test: anchor the release fixtures at both ends of the walk

`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) <noreply@anthropic.com>
This commit is contained in:
naudachu
2026-08-12 11:45:51 +05:00
parent 4058cf5a4e
commit a685f23bc0
+12 -5
View File
@@ -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