fix: isolate auth tests to prevent credential deletion#75
Merged
steve-calvert-glean merged 2 commits intomainfrom Apr 6, 2026
Merged
fix: isolate auth tests to prevent credential deletion#75steve-calvert-glean merged 2 commits intomainfrom
steve-calvert-glean merged 2 commits intomainfrom
Conversation
TestAuthLogoutCmd_NoPanic and TestAuthStatusCmd_NoConfig were running against real system state — no mock, no temp dir. The logout test called ClearConfig() which deleted ~/.glean/config.json and removed keyring entries, wiping real credentials on every test run. Isolate both tests with HOME set to a temp dir, ConfigPath swapped, and keyring mocked — same pattern as auth_persistence_test.go. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
rwjblue-glean
approved these changes
Apr 6, 2026
Hoists isolateAuthState into internal/auth/authtest.IsolateAuthState so both cmd/ and internal/auth/ tests use a single implementation. Adds CLAUDE.md guidance requiring all auth-touching tests to use it. Also fixes stale repo path references in CLAUDE.md after the repo moved from ~/workspace/personal/ to ~/workspace/glean/. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestAuthLogoutCmd_NoPanicandTestAuthStatusCmd_NoConfigwere running against real system state with no mocks or temp dirsClearConfig()which deleted~/.glean/config.jsonand removed keyring entries, wiping real credentials on every test runConfigPath, and mocked keyring — matching the pattern fromauth_persistence_test.goTest plan
go test ./cmd/ -run "TestAuthLogoutCmd_NoPanic|TestAuthStatusCmd_NoConfig" -vpassesgo test ./... -racepassesgolangci-lint runclean🤖 Generated with Claude Code