testdirs: align test name and assertion with the documented invariant · Entire
testdirs: align test name and assertion with the documented invariant
7af38da→main·
toothbrush·1mo ago·1 file·+6 added/-6 removed
Follow-up review feedback on #1411: rename the test (it no longer asserts "never under home") and compare against the real app dirs (~/.config/entire, ~/.cache/entire) rather than their parents — TMPDIR is commonly set under $HOME/.cache, which is legitimate.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Sessions
8fbc7140425dView transcript
[?
Fix Test Fixture Leaking Into User ConfigClaude Code·Fable 5.[1m]·2 steps](/content/gh/entireio/cli/session/688d98e0-f0a6-4240-acff-5f1100197cba#timeline-8fbc7140425d/index.html)
Changes
1
internal/testdirs
Mtestdirs_test.go+6/-6
6 unmodified lines
7
8
9
10
10
11
12
13
13 unmodified lines
27
28
29
30
31
32
30
31
32
33
34
35
36
35
36
37
38
39
6 unmodified lines
"testing"
)
func TestDir_StablePerSurfaceAndNeverUnderHome(t *testing.T) {
func TestDir_StablePerSurfaceAndNeverRealConfigOrCache(t *testing.T) {
t.Parallel()
cfg1, ok := Dir("config")
13 unmodified lines
t.Fatalf("surfaces must not share a directory: %q", cache)
}
// The invariant is "never the real config/cache locations" — not "never
// under $HOME": os.MkdirTemp respects TMPDIR, which may itself live under
// the home directory on some setups.
// The invariant is "never the real app locations" — not "never under
// $HOME" or even "never under ~/.cache": os.MkdirTemp respects TMPDIR,
// which is commonly set to places like $HOME/.cache/tmp.
if home, err := os.UserHomeDir(); err == nil {
for _, realDir := range []string{
filepath.Join(home, ".config"),
filepath.Join(home, ".cache"),
filepath.Join(home, ".config", "entire"),
filepath.Join(home, ".cache", "entire"),
} {
for _, d := range []string{cfg1, cache} {
if d == realDir || strings.HasPrefix(d, realDir+string(os.PathSeparator)) {
Minternal/testdirs/testdirs_test.go+6/-6