Skip to content

Commit

Permalink
test missing forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidari committed Dec 20, 2024
1 parent 3f4d8fa commit 3df0671
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions hewr/tests/testthat/test_score_hubverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,30 @@ testthat::test_that("score_hubverse handles missing location data", {
expect_false("loc2" %in% result$location)
expect_setequal(observed$location, result$location)
})


testthat::test_that("score_hubverse handles zero length forecast table", {
forecast <- tibble::tibble(
reference_date = as.Date(character(0)),
horizon = integer(0),
output_type_id = numeric(0),
location = character(0),
value = numeric(0),
target = character(0),
output_type = character(0),
target_end_date = as.Date(character(0))
)

observed <- create_observation_data(
date_cols = seq(
lubridate::ymd("2024-11-01"), lubridate::ymd("2024-11-02"),
by = "day"
),
location = c("loc1")
)

expect_error(
result <- score_hubverse(forecast, observed),
"Assertion on 'data' failed: Must have at least 1 rows, but has 0 rows."
)
})

0 comments on commit 3df0671

Please sign in to comment.