Skip to content

Commit

Permalink
Start testing default action.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed May 13, 2024
1 parent 387a58e commit e811a20
Showing 1 changed file with 72 additions and 1 deletion.
73 changes: 72 additions & 1 deletion src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,20 @@ command = "c"
assert_eq!(submit_options.partition, Some("i".to_string()));
}

#[test]
#[parallel]
fn default_action_from() {
let temp = TempDir::new().unwrap();
let workflow = r#"
[default.action]
from = "a"
"#;
let result = Workflow::open_str(temp.path(), workflow);
assert!(result.is_err());

assert!(result.unwrap_err().to_string().contains("asdf"));
}

#[test]
#[parallel]
fn empty_action_default() {
Expand Down Expand Up @@ -1358,7 +1372,64 @@ command = "c"
assert_eq!(action.from, None);
}

// TODO: Test action default all keys
#[test]
#[parallel]
fn action_default() {
let temp = TempDir::new().unwrap();
let workflow = r#"
[default.action]
name = "a"
command = "b"
launchers = ["c"]
previous_actions = ["d"]
products = ["e"]
[default.action.resources]
processes.per_directory = 2
threads_per_process = 3
gpus_per_process = 4
walltime.per_submission = "00:00:01"
# submit_options is tested above
[default.action.group]
include = [["/f", "equal_to", 5]]
sort_by = ["/g"]
split_by_sort_key = true
reverse_sort = true
maximum_size = 6
submit_whole = true
[[action]]
[[action]]
name = "d"
"#;

let workflow = Workflow::open_str(temp.path(), workflow).unwrap();

assert_eq!(workflow.action.len(), 2);

let action = workflow.action.first().unwrap();
assert_eq!(action.name(), "a");
assert_eq!(action.command(), "b");
assert_eq!(action.launchers(), vec!["c"]);
assert_eq!(action.previous_actions(), vec!["d"]);
assert_eq!(action.products(), vec!["e"]);
assert_eq!(action.resources.processes(), Processes::PerDirectory(2));
assert_eq!(action.resources.threads_per_process, Some(3));
assert_eq!(action.resources.gpus_per_process, Some(4));
assert_eq!(action.resources.walltime(), Walltime::PerSubmission(Duration::new(true, 0, 1, 0).unwrap()));
assert!(action.submit_options.is_empty());
assert_eq!(action.group.include, vec![("/f".into(), Comparison::EqualTo, serde_json::Value::from(5))]);
assert_eq!(action.group.sort_by, vec!["/g"]);
assert!(action.group.split_by_sort_key);
assert!(action.group.reverse_sort);
assert_eq!(action.group.maximum_size, Some(6));
assert!(action.group.submit_whole);
assert_eq!(action.from, None);
}

// TODO: Test action from all keys
// TODO: Test action override from
// TODO: Test action override default
Expand Down

0 comments on commit e811a20

Please sign in to comment.