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

Function TestOnStepFailedCallback

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

Source from the content-addressed store, hash-verified

666}
667
668func TestOnStepFailedCallback(t *testing.T) {
669 testErr := errors.New("test error")
670 tool1 := newMockTool("tool1", nil, testErr)
671
672 toolMap := map[string]tools.Tool{
673 "tool1": tool1,
674 }
675
676 var failedStep *Step
677 var failedErr error
678
679 executor := NewExecutor(
680 toolMap,
681 WithOnStepFailed(func(p *ExecutionPlan, s *Step, err error) {
682 failedStep = s
683 failedErr = err
684 }),
685 )
686
687 plan := NewExecutionPlan("Failed callback test")
688 plan.AddStep("tool1", "Step 1", nil)
689 plan.Options.RequireApproval = false
690
691 ctx := context.Background()
692 toolCtx := &tools.ToolContext{AgentID: "test-agent"}
693
694 _ = executor.Execute(ctx, plan, toolCtx)
695
696 if failedStep == nil {
697 t.Fatal("OnStepFailed callback not called")
698 }
699 if failedErr == nil || failedErr.Error() != testErr.Error() {
700 t.Errorf("expected error %v, got %v", testErr, failedErr)
701 }
702}
703
704func TestExecuteWithInputParameters(t *testing.T) {
705 tool1 := newMockTool("tool1", "result", nil)

Callers

nothing calls this directly

Calls 7

AddStepMethod · 0.95
ExecuteMethod · 0.95
newMockToolFunction · 0.85
WithOnStepFailedFunction · 0.85
NewExecutionPlanFunction · 0.85
NewExecutorFunction · 0.70
ErrorMethod · 0.65

Tested by

no test coverage detected