[test-improver] Improve tests for logger package#5577
Merged
lpcox merged 2 commits intoMay 13, 2026
Conversation
Add tests for the eight backward-compatibility wrappers that had 0% coverage: - LogInfoMd, LogWarnMd, LogErrorMd, LogDebugMd (markdown_logger.go) - LogInfoWithServer, LogWarnWithServer, LogErrorWithServer, LogDebugWithServer (server_file_logger.go) Each wrapper delegates to its canonical counterpart; the new tests initialise a real logger in a temp dir, call each wrapper, flush/close, and assert the expected message appears in the resulting log file. Coverage for internal/logger improves from 96.1% → 97.7%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves test coverage in internal/logger by adding unit tests that exercise the legacy/backward-compatibility wrapper functions, ensuring they continue to delegate correctly to the canonical Log*ToMarkdown / Log*ToServer APIs.
Changes:
- Add a new test covering
LogInfoMd/LogWarnMd/LogErrorMd/LogDebugMdwrappers and verifying output is written to the markdown log file. - Add a new test covering
LogInfoWithServer/LogWarnWithServer/LogErrorWithServer/LogDebugWithServerwrappers and verifying output is written to the per-server log file.
Show a summary per file
| File | Description |
|---|---|
| internal/logger/markdown_logger_test.go | Adds a test that calls legacy Log*Md wrappers and asserts the expected messages are present in the markdown log file. |
| internal/logger/server_file_logger_test.go | Adds a test that calls legacy Log*WithServer wrappers and asserts the expected messages are present in the per-server log file. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
Comment on lines
+388
to
+398
| err := InitMarkdownLogger(logDir, "gateway.md") | ||
| require.NoError(t, err) | ||
| defer CloseMarkdownLogger() | ||
|
|
||
| LogInfoMd("test", "md compat info %s", "msg") | ||
| LogWarnMd("test", "md compat warn %s", "msg") | ||
| LogErrorMd("test", "md compat error %s", "msg") | ||
| LogDebugMd("test", "md compat debug %s", "msg") | ||
|
|
||
| err = CloseMarkdownLogger() | ||
| require.NoError(t, err) |
Comment on lines
+475
to
+487
| err := InitServerFileLogger(logDir) | ||
| require.NoError(t, err) | ||
| defer CloseServerFileLogger() | ||
|
|
||
| serverID := "compat-server" | ||
|
|
||
| LogInfoWithServer(serverID, "test", "compat info %s", "msg") | ||
| LogWarnWithServer(serverID, "test", "compat warn %s", "msg") | ||
| LogErrorWithServer(serverID, "test", "compat error %s", "msg") | ||
| LogDebugWithServer(serverID, "test", "compat debug %s", "msg") | ||
|
|
||
| err = CloseServerFileLogger() | ||
| require.NoError(t, err) |
Collaborator
|
@copilot address the review feedback |
Contributor
This was referenced May 13, 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.
File Analyzed
internal/logger/markdown_logger_test.go,internal/logger/server_file_logger_test.gointernal/loggerImprovements Made
Increased Coverage
Eight backward-compatibility wrapper functions had 0% coverage. These are one-liner delegates that forward calls to the canonical
LogXxxToMarkdown/LogXxxToServerfunctions. Adding tests for them verifies the delegation chain works correctly and ensures future refactors don't accidentally break the public API.Functions now covered:
LogInfoMd→LogInfoToMarkdownLogWarnMd→LogWarnToMarkdownLogErrorMd→LogErrorToMarkdownLogDebugMd→LogDebugToMarkdownLogInfoWithServer→LogInfoToServerLogWarnWithServer→LogWarnToServerLogErrorWithServer→LogErrorToServerLogDebugWithServer→LogDebugToServerCoverage improvement:
Test Design
Each new test:
t.TempDir()directory (no side-effects on global state across test runs)Tests follow the existing patterns in the file (bound asserters,
require.NoErrorfor fatal errors,assert.Containsfor content checks).Test Execution
Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
invalidhostthatdoesnotexist12345.comSee Network Configuration for more information.