(t *testing.T)
| 666 | } |
| 667 | |
| 668 | func 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 | |
| 704 | func TestExecuteWithInputParameters(t *testing.T) { |
| 705 | tool1 := newMockTool("tool1", "result", nil) |
nothing calls this directly
no test coverage detected