From 12236f24e3cabd46dc7f660be234851cc5db64a3 Mon Sep 17 00:00:00 2001 From: rictus Date: Sat, 3 Jan 2026 10:33:27 -0800 Subject: [PATCH] Make TestDoneRedirectChain assertion deterministic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review comment: the test now explicitly asserts that ResolveBeadsDir follows exactly one level of redirect, returning intermediate (not canonical). The implementation intentionally does NOT follow chains transitively - it stops at the first resolved path and prints a warning about the detected chain. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/done_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/internal/cmd/done_test.go b/internal/cmd/done_test.go index 930b42ad..45121b1c 100644 --- a/internal/cmd/done_test.go +++ b/internal/cmd/done_test.go @@ -159,7 +159,9 @@ func TestDoneBeadsInitBothCodePaths(t *testing.T) { } // TestDoneRedirectChain verifies behavior with chained redirects. -// ResolveBeadsDir follows one level of redirect by design. +// ResolveBeadsDir follows exactly one level of redirect by design - it does NOT +// follow chains transitively. This is intentional: chains typically indicate +// misconfiguration (e.g., a redirect file that shouldn't exist). func TestDoneRedirectChain(t *testing.T) { tmpDir := t.TempDir() @@ -187,17 +189,14 @@ func TestDoneRedirectChain(t *testing.T) { t.Fatalf("write worktree redirect: %v", err) } - // ResolveBeadsDir follows to canonical (through the chain) - // Note: The implementation follows redirects transitively + // ResolveBeadsDir follows exactly one level - stops at intermediate + // (A warning is printed about the chain, but intermediate is returned) resolved := beads.ResolveBeadsDir(worktreeDir) - // The resolved directory should be either: - // - canonical (if following chain) - // - intermediate (if only one level) - // Accept either as valid - the key point is redirect IS followed - if resolved != canonicalBeadsDir && resolved != intermediateBeadsDir { - t.Errorf("ResolveBeadsDir didn't follow redirect chain: got %s, want %s or %s", - resolved, canonicalBeadsDir, intermediateBeadsDir) + // Should resolve to intermediate (one level), NOT canonical (two levels) + if resolved != intermediateBeadsDir { + t.Errorf("ResolveBeadsDir should follow one level only: got %s, want %s", + resolved, intermediateBeadsDir) } }