Commit 4e7cdf8
authored
[test-improver] Improve tests for logger package (#5577)
## File Analyzed
- **Test Files**: `internal/logger/markdown_logger_test.go`,
`internal/logger/server_file_logger_test.go`
- **Package**: `internal/logger`
## Improvements Made
### Increased Coverage
Eight backward-compatibility wrapper functions had **0% coverage**.
These are one-liner delegates that forward calls to the canonical
`LogXxxToMarkdown` / `LogXxxToServer` functions. 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` → `LogInfoToMarkdown`
- ✅ `LogWarnMd` → `LogWarnToMarkdown`
- ✅ `LogErrorMd` → `LogErrorToMarkdown`
- ✅ `LogDebugMd` → `LogDebugToMarkdown`
- ✅ `LogInfoWithServer` → `LogInfoToServer`
- ✅ `LogWarnWithServer` → `LogWarnToServer`
- ✅ `LogErrorWithServer` → `LogErrorToServer`
- ✅ `LogDebugWithServer` → `LogDebugToServer`
**Coverage improvement:**
- **Previous**: 96.1%
- **New**: 97.7%
- **Improvement**: +1.6%
### Test Design
Each new test:
1. Initialises a real logger in a `t.TempDir()` directory (no
side-effects on global state across test runs)
2. Calls all four level wrappers with a formatted message
3. Closes/flushes the logger so the file is written
4. Reads the log file and asserts each expected message is present
Tests follow the existing patterns in the file (bound asserters,
`require.NoError` for fatal errors, `assert.Contains` for content
checks).
## Test Execution
```
=== RUN TestLogMdBackwardCompatWrappers
--- PASS: TestLogMdBackwardCompatWrappers (0.00s)
=== RUN TestLogWithServerBackwardCompatWrappers
--- PASS: TestLogWithServerBackwardCompatWrappers (0.00s)
PASS
ok github.com/github/gh-aw-mcpg/internal/logger 0.296s coverage: 97.7% of statements
```
---
*Generated by Test Improver Workflow*
*Focuses on better patterns, increased coverage, and more stable tests*
> [!WARNING]
> <details>
> <summary>Firewall blocked 1 domain</summary>
>
> The following domain was blocked by the firewall during workflow
execution:
>
> - `invalidhostthatdoesnotexist12345.com`
>> To allow these domains, add them to the `network.allowed` list in
your workflow frontmatter:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "invalidhostthatdoesnotexist12345.com"
> ```
>
> See [Network
Configuration](https://github.github.com/gh-aw/reference/network/) for
more information.
>
> </details>
> Generated by [Test
Improver](https://github.com/github/gh-aw-mcpg/actions/runs/25769530984/agentic_workflow)
· ● 2.2M ·
[◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+test-improver%22&type=pullrequests)
<!-- gh-aw-agentic-workflow: Test Improver, engine: copilot, version:
1.0.40, model: claude-sonnet-4.6, id: 25769530984, workflow_id:
test-improver, run:
https://github.com/github/gh-aw-mcpg/actions/runs/25769530984 -->
<!-- gh-aw-workflow-id: test-improver -->2 files changed
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
0 commit comments