-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug and add test that would've caught it
- Loading branch information
1 parent
36ec48c
commit 83a1d65
Showing
5 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
hewr/man/get_all_forecast_dirs.Rd → hewr/man/get_all_model_batch_dirs.Rd
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(hewr) | ||
|
||
test_check("hewr") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
test_that("get_all_model_batch_dirs returns expected output", { | ||
withr::with_tempdir({ | ||
## create some directories | ||
valid_covid <- c( | ||
"covid-19_r_2024-02-01_f_2021-01-01_t_2024-01-31", | ||
"covid-19_r" | ||
) | ||
valid_flu <- c( | ||
"influenza_r_2022-11-12_f_2022-11-01_t_2022_11_10", | ||
"influenza_r" | ||
) | ||
valid_dirs <- c(valid_flu, valid_covid) | ||
|
||
invalid_dirs <- c( | ||
"this_is_not_valid", | ||
"covid19_r", | ||
"covid-19-r", | ||
"influenza-r", | ||
"influnza_r", | ||
"covid-19", | ||
"influenza" | ||
) | ||
|
||
invalid_files <- c( | ||
"covid-19_r.txt", | ||
"influenza_r.txt" | ||
) | ||
fs::dir_create(c(valid_dirs, invalid_dirs)) | ||
fs::file_create(invalid_files) | ||
expected_all_files <- c( | ||
valid_dirs, | ||
invalid_dirs, | ||
invalid_files | ||
) | ||
|
||
result_all <- fs::dir_ls(".") |> fs::path_file() | ||
|
||
result_valid <- get_all_model_batch_dirs( | ||
".", | ||
c("COVID-19", "Influenza") | ||
) | ||
|
||
result_valid_alt <- get_all_model_batch_dirs( | ||
".", | ||
c("Influenza", "COVID-19") | ||
) | ||
|
||
result_valid_covid <- get_all_model_batch_dirs( | ||
".", | ||
"COVID-19" | ||
) | ||
|
||
result_valid_flu <- get_all_model_batch_dirs( | ||
".", | ||
"Influenza" | ||
) | ||
|
||
expect_setequal(result_all, expected_all_files) | ||
expect_setequal(result_valid, c(valid_flu, valid_covid)) | ||
expect_setequal(result_valid_alt, c(valid_flu, valid_covid)) | ||
expect_setequal(result_valid_covid, valid_covid) | ||
expect_setequal(result_valid_flu, valid_flu) | ||
}) | ||
}) |