Skip to content

[test] web server handler httptest coverage (web 0% -> 50%) (STAR-53)#19

Merged
vt128 merged 1 commit into
masterfrom
test/web-handler-httptest
Jun 22, 2026
Merged

[test] web server handler httptest coverage (web 0% -> 50%) (STAR-53)#19
vt128 merged 1 commit into
masterfrom
test/web-handler-httptest

Conversation

@vt128

@vt128 vt128 commented Jun 22, 2026

Copy link
Copy Markdown
Member

What

Cover the web-server request mode, which had 0% coverage and had never been exercised end-to-end — the top P0 gap from the v0.1.0 cost-price audit.

  • Refactor (behaviour-preserving): extract the per-request handler out of Start into a named handler(builder) http.HandlerFunc, so it can be driven with httptest without binding a port.
  • Tests (web/webserver_test.go):
    • the script's response (status + body) is written back to the client;
    • a runtime error (fail()) becomes a 500 carrying the error text;
    • request fields (method, body) reach the script via the injected request global.

Start() keeps only the mux + ListenAndServe wiring; the untestable port bind + log.Fatalw remain uncovered.

Result

  • web/ coverage 0% → 50% (the handler logic — the actual risk — is now covered).
  • Full -race green; Docker golang:1.25 (go floor) green; gofmt/vet clean.

Tracks STAR-53 P0 ① (under the v0.2 收口). Next: ② end-to-end golden suite, ③ domain-module real integration.

The web-server request mode had zero coverage and had never been exercised
end-to-end (the v0.1.0 cost-price audit's top P0 gap). Extract the per-request
handler out of Start into a named handler() (behaviour-preserving) so it can be
driven with httptest without binding a port, and add the suite:

- the script's response (status + body) is written back to the client
- a runtime error (fail()) becomes a 500 carrying the error text
- request fields (method, body) reach the script via the injected `request`

Start() keeps only the mux + ListenAndServe wiring (the untestable port bind +
log.Fatalw remain uncovered). web/ coverage 0% -> 50%.

Full -race green; Docker golang:1.25 floor green; gofmt/vet clean.
@vt128 vt128 merged commit e10fbd7 into master Jun 22, 2026
6 checks passed
@vt128 vt128 deleted the test/web-handler-httptest branch June 22, 2026 06:00
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.

1 participant