MCPcopy Create free account
hub / github.com/astercloud/aster / TestExecuteContinueOnError

Function TestExecuteContinueOnError

pkg/executionplan/executor_test.go:234–281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

232}
233
234func TestExecuteContinueOnError(t *testing.T) {
235 testErr := errors.New("test error")
236 tool1 := newMockTool("tool1", "result1", nil)
237 tool2 := newMockTool("tool2", nil, testErr)
238 tool3 := newMockTool("tool3", "result3", nil)
239
240 toolMap := map[string]tools.Tool{
241 "tool1": tool1,
242 "tool2": tool2,
243 "tool3": tool3,
244 }
245
246 executor := NewExecutor(toolMap)
247
248 plan := NewExecutionPlan("Continue on error test")
249 plan.AddStep("tool1", "Step 1", nil)
250 plan.AddStep("tool2", "Step 2", nil)
251 plan.AddStep("tool3", "Step 3", nil)
252 plan.Options.RequireApproval = false
253 plan.Options.StopOnError = false
254
255 ctx := context.Background()
256 toolCtx := &tools.ToolContext{AgentID: "test-agent"}
257
258 err := executor.Execute(ctx, plan, toolCtx)
259 if err == nil {
260 t.Fatal("expected error to be returned")
261 }
262
263 if plan.Steps[0].Status != StepStatusCompleted {
264 t.Errorf("step 0: expected %v, got %v", StepStatusCompleted, plan.Steps[0].Status)
265 }
266 if plan.Steps[1].Status != StepStatusFailed {
267 t.Errorf("step 1: expected %v, got %v", StepStatusFailed, plan.Steps[1].Status)
268 }
269 if plan.Steps[2].Status != StepStatusCompleted {
270 t.Errorf("step 2: expected %v, got %v", StepStatusCompleted, plan.Steps[2].Status)
271 }
272
273 // Tool3 should still execute
274 if tool3.ExecutionCount() != 1 {
275 t.Errorf("tool3 should have been executed once, got %d", tool3.ExecutionCount())
276 }
277
278 if plan.Status != StatusPartial {
279 t.Errorf("expected status %v, got %v", StatusPartial, plan.Status)
280 }
281}
282
283func TestExecuteParallel(t *testing.T) {
284 // Use delays to verify parallel execution

Callers

nothing calls this directly

Calls 6

AddStepMethod · 0.95
ExecuteMethod · 0.95
newMockToolFunction · 0.85
NewExecutionPlanFunction · 0.85
ExecutionCountMethod · 0.80
NewExecutorFunction · 0.70

Tested by

no test coverage detected