textmachine/platform/internal/runs/reconcile_basis_test.go

29 lines
1.2 KiB
Go

package runs
import (
"testing"
"textmachine/platform/internal/pgstore"
)
// Which settlements are short for a reason we know of (PD-441): the five endings an attempt can have,
// mapped onto the only question this side can answer — did the engine stop on its own terms.
//
// `awaiting_bank` is a clean ending: the engine exits at the signing boundary with its own exit code,
// and calling it a halt would mark the product's most ordinary paid pause as unaccounted money.
func TestOnlyAnEndingTheEngineChoseIsSettledAsComplete(t *testing.T) {
for _, c := range []struct {
status string
want pgstore.SettlementBasis
}{
{"ready", pgstore.BasisComplete}, // the translation finished
{"awaiting_bank", pgstore.BasisComplete}, // the engine exited at the signing boundary
{"paused", pgstore.BasisHalted}, // the ceiling was breached mid-wave — PD-441's own case
{"stopped", pgstore.BasisHalted}, // the user's stop, delivered as a signal
{"failed", pgstore.BasisHalted}, // the unit died, or its marker could not be read
} {
if got := settlementBasis(pgstore.LiveRun{Status: c.status}); got != c.want {
t.Errorf("an attempt that ended %q settles as %q, want %q", c.status, got, c.want)
}
}
}