package thin import ( "context" "testing" "amadan.net/oficina/equipo/internal/wire" ) // TestPreviewRefusesOldCarlos: a preview whose host's carlos is older than // wire.MinCarlos, or whose version cannot be read, refuses carlos_outdated // before anything is built or sent (production ran a stale carlos on its // PATH, 2026-11-26, and every preview failed obscurely at the deploy). func TestPreviewRefusesOldCarlos(t *testing.T) { for _, v := range []string{"v0.32.2", "", "v0.42.9"} { old := readCarlosVersion readCarlosVersion = func(context.Context, string) string { return v } carlosCLIs.Clear() e, fc, confirms, r := previewRig(t, mockups, nil) built := false rep := e.Exec(context.Background(), r, func(p wire.StepReport) { built = built || p.Preview != nil }) readCarlosVersion = old carlosCLIs.Clear() if rep.State != wire.StepFailed || rep.Reason != wire.ReasonCarlosOutdated || !rep.Termination || built || len(fc.calls) != 0 || len(*confirms) != 0 { t.Fatalf("%q: %+v built %t calls %d", v, rep, built, len(fc.calls)) } } // At the minimum it runs. e, _, _, r := previewRig(t, mockups, nil) if rep := e.Exec(context.Background(), r, func(wire.StepReport) {}); rep.Reason == wire.ReasonCarlosOutdated { t.Fatalf("a current carlos refused: %+v", rep) } }