(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestTaskManagerExecutionProfiles(t *testing.T) { |
| 10 | t.Parallel() |
| 11 | |
| 12 | t.Run("Should return default inherit profile when no row is persisted", func(t *testing.T) { |
| 13 | t.Parallel() |
| 14 | |
| 15 | store := newInMemoryManagerStore() |
| 16 | store.tasks["task-1"] = validProfileTask("task-1") |
| 17 | manager := newTaskManagerForTest(t, store) |
| 18 | |
| 19 | profile, err := manager.GetExecutionProfile(context.Background(), "task-1", validActorContext()) |
| 20 | if err != nil { |
| 21 | t.Fatalf("GetExecutionProfile() error = %v", err) |
| 22 | } |
| 23 | |
| 24 | if got, want := profile.Coordinator.Mode, CoordinatorModeInherit; got != want { |
| 25 | t.Fatalf("Coordinator.Mode = %q, want %q", got, want) |
| 26 | } |
| 27 | if got, want := profile.Worker.Mode, WorkerModeInherit; got != want { |
| 28 | t.Fatalf("Worker.Mode = %q, want %q", got, want) |
| 29 | } |
| 30 | if got, want := profile.Sandbox.Mode, SandboxModeInherit; got != want { |
| 31 | t.Fatalf("Sandbox.Mode = %q, want %q", got, want) |
| 32 | } |
| 33 | }) |
| 34 | |
| 35 | t.Run("Should persist validated profile and emit audit event", func(t *testing.T) { |
| 36 | t.Parallel() |
| 37 | |
| 38 | store := newInMemoryManagerStore() |
| 39 | store.tasks["task-1"] = validProfileTask("task-1") |
| 40 | manager := newTaskManagerForTest(t, store) |
| 41 | |
| 42 | profile, err := manager.SetExecutionProfile(context.Background(), "task-1", &ExecutionProfile{ |
| 43 | Coordinator: CoordinatorProfile{Mode: CoordinatorModeGuided, Guidance: "Keep the worker focused."}, |
| 44 | Worker: WorkerProfile{ |
| 45 | Mode: WorkerModeSelect, |
| 46 | AgentName: "coder", |
| 47 | AllowedAgentNames: []string{"coder"}, |
| 48 | RequiredCapabilities: []string{"go"}, |
| 49 | PreferredCapabilities: []string{"tests"}, |
| 50 | }, |
| 51 | Review: ReviewProfile{ |
| 52 | AgentName: "reviewer", |
| 53 | AllowedAgentNames: []string{"reviewer"}, |
| 54 | }, |
| 55 | Sandbox: SandboxPolicy{Mode: SandboxModeRef, SandboxRef: "workspace"}, |
| 56 | }, validActorContext()) |
| 57 | if err != nil { |
| 58 | t.Fatalf("SetExecutionProfile() error = %v", err) |
| 59 | } |
| 60 | |
| 61 | if got, want := profile.TaskID, "task-1"; got != want { |
| 62 | t.Fatalf("TaskID = %q, want %q", got, want) |
| 63 | } |
| 64 | if got, want := store.profiles["task-1"].Worker.AgentName, "coder"; got != want { |
| 65 | t.Fatalf("stored Worker.AgentName = %q, want %q", got, want) |
| 66 | } |
nothing calls this directly
no test coverage detected