tests/testthat/test-get-data.R

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

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

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")))
  })
jamie-ralph/statswalesr documentation built on Oct. 22, 2024, 9:45 p.m.