carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3// The CLI-side gates for `carlos releases retention` (issue #136): these
4// fail before any network call, so they run against the real binary rather
5// than a fake console.
6
7import (
8 "os/exec"
9 "strings"
10 "testing"
11)
12
13// runRetentionCLI shells the built binary with the given args from a
14// scratch dir with the masked test env (the 40-accounts rule). Deviation
15// from the brief: there is no `carlosBin(t)` helper in this package: the
16// existing per-test build helper is `buildCarlos(t)` (auth_e2e_test.go),
17// which restart_test.go's own CLI-gate test already uses — followed
18// verbatim here rather than inventing a second name for the same thing.
19func runRetentionCLI(t *testing.T, args ...string) (string, error) {
20 t.Helper()
21 bin := buildCarlos(t)
22 cmd := exec.Command(bin, args...)
23 cmd.Env = carlosTestEnv(t)
24 cmd.Dir = t.TempDir()
25 out, err := cmd.CombinedOutput()
26 return string(out), err
27}
28
29func TestReleasesRetentionRefusesBelowFloorClientSide(t *testing.T) {
30 out, err := runRetentionCLI(t, "releases", "retention", "-app", "kass", "-keep", "5")
31 if err == nil {
32 t.Fatalf("keep 5 exited 0: %s", out)
33 }
34 if !strings.Contains(out, "20") {
35 t.Fatalf("floor refusal must name the floor, got: %s", out)
36 }
37}
38
39func TestReleasesRetentionRefusesOffPlusKeep(t *testing.T) {
40 out, err := runRetentionCLI(t, "releases", "retention", "-app", "kass", "-keep", "50", "-off")
41 if err == nil {
42 t.Fatalf("--off with --keep exited 0: %s", out)
43 }
44 if !strings.Contains(out, "-off") {
45 t.Fatalf("refusal should name the conflict, got: %s", out)
46 }
47}
48
49func TestReleasesRetentionNeedsApp(t *testing.T) {
50 // -app resolves since the project-defaults spec (2026-08-13): with
51 // nothing configured the refusal names the missing SESSION, the real
52 // blocker — not a usage line for a flag that is no longer required.
53 out, err := runRetentionCLI(t, "releases", "retention")
54 if err == nil {
55 t.Fatalf("no --app exited 0: %s", out)
56 }
57 if !strings.Contains(out, "no deployment target configured") {
58 t.Fatalf("want the no-target refusal, got: %s", out)
59 }
60}
61