(t *testing.T)
| 411 | } |
| 412 | |
| 413 | func TestExecuteRequiresApproval(t *testing.T) { |
| 414 | toolMap := map[string]tools.Tool{ |
| 415 | "tool1": newMockTool("tool1", "result1", nil), |
| 416 | } |
| 417 | |
| 418 | executor := NewExecutor(toolMap) |
| 419 | |
| 420 | plan := NewExecutionPlan("Requires approval") |
| 421 | plan.AddStep("tool1", "Step 1", nil) |
| 422 | plan.Options.RequireApproval = true |
| 423 | |
| 424 | ctx := context.Background() |
| 425 | toolCtx := &tools.ToolContext{AgentID: "test-agent"} |
| 426 | |
| 427 | err := executor.Execute(ctx, plan, toolCtx) |
| 428 | if err == nil { |
| 429 | t.Fatal("expected error for unapproved plan") |
| 430 | } |
| 431 | |
| 432 | if plan.Status != StatusDraft { |
| 433 | t.Errorf("expected status %v, got %v", StatusDraft, plan.Status) |
| 434 | } |
| 435 | |
| 436 | // Now approve and execute |
| 437 | plan.Approve("test-user") |
| 438 | err = executor.Execute(ctx, plan, toolCtx) |
| 439 | if err != nil { |
| 440 | t.Fatalf("unexpected error after approval: %v", err) |
| 441 | } |
| 442 | |
| 443 | if plan.Status != StatusCompleted { |
| 444 | t.Errorf("expected status %v, got %v", StatusCompleted, plan.Status) |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | func TestExecuteContextCancellation(t *testing.T) { |
| 449 | tool1 := newDelayedMockTool("tool1", "result1", 100*time.Millisecond) |
nothing calls this directly
no test coverage detected