From e2e9cbd0f35c32a3990ce6df630b4d78c00cf695 Mon Sep 17 00:00:00 2001 From: ross hull Date: Fri, 5 Jul 2024 16:22:09 +0100 Subject: [PATCH] add tests --- tests/testthat/test-get_dataset_additional_info.R | 7 +++++++ tests/testthat/test-get_latest_resource.R | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/testthat/test-get_dataset_additional_info.R create mode 100644 tests/testthat/test-get_latest_resource.R diff --git a/tests/testthat/test-get_dataset_additional_info.R b/tests/testthat/test-get_dataset_additional_info.R new file mode 100644 index 0000000..2ef9751 --- /dev/null +++ b/tests/testthat/test-get_dataset_additional_info.R @@ -0,0 +1,7 @@ +test_that("returns data in the expected format", { + expect_s3_class(get_dataset_additional_info("weekly-accident-and-emergency-activity-and-waiting-times"), "tbl_df") +}) + +test_that("returned tibble has one row", { + expect_equal(nrow(get_dataset_additional_info("weekly-accident-and-emergency-activity-and-waiting-times")), 1) +}) diff --git a/tests/testthat/test-get_latest_resource.R b/tests/testthat/test-get_latest_resource.R new file mode 100644 index 0000000..341326b --- /dev/null +++ b/tests/testthat/test-get_latest_resource.R @@ -0,0 +1,10 @@ +test_that("returns more than 0 datasets", { + # select the first row of the tibble and get the + # number of rows. If no datasets were returned + # this will be 0 + expect_equal(nrow(dplyr::slice(list_datasets(), 1)), 1) +}) + +test_that("returns data in the expected format", { + expect_s3_class(list_datasets(), "tbl_df") +})