From a468211b4cea13eba650670452c2cb758ddb0051 Mon Sep 17 00:00:00 2001 From: Nat DeFries <42820733+nmdefries@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:13:24 -0500 Subject: [PATCH] don't check missingness on args with defaults -- covid_hosp_state --- R/endpoints.R | 7 ++++--- tests/testthat/test-endpoints.R | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index 36f7b75..94f6adc 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -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" ) } diff --git a/tests/testthat/test-endpoints.R b/tests/testthat/test-endpoints.R index f452191..e29acb1 100644 --- a/tests/testthat/test-endpoints.R +++ b/tests/testthat/test-endpoints.R @@ -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" + ) +})