Skip to content

Commit 0fa2491

Browse files
committed
test date/str handling
1 parent ff87a71 commit 0fa2491

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/testthat/test-utils.R

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,42 @@ test_that("format_list", {
2020
expect_identical(format_list(list("5", "6")), "5,6")
2121
expect_identical(format_list(list("*", "*")), "*,*")
2222
})
23+
24+
test_that("check_is_cachable can handle both str and date inputs of various lengths", {
25+
epidata_call <- list(
26+
params = list(as_of = NULL, issues = NULL)
27+
)
28+
fetch_args <- fetch_args_list()
29+
30+
expect_no_error(check_is_cachable(epidata_call, fetch_args))
31+
32+
# as_of string
33+
epidata_call$params$as_of <- "2022-01-01"
34+
epidata_call$params$issues <- NULL
35+
expect_no_error(check_is_cachable(epidata_call, fetch_args))
36+
37+
# as_of date
38+
epidata_call$params$as_of <- as.Date("2022-01-01")
39+
epidata_call$params$issues <- NULL
40+
expect_no_error(check_is_cachable(epidata_call, fetch_args))
41+
42+
# issues single string
43+
epidata_call$params$as_of <- NULL
44+
epidata_call$params$issues <- "2022-01-01"
45+
expect_no_error(check_is_cachable(epidata_call, fetch_args))
46+
47+
# issues string vector
48+
epidata_call$params$as_of <- NULL
49+
epidata_call$params$issues <- c("2022-01-01", "2022-02-01")
50+
expect_no_error(check_is_cachable(epidata_call, fetch_args))
51+
52+
# issues single date
53+
epidata_call$params$as_of <- NULL
54+
epidata_call$params$issues <- as.Date("2022-01-01")
55+
expect_no_error(check_is_cachable(epidata_call, fetch_args))
56+
57+
# issues date vector
58+
epidata_call$params$as_of <- NULL
59+
epidata_call$params$issues <- c(as.Date("2022-01-01"), as.Date("2022-02-01"))
60+
expect_no_error(check_is_cachable(epidata_call, fetch_args))
61+
})

0 commit comments

Comments
 (0)