@@ -65,6 +65,33 @@ test_that("check_is_cachable can handle both str and date inputs of various leng
6565 expect_no_error(check_is_cachable(epidata_call , fetch_args ))
6666})
6767
68+ test_that(" check_is_recent can handle both str and date inputs of various lengths" , {
69+ # NULL
70+ as_of <- NULL
71+ expect_no_error(result <- check_is_recent(as_of , 10 ))
72+ expect_identical(result , FALSE )
73+
74+ # as_of single string
75+ as_of <- " 2022-01-01"
76+ expect_no_error(result <- check_is_recent(as_of , 10 ))
77+ expect_identical(result , FALSE )
78+
79+ # as_of string vector
80+ as_of <- c(" 2022-01-01" , " 3000-01-02" , " 3000-01-03" )
81+ expect_no_error(result <- check_is_recent(as_of , 10 ))
82+ expect_identical(result , TRUE )
83+
84+ # as_of single date
85+ as_of <- as.Date(" 2022-01-01" )
86+ expect_no_error(result <- check_is_recent(as_of , 10 ))
87+ expect_identical(result , FALSE )
88+
89+ # as_of date vector
90+ as_of <- as.Date(c(" 2022-01-01" , " 3000-01-02" , " 3000-01-03" ))
91+ expect_no_error(result <- check_is_recent(as_of , 10 ))
92+ expect_identical(result , TRUE )
93+ })
94+
6895test_that(" get_wildcard_equivalent_dates works in basic cases" , {
6996 # Week date
7097 result <- get_wildcard_equivalent_dates(epirange(202002 , 202013 ), " week" )
0 commit comments