tests/testthat/test-get-data.R

context("Only a single valid id returns a dataframe")

test_df <- statswalesr::statswales_get_dataset("hlth0515")

test_that("get_dataset with a valid id returns a dataframe, if API is available", {
  expect_true(is.data.frame(test_df) | is.null(test_df))
  })

test_that("invalid id returns NULL", {
  expect_null(statswalesr::statswales_get_dataset("XXXXX"))
  })

test_that("numeric input returns an error", {
  expect_error(statswalesr::statswales_get_dataset(1234))
  })

test_that("vector of valid ids returns an error", {
  expect_error(statswalesr::statswales_get_dataset(c("Econ0072", "Hlth0019")))
  })

Try the statswalesr package in your browser

Any scripts or data that you put into this service are public.

statswalesr documentation built on April 4, 2022, 1:06 a.m.