Make TestDoneRedirectChain assertion deterministic

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 <noreply@anthropic.com>
This commit is contained in:
rictus
2026-01-03 10:33:27 -08:00
committed by Mike Lady
parent 717a82753c
commit 12236f24e3

View File

@@ -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)
}
}