# For the selection of species and years that we can use for testing see
# tests/testthat/helper.R
test_that("we get a tibble", {
my_data <- suppressWarnings(getCwacSppCounts(sample(spp, 1)))
expect_s3_class(my_data, "tbl_df")
})
# For the next tests we need a standard to match the outputs of getCwacSppCounts()
# against. This is found at tests/testthat/fixtures/empty_cwac_spp_df_yyyymmdd.rds
# where yyyymmdd is the data of the last file to use as reference. If the
# standard changed, we would need to generate a new file with the new standard
# and the new date. It would be good to keep all standards for future comparison
test_that("we get the correct number of columns", {
my_data <- suppressWarnings(getCwacSppCounts(sample(spp, 1)))
ref_data <- readRDS(test_path("fixtures", "empty_cwac_spp_df_20240731.rds"))
expect_equal(ncol(my_data), ncol(ref_data))
})
test_that("we get the correct types of columns", {
my_data <- suppressWarnings(getCwacSppCounts(sample(spp, 1)))
ref_data <- readRDS(test_path("fixtures", "empty_cwac_spp_df_20240731.rds"))
expect_equal(sapply(my_data, class), sapply(ref_data, class))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.