(t *testing.T)
| 361 | } |
| 362 | |
| 363 | func TestExecuteParallelWithDependencies(t *testing.T) { |
| 364 | tool1 := newDelayedMockTool("install", "installed", 30*time.Millisecond) |
| 365 | tool2 := newDelayedMockTool("build", "built", 30*time.Millisecond) |
| 366 | tool3 := newDelayedMockTool("test", "tested", 30*time.Millisecond) |
| 367 | tool4 := newDelayedMockTool("lint", "linted", 30*time.Millisecond) |
| 368 | |
| 369 | toolMap := map[string]tools.Tool{ |
| 370 | "install": tool1, |
| 371 | "build": tool2, |
| 372 | "test": tool3, |
| 373 | "lint": tool4, |
| 374 | } |
| 375 | |
| 376 | executor := NewExecutor(toolMap) |
| 377 | |
| 378 | plan := NewExecutionPlan("Parallel with deps test") |
| 379 | |
| 380 | // install -> build -> test |
| 381 | // install -> lint (can run parallel with build/test) |
| 382 | step1 := plan.AddStep("install", "Install deps", nil) |
| 383 | step2 := plan.AddStep("build", "Build project", nil) |
| 384 | step2.DependsOn = []string{step1.ID} |
| 385 | step3 := plan.AddStep("test", "Run tests", nil) |
| 386 | step3.DependsOn = []string{step2.ID} |
| 387 | step4 := plan.AddStep("lint", "Run linter", nil) |
| 388 | step4.DependsOn = []string{step1.ID} |
| 389 | |
| 390 | plan.Options.RequireApproval = false |
| 391 | plan.Options.AllowParallel = true |
| 392 | plan.Options.MaxParallelSteps = 3 |
| 393 | |
| 394 | ctx := context.Background() |
| 395 | toolCtx := &tools.ToolContext{AgentID: "test-agent"} |
| 396 | |
| 397 | err := executor.Execute(ctx, plan, toolCtx) |
| 398 | if err != nil { |
| 399 | t.Fatalf("unexpected error: %v", err) |
| 400 | } |
| 401 | |
| 402 | if plan.Status != StatusCompleted { |
| 403 | t.Errorf("expected status %v, got %v", StatusCompleted, plan.Status) |
| 404 | } |
| 405 | |
| 406 | for i, step := range plan.Steps { |
| 407 | if step.Status != StepStatusCompleted { |
| 408 | t.Errorf("step %d (%s): expected %v, got %v", i, step.ToolName, StepStatusCompleted, step.Status) |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | func TestExecuteRequiresApproval(t *testing.T) { |
| 414 | toolMap := map[string]tools.Tool{ |
nothing calls this directly
no test coverage detected