Skip to content

chore: overhaul the test suite - #108

Merged
rustatian merged 1 commit into
masterfrom
chore/overhaul-test-suite
Aug 17, 2026
Merged

chore: overhaul the test suite#108
rustatian merged 1 commit into
masterfrom
chore/overhaul-test-suite

Conversation

@rustatian

Copy link
Copy Markdown
Member

Wave 2 overhaul. The CI side was already handled in #107, so this is tests only.

TestLoggerCustomFormat asserted 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.go for the configs where the logs section is absent, empty or raw; file_test.go for the file output — the pool's own record, the http access record, and one record per level; format_test.go for 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 writes test.log and now custom-format.log into the tests directory, and neither was ignored.

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.
Copilot AI lite review requested due to automatic review settings August 17, 2026 18:05
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.35%. Comparing base (2e0a09c) to head (4dff429).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.go with focused test files (boot_test.go, file_test.go, format_test.go).
  • Introduces tests/helpers/rr.go to 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.

Comment thread tests/helpers/rr.go
Comment thread tests/format_test.go
@rustatian rustatian self-assigned this Aug 17, 2026
@rustatian
rustatian merged commit e2d9e34 into master Aug 17, 2026
9 of 12 checks passed
@rustatian
rustatian deleted the chore/overhaul-test-suite branch August 17, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants