test(tokenstore): pin the warning's stderr default (round-2 review) · Entire

test(tokenstore): pin the warning's stderr default (round-2 review)

2259be8→main·

peyton-alt·3d ago·2 files·+16 added/-3 removed

Every warning test swaps loosePermsWarnW to capture output, so changing the production default to io.Discard silently deleted the feature while the suite stayed green (the one mutation that survived round-2 review). Also note the once-per-process composition on the dedup field doc.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

Sessions

01KXH0YEGFVP1201XK5F44566MView transcript

Changes

2

29 unmodified lines
30
31
32
33
34
35
33
34
35
36
37
38
39
40

29 unmodified lines

path string
    mu   sync.Mutex
    // warnedLoosePerms dedupes the loose-permissions warning to once per
    // store instance. Like the rest of the store's state it relies on mu,
    // which every production caller of load (Get/Set/Delete) holds; tests
    // that call load directly are single-goroutine.
    // store instance — effectively once per CLI invocation, since
    // currentBackend caches a single fileStore for the process. Like the
    // rest of the store's state it relies on mu, which every production
    // caller of load (Get/Set/Delete) holds; tests that call load directly
    // are single-goroutine.
    warnedLoosePerms bool
}

Minternal/entireclient/tokenstore/file.go+5/-3

397 unmodified lines
398
399
400
401
402
403
404
405
406
407
408
409
410
411

397 unmodified lines

t.Fatalf("FileBackendPath() = %q, want %q", got, want)
}

// The warning's production destination is stderr. Pinned because every other
// warning test swaps the writer via captureLoosePermsWarnings — without this,
// changing the default to io.Discard would silently delete the feature in
// production while the whole suite stays green (verified by mutation).
// Not parallel: reads the package-global writer that other tests swap.
func TestLoosePermsWarnWriter_DefaultsToStderr(t *testing.T) {
    if loosePermsWarnW != os.Stderr {
        t.Fatalf("loosePermsWarnW default = %T, want os.Stderr", loosePermsWarnW)
    }
}

Minternal/entireclient/tokenstore/file_test.go+11