test(taskstate): seed fixture task states along the transition table

The execution transition table refuses most of the pairs shipped fixtures
wrote to build a finished task -- running -> merged, queued -> parked,
queued -> waiting_human, queued -> merged -- so those fixtures fail the
moment the store enforces it.

internal/taskstate/taskstatetest seeds a status by walking the table's
legal edges (shortest route, computed from taskstate.CanTransition), so a
fixture cannot write an illegal pair and fails loudly when no route
exists. The fixtures in internal/daemon, internal/app/archied,
internal/webui and internal/infrastructure/postgres go through it, and
the table's own test names running -> merged as refused.
This commit is contained in:
sam committed 2026-09-26 04:01:08 +10:00
1 parent 9a3f02a17a
commit 1024feda21
10 files changed
+291 -65

No files matched your search

@@ -4,6 +4,7 @@ import (
"testing"
"github.com/samcharles93/archie-core/internal/taskstate"
"github.com/samcharles93/archie-core/internal/taskstate/taskstatetest"
)
// TestWorkflowStatsCountsCompletedRuns pins the per-workflow count the
@@ -21,12 +22,9 @@ func TestWorkflowStatsCountsCompletedRuns(t *testing.T) {
merged := insertChatTask(t, q)
finish := func(id int64, to string) {
t.Helper()
if err := store.Transition(t.Context(), id, taskstate.Queued, taskstate.Running, ""); err != nil {
t.Fatalf("queued -> running: %v", err)
}
if err := store.Transition(t.Context(), id, taskstate.Running, to, ""); err != nil {
t.Fatalf("running -> %s: %v", to, err)
}
// Seeded along the table's edges: a merged task is merged on an open
// pull request, and the fixture used to write running -> merged.
taskstatetest.Seed(t.Context(), t, store, id, taskstate.Queued, to, "")
}
finish(finished.ID, taskstate.Completed)
finish(merged.ID, taskstate.Merged)