From 988c3e810baf4486aa18778d8779c27e9f18dd23 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 29 Oct 2026 07:12:42 -0400 Subject: [PATCH] fix(catalog): make the -check baseline test hermetic --- tools/catalog/behaviour_test.go | 18 +++++++++++++++++- tools/catalog/release_consistency_test.go | 10 ++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/catalog/behaviour_test.go b/tools/catalog/behaviour_test.go index d91194a4a..d693c3c65 100644 --- a/tools/catalog/behaviour_test.go +++ b/tools/catalog/behaviour_test.go @@ -20,7 +20,23 @@ func TestDeterministicAndCheck(t *testing.T) { t.Fatalf("%s registry differs between two runs on identical inputs", f) } } - args := tierArgs("free", filepath.Join(td, "free"), filepath.Join(d1, "free"), filepath.Join(d1, "p1l", "registry.json"), "-check") + entries, err := os.ReadDir(filepath.Join(td, "free")) + if err != nil { + t.Fatal(err) + } + var slugs []string + for _, entry := range entries { + if entry.IsDir() { + slugs = append(slugs, entry.Name()) + } + } + // Give -check its own committed baseline, independent of checkout refs. + dir := tree(t, "free", slugs...) + catalogGit(t, dir, "init", "-q") + catalogGit(t, dir, "add", "releases.json") + catalogGit(t, dir, "commit", "-qm", "Release fixture") + catalogGit(t, dir, "update-ref", "refs/heads/main", "HEAD") + args := tierArgs("free", dir, filepath.Join(d1, "free"), filepath.Join(d1, "p1l", "registry.json"), "-check") if code, se := gen(t, args...); code != 0 { t.Fatalf("-check on current output: exit %d\n%s", code, se) } diff --git a/tools/catalog/release_consistency_test.go b/tools/catalog/release_consistency_test.go index 2d968849e..d114e2cc5 100644 --- a/tools/catalog/release_consistency_test.go +++ b/tools/catalog/release_consistency_test.go @@ -83,3 +83,13 @@ func TestCheckAllowsNewUnreleasedManifest(t *testing.T) { t.Fatalf("new unreleased plugin: exit %d\n%s", code, se) } } + +func TestCheckRefusesMissingMainBaseline(t *testing.T) { + dir := tree(t, "free", "ai-cli") + catalogGit(t, dir, "init", "-q", "-b", "fixture") + catalogGit(t, dir, "add", "releases.json") + catalogGit(t, dir, "commit", "-qm", "Release fixture") + args := tierArgs("free", dir, t.TempDir(), "") + mustGen(t, args...) + expectProblem(t, "-check needs origin/main or main", append(args, "-check")...) +}