test(graph): run a validated two-step map chain end to end

Same two-script chain as `map_chain_two_script_steps_route_via_next`,
with `validate_before_run: true`, proving the validator admits the
chains the runtime executes.
This commit is contained in:
Dark-Alex-17 committed 2026-09-11 10:56:27 -06:00
1 parent 824edf587b
commit 846bc39263
1 file changed
+49
+49
View File
@@ -687,6 +687,55 @@ nodes:
assert_eq!(collected(&result), vec![json!(3), json!(5), json!(7)]); assert_eq!(collected(&result), vec![json!(3), json!(5), json!(7)]);
} }
#[tokio::test]
async fn map_chain_two_script_steps_pass_validation_before_run() {
if !cmd_available("python3") {
eprintln!("skipping: python3 not available");
return;
}
let ws = TestWorkspace::new();
ws.write_py(
"step_one.py",
r#"print(json.dumps({"draft": state["item"] * 2}))"#,
);
ws.write_py(
"step_two.py",
r#"print(json.dumps({"output": state["draft"] + 1}))"#,
);
let yaml = r#"
name: chain
start: fan_out
settings:
validate_before_run: true
initial_state:
items: [1, 2, 3]
nodes:
fan_out:
type: map
over: "{{items}}"
as: item
branch: step_one
collect_into: results
next: done
step_one:
type: script
script: step_one.py
next: step_two
step_two:
type: script
script: step_two.py
done:
type: end
output: "{{results}}"
"#;
let result = run_graph(yaml, &ws)
.await
.unwrap_or_else(|e| panic!("validation rejected a runnable chain: {e:#}"));
assert_eq!(collected(&result), vec![json!(3), json!(5), json!(7)]);
}
#[tokio::test] #[tokio::test]
async fn map_chain_script_next_loop_is_bounded_by_max_loop_iterations() { async fn map_chain_script_next_loop_is_bounded_by_max_loop_iterations() {
if !cmd_available("python3") { if !cmd_available("python3") {