Skip to content

Commit

Permalink
test-submit-model.R: improve .mode override test
Browse files Browse the repository at this point in the history
The test that passing .mode overrides the bbr.bbi_exe_mode option
doesn't account for bbr.bbi_exe_mode being "local" on non-Linux
machines (i.e. the test would pass even if the argument didn't have an
effect).

Use the same approach that other tests do to explicitly choose a mode
other than the default.  Also extract the check and put it in its own
test next to a similar check.
  • Loading branch information
kyleam committed Dec 19, 2024
1 parent 303cfe0 commit 01f39e6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/testthat/test-submit-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ test_that("submit_model(.dry_run=TRUE) returns correct command string", {
as.character(glue("{cmd_prefix} {default_mode} {mod_ctl_path} --overwrite --threads=4 --parallel"))
)

# switch to local mode
expect_identical(
submit_model(MOD1, .mode = "local", .dry_run = TRUE)[[PROC_CALL]],
as.character(glue("{cmd_prefix} local {mod_ctl_path} --overwrite --threads=4 --parallel"))
)

# over-riding yaml arg with passed args
expect_identical(
submit_model(MOD1,
Expand Down Expand Up @@ -86,6 +80,14 @@ test_that("submit_model() throws an error if passed `output_dir` bbi arg", {
)
})

test_that("submit_model() .mode argument overrides bbr.bbi_exe_mode default", {
other_mode <- if (identical(default_mode, "local")) "slurm" else "local"
expect_identical(
submit_model(MOD1, .mode = other_mode, .dry_run = TRUE)[[PROC_CALL]],
as.character(glue("{cmd_prefix} {other_mode} {mod_ctl_path} --overwrite --threads=4 --parallel"))
)
})

test_that("submit_model(.mode) inherits option", {
other_mode <- if (identical(default_mode, "local")) "slurm" else "local"
withr::with_options(list(bbr.bbi_exe_mode = other_mode), {
Expand Down

0 comments on commit 01f39e6

Please sign in to comment.