tests: push coverage to 98.2% with targeted unit + characterization tests#1
Merged
Conversation
…ests Lift coverage from baseline 83.7% to 98.2% via a single new test file: - Service adapter (service.go): from 0% to 100%; Name/Order/Start/Stop plus a cancelled-ctx regression pin so silent context handling fails loudly if anyone ever wires real Start logic. - extractCallerNode (server.go): pin both the iter-2 audit characterization (plain "N:NNNN.HHHH.LLLL" silently returns 0 because net.SplitHostPort treats the first colon as host:port) AND the rarely- hit positive path (IPv6-bracketed pilot addr). - handleRegister caller-mismatch: A and S records reject spoofed addrs. - handleConn: bad-request flow + bare-close client doesn't crash the accept loop. - ListenAndServe: bind failure error wrapping + Accept-after-Close. - Client (client.go): dial / write / read / ERR-reply / malformed-reply paths for every Lookup* and Register* method (each was at ~67% before). - RecordStore persistence (records.go): bad JSON load, snapshot with unparseable addrs in both A and S sections (skip-and-continue branch), no-file load, MkdirAll failure when storePath parent is a regular file, RegisterS rename-existing-entry path. - reapExpired: A, N, and S record expiry paths in one shot. - Wire (wire.go): QUERY A / QUERY N / REGISTER A,N,S short-form validation, ParseResponse skipping malformed / whitespace S lines, FormatRequest unknown-record-type defaulting to empty. Also documents (not enforces) iter-2's "no max name length" finding via a characterization test on a 64KiB name — when limits land, the test must be replaced with an "ERR name too long" assertion. Remaining 1.8% is honest ceiling: json.MarshalIndent error on our types is impossible; fsutil.AtomicWrite mid-write failure needs filesystem fault injection; reapLoop's 60s ticker branch is racy; defensive storePath=="" / len(lines)==0 guards are unreachable through the public API. go test -race -count=1 -timeout 180s ./... passes.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
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.
Summary
Lifts coverage from baseline 83.7% → 98.2% via a single new test file (
zz_coverage_test.go, no production code changes).What got covered
service.go(plugin adapter)client.go(every method)extractCallerNodehandleConnListenAndServehandleRegisterreapExpiredrecords.go save/loadIter-2 audit follow-throughs
extractCallerNodesilent-zero on plain pilot addr: pinned as a regression test.net.SplitHostPorttreats the first colon inN:NNNN.HHHH.LLLLas host:port, leaving an unparseable host, so the function silently returns 0. Verification confirmed the IPC layer authenticates upstream — the test documents the current behaviour so that, if anyone ever callsextractCallerNodefrom a path without upstream auth, this test goes red.Honest-ceiling: the remaining 1.8%
json.MarshalIndentcannot fail for our snapshot types (noMarshalJSONhooks, no channels).fsutil.AtomicWritemid-write failure needs filesystem fault injection.reapLoop's 60-second ticker tick branch is too racy to assert in a unit test (the done branch IS covered viaClose()).if rs.storePath == ""guards insave/loadare unreachable through the public API onceSetStorePathhas been called.len(lines) == 0afterstrings.Splitis unreachable —Splitalways returns at least one element.Test plan
go test -race -count=1 -timeout 180s ./...passes locallygo vet ./...cleango tool cover -func