(t *testing.T)
| 140 | } |
| 141 | |
| 142 | func TestExecuteSequential(t *testing.T) { |
| 143 | tool1 := newMockTool("tool1", "result1", nil) |
| 144 | tool2 := newMockTool("tool2", "result2", nil) |
| 145 | tool3 := newMockTool("tool3", "result3", nil) |
| 146 | |
| 147 | toolMap := map[string]tools.Tool{ |
| 148 | "tool1": tool1, |
| 149 | "tool2": tool2, |
| 150 | "tool3": tool3, |
| 151 | } |
| 152 | |
| 153 | executor := NewExecutor(toolMap) |
| 154 | |
| 155 | plan := NewExecutionPlan("Sequential test") |
| 156 | plan.AddStep("tool1", "Step 1", nil) |
| 157 | plan.AddStep("tool2", "Step 2", nil) |
| 158 | plan.AddStep("tool3", "Step 3", nil) |
| 159 | plan.Options.RequireApproval = false |
| 160 | |
| 161 | ctx := context.Background() |
| 162 | toolCtx := &tools.ToolContext{AgentID: "test-agent"} |
| 163 | |
| 164 | err := executor.Execute(ctx, plan, toolCtx) |
| 165 | if err != nil { |
| 166 | t.Fatalf("unexpected error: %v", err) |
| 167 | } |
| 168 | |
| 169 | if plan.Status != StatusCompleted { |
| 170 | t.Errorf("expected status %v, got %v", StatusCompleted, plan.Status) |
| 171 | } |
| 172 | |
| 173 | for i, step := range plan.Steps { |
| 174 | if step.Status != StepStatusCompleted { |
| 175 | t.Errorf("step %d: expected status %v, got %v", i, StepStatusCompleted, step.Status) |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | if tool1.ExecutionCount() != 1 { |
| 180 | t.Errorf("tool1 executed %d times, expected 1", tool1.ExecutionCount()) |
| 181 | } |
| 182 | if tool2.ExecutionCount() != 1 { |
| 183 | t.Errorf("tool2 executed %d times, expected 1", tool2.ExecutionCount()) |
| 184 | } |
| 185 | if tool3.ExecutionCount() != 1 { |
| 186 | t.Errorf("tool3 executed %d times, expected 1", tool3.ExecutionCount()) |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | func TestExecuteWithError(t *testing.T) { |
| 191 | testErr := errors.New("test error") |
nothing calls this directly
no test coverage detected