| 1209 | |
| 1210 | #[tokio::test] |
| 1211 | async fn program_executor_runs_steps_in_order() { |
| 1212 | let registry = Arc::new(ToolRegistry::new(PathBuf::from("/tmp"))); |
| 1213 | registry.register(Arc::new(EchoTool)); |
| 1214 | let executor = ProgramExecutor::new( |
| 1215 | Arc::clone(®istry), |
| 1216 | ToolContext::new(PathBuf::from("/tmp")), |
| 1217 | ); |
| 1218 | let program = Program::new("two_echoes", "Run two echo steps") |
| 1219 | .with_step(ProgramStep::new( |
| 1220 | "echo", |
| 1221 | serde_json::json!({ "message": "one" }), |
| 1222 | )) |
| 1223 | .with_step(ProgramStep::new( |
| 1224 | "echo", |
| 1225 | serde_json::json!({ "message": "two" }), |
| 1226 | )); |
| 1227 | |
| 1228 | let result = executor.execute(&program).await.unwrap(); |
| 1229 | |
| 1230 | assert!(result.success); |
| 1231 | assert_eq!(result.steps.len(), 2); |
| 1232 | assert_eq!(result.steps[0].output, "one"); |
| 1233 | assert_eq!(result.steps[1].output, "two"); |
| 1234 | assert_eq!(result.steps[0].label, None); |
| 1235 | assert_eq!( |
| 1236 | result.summary, |
| 1237 | "Program 'two_echoes' completed after 2/2 steps." |
| 1238 | ); |
| 1239 | } |
| 1240 | |
| 1241 | #[tokio::test] |
| 1242 | async fn program_executor_stops_after_failed_step() { |