| 1 | package thin |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/wire" |
| 8 | ) |
| 9 | |
| 10 | // TestPreviewRefusesOldCarlos: a preview whose host's carlos is older than |
| 11 | // wire.MinCarlos, or whose version cannot be read, refuses carlos_outdated |
| 12 | // before anything is built or sent (production ran a stale carlos on its |
| 13 | // PATH, 2026-11-26, and every preview failed obscurely at the deploy). |
| 14 | func TestPreviewRefusesOldCarlos(t *testing.T) { |
| 15 | for _, v := range []string{"v0.32.2", "", "v0.42.9"} { |
| 16 | old := readCarlosVersion |
| 17 | readCarlosVersion = func(context.Context, string) string { return v } |
| 18 | carlosCLIs.Clear() |
| 19 | e, fc, confirms, r := previewRig(t, mockups, nil) |
| 20 | built := false |
| 21 | rep := e.Exec(context.Background(), r, func(p wire.StepReport) { built = built || p.Preview != nil }) |
| 22 | readCarlosVersion = old |
| 23 | carlosCLIs.Clear() |
| 24 | if rep.State != wire.StepFailed || rep.Reason != wire.ReasonCarlosOutdated || !rep.Termination || built || len(fc.calls) != 0 || len(*confirms) != 0 { |
| 25 | t.Fatalf("%q: %+v built %t calls %d", v, rep, built, len(fc.calls)) |
| 26 | } |
| 27 | } |
| 28 | // At the minimum it runs. |
| 29 | e, _, _, r := previewRig(t, mockups, nil) |
| 30 | if rep := e.Exec(context.Background(), r, func(wire.StepReport) {}); rep.Reason == wire.ReasonCarlosOutdated { |
| 31 | t.Fatalf("a current carlos refused: %+v", rep) |
| 32 | } |
| 33 | } |
| 34 | |