chore: overhaul the test suite - #108
Merged
Merged
Conversation
Replace the per-test endure boilerplate with a Start helper and poll for the log file to reach its expected contents instead of sleeping 2s and hoping the writer flushed. TestLoggerCustomFormat booted the custom-format config and asserted nothing, so any format string would have passed. Give that config a file output and assert the rendered line follows the configured layout, that it is not json, and that debug records stay out at info level. Split the rest by theme: the boot-only configs, and the file output cases covering the pool record, the http access record and one record per level.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #108 +/- ##
=======================================
Coverage 79.35% 79.35%
=======================================
Files 5 5
Lines 281 281
=======================================
Hits 223 223
Misses 47 47
Partials 11 11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors and strengthens the tests/ module’s logger integration tests by replacing a monolithic test file with themed suites, improving determinism around asynchronous file logging, and adding coverage for custom formatting behavior.
Changes:
- Replaces
tests/logger_test.gowith focused test files (boot_test.go,file_test.go,format_test.go). - Introduces
tests/helpers/rr.goto centralize container boot, readiness probing, and file-content polling. - Updates the custom-format test config to write to a dedicated log file and gitignores
tests/*.log.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/logger_test.go | Removes the previous combined test suite in favor of themed test files. |
| tests/helpers/rr.go | Adds shared helpers for starting/stopping the container, probing readiness, and polling log files. |
| tests/boot_test.go | Adds boot-only tests for configs with absent/minimal logs configuration. |
| tests/file_test.go | Adds file-output tests with polling to avoid racey sleeps. |
| tests/format_test.go | Adds custom-format tests intended to assert formatting and level filtering. |
| tests/configs/.rr-custom-format.yaml | Directs custom-format output into custom-format.log for assertions. |
| .gitignore | Ignores log files produced by the test suite. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Wave 2 overhaul. The CI side was already handled in #107, so this is tests only.
TestLoggerCustomFormatasserted nothing. It booted the custom-format config, waited, stopped, and checked no error came back — any format string would have passed, including the default json. That config now writes to a file and the test asserts the rendered line actually follows%time% [%level%] %message% %attrs%with the configured time layout, that it is not json, and that debug records stay out at info level.I mutation-checked that assertion before trusting it: pointing the regex at a layout the config does not produce makes the test fail as expected.
Sleep replaced with polling. Both file-reading tests slept 2s and then read the log, racing the writer. They now poll until the file reaches the expected contents, and report the last thing they read when they give up.
Split by theme.
boot_test.gofor the configs where the logs section is absent, empty or raw;file_test.gofor the file output — the pool's own record, the http access record, and one record per level;format_test.gofor the custom layout.Local results: root unit 44.5%, e2e 71.7%, merged 80.1% against a current badge of 79%. Eight tests, stable across 4 consecutive shuffled runs.
Also gitignored
tests/*.log. The suite writestest.logand nowcustom-format.loginto the tests directory, and neither was ignored.