[test] web server handler httptest coverage (web 0% -> 50%) (STAR-53)#19
Merged
Conversation
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.
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.
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.
Startinto a namedhandler(builder) http.HandlerFunc, so it can be driven withhttptestwithout binding a port.web/webserver_test.go):response(status + body) is written back to the client;fail()) becomes a 500 carrying the error text;method,body) reach the script via the injectedrequestglobal.Start()keeps only themux+ListenAndServewiring; the untestable port bind +log.Fatalwremain uncovered.Result
web/coverage 0% → 50% (the handler logic — the actual risk — is now covered).-racegreen; Dockergolang:1.25(go floor) green;gofmt/vetclean.Tracks STAR-53 P0 ① (under the v0.2 收口). Next: ② end-to-end golden suite, ③ domain-module real integration.