Skip to content

Commit 5e7a0f6

Browse files
committed
test missing date parsing behavior
1 parent fa038fa commit 5e7a0f6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/testthat/test-model.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ test_that("null parsing", {
5757
# see generate_test_data.R
5858
mock_df <- as.data.frame(readr::read_rds(testthat::test_path("data/flusurv-epiweeks.rds")))
5959
metadata <- epidata_call$meta
60-
mock_df[[metadata[[1]]$name]][1] <- list(NULL)
60+
mock_df[[metadata[[1]]$name]][1] <- NA
6161
mock_df[[metadata[[2]]$name]] <- c(TRUE)
6262
epidata_call$meta[[2]]$type <- "bool"
63-
res <- parse_data_frame(epidata_call, mock_df) %>% as_tibble()
63+
expect_no_error(res <- parse_data_frame(epidata_call, mock_df) %>% as_tibble())
6464
expect_true(res$location)
65+
expect_identical(res$release_date, as.Date(NA))
6566

6667
# if the call has no metadata, return the whole frame as is
6768
epidata_call$meta <- NULL
@@ -108,3 +109,7 @@ test_that("parse_api_date accepts YYYYMMDD and YYYY-MM-DD", {
108109
expect_identical(parse_api_date(20200101), as.Date("2020-01-01"))
109110
expect_identical(parse_api_date("2020-01-01"), as.Date("2020-01-01"))
110111
})
112+
113+
test_that("parse_api_date handles missing values appropriately", {
114+
expect_identical(parse_api_date(NA), as.Date(NA))
115+
})

0 commit comments

Comments
 (0)