Skip to content

Commit

Permalink
don't check missingness on args with defaults -- covid_hosp_state
Browse files Browse the repository at this point in the history
  • Loading branch information
nmdefries committed Mar 4, 2024
1 parent 5d63158 commit a468211
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,10 @@ pub_covid_hosp_state_timeseries <- function(
# Check parameters
rlang::check_dots_empty()

if (missing(states) || missing(dates)) {
stop(
"`states` and `dates` are both required"
if (missing(states)) {
cli::cli_abort(
"`states` is required",
class = "epidatr__pub_covid_hosp_state_timeseries__missing_required_args"
)
}

Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -570,3 +570,14 @@ test_that("pub_covidcast catches missing args for args without defaults", {
class = "epidatr__pub_covidcast__missing_required_args"
)
})

test_that("pub_covid_hosp_state_timeseries catches missing args for args without defaults", {
expect_no_error(pub_covid_hosp_state_timeseries(
states = "fl",
fetch_args = fetch_args_list(dry_run = TRUE)
))
expect_error(
pub_covid_hosp_state_timeseries(),
class = "epidatr__pub_covid_hosp_state_timeseries__missing_required_args"
)
})

0 comments on commit a468211

Please sign in to comment.