This function runs a battery of tests of the given diseasystore.
The supplied diseasystore must be a generator for the diseasystore, not an instance of the diseasystore.
The tests assume that data has been made available locally to run the majority of the tests. The location of the local data should be configured in the options for "source_conn" of the given diseasystore before calling test_diseasystore.
Usage
test_diseasystore(
diseasystore_generator = NULL,
conn_generator = NULL,
data_files = NULL,
target_schema = "test_ds",
test_start_date = NULL,
skip_backends = NULL,
...
)
Arguments
- diseasystore_generator
(
Diseasystore*
)
The diseasystore R6 class generator to test.- conn_generator
(
function
)
Function that generates alist
() of connections use as target_conn. Should take askip_backend
that does not open connections for the given backends.- data_files
(
character()
)
List of files that should be available when testing.- target_schema
(
character(1)
)
The data base schema where the tests should be run.- test_start_date
(
Date
)
The earliest date to retrieve data from during tests.- skip_backends
(
character()
)
List of connection types to skip tests for due to missing functionality.- ...
Other parameters passed to the diseasystore generator.
Examples
# \donttest{
withr::local_options("diseasystore.DiseasystoreEcdcRespiratoryViruses.pull" = FALSE)
conn_generator <- function(skip_backends = NULL) {
switch(
("SQLiteConnection" %in% skip_backends) + 1,
list(DBI::dbConnect(RSQLite::SQLite())), # SQLiteConnection not in skip_backends
list() # SQLiteConnection in skip_backends
)
}
test_diseasystore(
DiseasystoreEcdcRespiratoryViruses,
conn_generator,
data_files = "data/snapshots/2023-11-24_ILIARIRates.csv",
target_schema = "test_ds",
test_start_date = as.Date("2022-06-20"),
slice_ts = "2023-11-24"
)
#> Test passed π
#> ββ Skip: DiseasystoreEcdcRespiratoryViruses can initialise with remote source_conn ββ
#> Reason: empty test
#>
#> ββ Failure: DiseasystoreEcdcRespiratoryViruses can initialise with default source_conn ββ
#> Expected `ds$get_feature(ds$available_features[[1]])` to run without any errors.
#> i Actually got a <purrr_error_indexed> with text:
#> i In index: 1.
#> Caused by error in `source_conn_github()`:
#> ! The directory /tmp/Rtmp026ZJm does not appear to be a git repository. Cannot pull.
#>
#> Error: Test failed
# }