From a685f23bc07629407f85eb7ef83b191f6bcd2334 Mon Sep 17 00:00:00 2001 From: naudachu Date: Wed, 12 Aug 2026 11:45:51 +0500 Subject: [PATCH] test: anchor the release fixtures at both ends of the walk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `harmless` pointed CLAUDE_PROJECT_DIR at an empty temp directory and left the working directory where `go test` put it. The walk has two anchors, so the second one carried the fixture back up into this repository, which has a `.kettle/` marker of its own — gitignored, and therefore present in every developer's checkout and in no clone. The run resolved `login: noodles` from it and then failed against the fixture's empty config home. TestRunPublishesFromTheEnvironmentWithNoProjectInSight is precisely the test that is about resolving nothing at all, and it passed only while nobody had run `kettle init` here. Co-Authored-By: Claude Opus 5 (1M context) --- cli/cmd/release/release_test.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cli/cmd/release/release_test.go b/cli/cmd/release/release_test.go index 82027a3..145f683 100644 --- a/cli/cmd/release/release_test.go +++ b/cli/cmd/release/release_test.go @@ -4,11 +4,12 @@ package main // that needs a server somewhere is a test nobody runs, and this is the one tool // in the tree whose mistakes are visible to everybody who downloads a binary. // -// Every fixture points CLAUDE_PROJECT_DIR at an empty temp directory — no -// `.kettle/` marker anywhere on the way up, which is the state a fresh clone is -// in and the whole reason this tool resolves its configuration the way it does -// — and KETTLE_CONFIG_HOME at another, so a run can neither read nor overwrite -// the developer's own tokens. +// Every fixture puts BOTH anchors of the walk — CLAUDE_PROJECT_DIR and the +// working directory — in an empty temp directory, so there is no `.kettle/` +// marker anywhere on the way up. That is the state a fresh clone is in and the +// whole reason this tool resolves its configuration the way it does. It also +// points KETTLE_CONFIG_HOME at another temp directory, so a run can neither +// read nor overwrite the developer's own tokens. // // THE FAKE ANSWERS /api/v1/version, because building an SDK client is itself a // request: the SDK asks the instance what it is before it hands a client back, @@ -41,6 +42,12 @@ func harmless(t *testing.T) { t.Helper() dir := t.TempDir() t.Setenv("CLAUDE_PROJECT_DIR", dir) + // The walk has two anchors and CLAUDE_PROJECT_DIR is only the first: with + // the working directory left where `go test` put it, a run inside a tree + // that has a marker resolves that tree's config. This repository has one — + // it is gitignored, so it is present in a developer's checkout and in no + // clone — and a fixture about resolving nothing must not find it. + t.Chdir(dir) t.Setenv(config.EnvHome, filepath.Join(dir, "config")) // An exported KETTLE_URL in the developer's shell would otherwise decide // what a test resolved to, and one of these tests is about resolving