Skip to content

Commit

Permalink
fixup! fixup! Builtin iterate action
Browse files Browse the repository at this point in the history
  • Loading branch information
albinsuresh committed Aug 14, 2024
1 parent 1012f41 commit 358979c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 0 additions & 1 deletion crates/core/tedge_api/src/workflow/script.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::WorkflowDefinitionError;
use crate::workflow::GenericStateUpdate;
use crate::workflow::ScriptDefinitionError;
use serde::de::Error;
Expand Down
20 changes: 18 additions & 2 deletions crates/core/tedge_api/src/workflow/toml_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ action = "proceed"
on_success = "apply_operation"
[apply_operation]
iterate = "{.payload.target}"
iterate = "${.payload.target}"
on_next = "next_operation"
on_success = "successful"
on_error = "failed"
Expand All @@ -656,7 +656,7 @@ action = "cleanup"
on_error,
},
) => {
assert_eq!(target, "{.payload.target}");
assert_eq!(target, ".payload.target");
assert_eq!(on_next, &"next_operation".into());
assert_eq!(on_success, &"successful".into());
assert_eq!(on_error, &Some("failed".into()));
Expand Down Expand Up @@ -694,4 +694,20 @@ on_error = "failed"
let res = OperationWorkflow::try_from(input);
assert_matches!(res, Err(WorkflowDefinitionError::MissingState { state }) if state == *"on_success");
}

#[test]
fn iterate_parse_fails_with_invalid_json_path() {
let file = r#"
operation = "custom_operation"
[apply_operation]
iterate = "{invalid.json.path}"
on_next = "next_operation"
on_success = "successful"
on_error = "failed"
"#;
let input: TomlOperationWorkflow = toml::from_str(file).unwrap();
let res = OperationWorkflow::try_from(input);
assert_matches!(res, Err(WorkflowDefinitionError::InvalidPathExpression(_)));
}
}

0 comments on commit 358979c

Please sign in to comment.