Skip to content

Commit

Permalink
Signal error when course period unmatched
Browse files Browse the repository at this point in the history
Signed-off-by: Liang Zhang <[email protected]>
  • Loading branch information
psychelzh committed Aug 31, 2023
1 parent 08bbfb6 commit 6a20dd5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 8 additions & 3 deletions R/prepare_fetch_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ fetch_config_tbl <- function(course_name, course_period, ...) {
# course periods are numeric coded in database
if (is.character(course_period)) {
if (!course_period %in% name_course_periods) {
warn("Invalid course period specified.", class = "tarflow_invalid_period")
abort(
"Invalid course period specified.",
class = "tarflow_invalid_period"
)
}
course_period <- which(name_course_periods == course_period)
}
Expand All @@ -177,7 +180,9 @@ read_sql_file <- function(file) {
}

utils::globalVariables(
c("scores", "raw_data", "raw_data_parsed", "indices",
c(
"scores", "raw_data", "raw_data_parsed", "indices",
"project_id", "game_id", "course_date",
"prep_fun_name", "prep_fun", "input", "extra")
"prep_fun_name", "prep_fun", "input", "extra"
)
)
12 changes: 9 additions & 3 deletions tests/testthat/test-prepare_fetch_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ test_that("Smoke test", {
~course_name, ~course_period,
"Unexisted", "Malvalue"
)
memoise::drop_cache(fetch_config_tbl_mem)("Unexisted", "Malvalue")
prepare_fetch_data(tbl_params_bad) |>
expect_null() |>
expect_warning(class = "tarflow_invalid_period") |>
expect_error(class = "tarflow_invalid_period")

tbl_params_bad <- tibble::tribble(
~course_name, ~course_period,
"Unexisted", 7
)
memoise::drop_cache(fetch_config_tbl_mem)("Unexisted", 0)
prepare_fetch_data(tbl_params_bad) |>
expect_warning(class = "tarflow_bad_params")

})

test_that("Work with `tar_make()", {
Expand Down

0 comments on commit 6a20dd5

Please sign in to comment.