A run that parked left tc.Outcome empty, so the taskrun response carried an empty status and the daemon logged 'taskrun run recorded no outcome' for a run that had recorded one, then retried the park it could not apply. Record the outcome once the parked transition lands, so a budget stop and every other park surface with the reason the run parked.
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
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)
|
|
}
|
|
}
|