package workflow import ( "context" "errors" "log/slog" "strings" "testing" "github.com/samcharles93/archie-core/internal/domain/workflow/task" ) // TestRunReportsTheParkedOutcome pins the status a parked run hands back to // whoever dispatched it: archie-agent returns tc.Outcome in its taskrun // response, so a park that leaves the outcome empty reads there as a run that // recorded nothing. func TestRunReportsTheParkedOutcome(t *testing.T) { reason := "agent parked (budget_exhausted): stopped after 60/60 steps" wf := Workflow{Name: "implement", Stages: []Stage{{ Name: "plan", Run: func(context.Context, *TaskContext) error { return errors.New(reason) }, }}} tc := &TaskContext{Task: &task.Task{ID: 1, Attempt: 1}, Store: &fakeStepStore{}, Log: slog.Default()} Run(context.Background(), wf, tc) if tc.Outcome.Status != StatusParked { t.Fatalf("outcome status = %q, want %q", tc.Outcome.Status, StatusParked) } if !strings.Contains(tc.Outcome.Detail, reason) { t.Fatalf("outcome detail = %q, want it to carry %q", tc.Outcome.Detail, reason) } }