Skip to content

chore: overhaul the test suite - #172

Merged
rustatian merged 2 commits into
masterfrom
chore/overhaul-test-suite
Aug 17, 2026
Merged

chore: overhaul the test suite#172
rustatian merged 2 commits into
masterfrom
chore/overhaul-test-suite

Conversation

@rustatian

Copy link
Copy Markdown
Member

Wave 2 overhaul, same shape as gzip #244. No dependency bump needed — headers is already on http beta.9.

Simplification. 437 lines across one file, five tests, each opening with the same ~60 lines of endure.NewRegisterAllInitServesignal.NotifystopCh → drain-goroutine. That is now a Start(t, cfg, plugins, opts...) helper, and the five fixed sleeps are gone in favour of a readiness probe.

Split by theme. headers_test.go covers boot plus request/response header injection; cors_test.go covers preflight and actual-request behaviour for both the wildcard and the regex config.

New coverage. The old suite never checked that the origin regex rejects anything — it only asserted the matching case, so a regex that accepted everything would have passed. Added that case. Root unit tests now cover Init: both disabled paths, regex compilation and its error branch, the options_success_status default and override, and header injection in both directions.

Local results: root unit 91.4%, e2e 81.0%, merged 98.3% against a current badge of 70%. Stable across 5 consecutive shuffled runs. Guard sees 88 blocks against a floor of 10.

CI gains the unit tier. The artifact now uploads the whole coverage-ci directory rather than a single file, so both tiers reach codecov.

Replace the per-test endure boilerplate with a Start helper that boots
the container, waits on a readiness probe and tears down through
t.Cleanup.

Split the e2e into request/response header behaviour and CORS, and add
a case proving the origin regex rejects an origin it does not match.
Add root unit tests for Init: the two disabled paths, regex compilation
and its error, the options_success_status default and override, and the
header injection in both directions.
Copilot AI lite review requested due to automatic review settings August 17, 2026 17:17

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 overhauls the headers plugin test suite by extracting a shared RoadRunner boot helper, splitting e2e tests by theme (headers vs CORS), and adding new unit coverage for Plugin.Init and middleware behavior. It also updates CI to run root-module unit tests with coverage and upload both unit + e2e coverage outputs.

Changes:

  • Introduced tests/helpers.Start to centralize container boot + readiness probing and remove fixed sleeps.
  • Replaced the monolithic tests/headers_plugin_test.go with focused e2e tests (tests/headers_test.go, tests/cors_test.go) and added root-module unit tests (init_test.go) for init/error branches and middleware behavior.
  • Updated GitHub Actions workflow to run root-module unit tests with coverage and upload the full coverage directory as an artifact.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/helpers/rr.go Adds a shared container boot helper with pluggable readiness probes and cleanup.
tests/headers_test.go New focused e2e tests for boot + request/response header injection.
tests/cors_test.go New focused e2e tests for wildcard and regex CORS behavior, including a rejecting case.
tests/headers_plugin_test.go Removes the previous monolithic e2e test file in favor of themed tests + helper.
init_test.go Adds unit tests covering Init disabled paths, regex compilation/error, CORS options default/override, and header injection.
.github/workflows/linux.yml Adds root-module unit coverage tier and uploads the entire coverage-ci directory artifact.

💡 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 .github/workflows/linux.yml
@rustatian rustatian self-assigned this Aug 17, 2026
@rustatian
rustatian merged commit 5d2b0b3 into master Aug 17, 2026
7 checks passed
@rustatian
rustatian deleted the chore/overhaul-test-suite branch August 17, 2026 17:41
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