Skip to content

Commit a3b9816

Browse files
fix check and tests
1 parent 4f5b1fd commit a3b9816

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

R/workflow.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
create_workflow <- function(wf_name, default_sbatch_opts,
3939
wf_common_dir = "workflows") {
4040
sbatch_opts <- validate_sbatch_opts(default_sbatch_opts)
41-
if (!"partition" %in% sbatch_opts)
41+
if (!"partition" %in% names(sbatch_opts))
4242
stop("A `partition` option must be defined in `default_sbatch_opts`")
4343
wf_summary <- new_summary(fs::path(wf_common_dir, wf_name), sbatch_opts)
4444
create_wf_dir(wf_summary)

tests/testthat/test-add_workflow_step.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ test_that("`add_workflow_step` produces the right file structure", {
1717
wf <- create_workflow(
1818
wf_name = wf_name,
1919
default_sbatch_opts = list(
20+
"partition" = "test_partition",
2021
"account" = "test_account"
2122
),
2223
wf_common_dir = test_dir

tests/testthat/test-create_workflow.R

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test_that("`create_workflow` produces the right file structure", {
77
wf <- create_workflow(
88
wf_name = wf_name,
99
default_sbatch_opts = list(
10+
"partition" = "dummy_part",
1011
"account" = "test_account"
1112
),
1213
wf_common_dir = test_dir
@@ -35,17 +36,34 @@ test_that("`create_workflow` fails if a workflow with the same name already exis
3536
create_workflow(
3637
wf_name = wf_name,
3738
default_sbatch_opts = list(
38-
"account" = "test_account"
39+
"partition" = "test_partition"
3940
),
4041
wf_common_dir = test_dir
4142
)
4243

44+
expect_error(
45+
create_workflow(
46+
wf_name = wf_name,
47+
default_sbatch_opts = list(
48+
"partition" = "test_partition"
49+
),
50+
wf_common_dir = test_dir
51+
)
52+
)
53+
})
54+
55+
test_that("`create_workflow` fails if no `partition` is selected", {
56+
test_dir <- "workflows"
57+
withr::local_file(test_dir)
58+
59+
wf_name <- "test_wf_part"
60+
4361
expect_error(
4462
create_workflow(
4563
wf_name = wf_name,
4664
default_sbatch_opts = list(
4765
"account" = "test_account"
48-
),
66+
),
4967
wf_common_dir = test_dir
5068
)
5169
)

0 commit comments

Comments
 (0)