Restore global logger state in tests - #211
Merged
Merged
Conversation
3 tasks
jeffwidman
force-pushed
the
restore-test-logger-state
branch
from
August 18, 2026 22:29
5af0a61 to
b410d62
Compare
jeffwidman
marked this pull request as ready for review
August 18, 2026 22:29
There was a problem hiding this comment.
Pull request overview
Adds shared test helpers to prevent process-wide logger state from leaking between serial tests.
Changes:
- Snapshot and restore standard-log and Logrus configuration.
- Migrate all logger-capturing tests to shared helpers.
- Verify restoration of every captured logger field.
Show a summary per file
| File | Description |
|---|---|
proxy_test.go |
Uses combined logger capture helper. |
logging_test.go |
Preserves logger state around logging tests. |
internal/testhelpers/logging.go |
Adds logger preservation and capture helpers. |
internal/testhelpers/logging_test.go |
Tests complete state restoration. |
internal/oidc/oidc_registry_test.go |
Restores the actual previous log writer. |
internal/logging/logging_test.go |
Uses standard-log capture helper. |
internal/handlers/oidc_handling_test.go |
Prevents OIDC test log leakage. |
internal/handlers/nuget_feed_test.go |
Prevents NuGet test log leakage. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 8/8 changed files
- Comments generated: 0
- Review effort level: Balanced
JamieMagee
approved these changes
Aug 18, 2026
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
Tests in several packages redirect the process-wide standard logger to capture output. Most did not restore the previous writer, so later tests could inherit a buffer owned by an earlier test. One OIDC registry test restored
os.Stderrrather than the actual previous writer.TestSetupLoggingalso exercised production code that changes both standard-log and Logrus global configuration without restoring either logger.This change adds shared test helpers that snapshot and restore:
All direct output captures now use those helpers, and
TestSetupLoggingpreserves state before invoking production setup. A focused helper test mutates every captured field in a subtest and verifies that cleanup restores the exact prior state.The branch was rebased onto current
main. During the audit of changes merged since the PR was opened, one additional NuGet test logger capture was found and migrated to the helper. No other uncovered global logger mutations remain in tests.This does not make process-wide logger mutation safe for parallel tests. These tests should continue to run serially; the change prevents state from leaking after each test or subtest completes.
Validation
All packages pass.