tests: raise dataexchange coverage from 52% to 69%#1
Merged
Conversation
Adds focused tests for the lowest-covered functions in service.go: - evictInboxOverflow: 0% -> 92.3% (no-op below cap, default cap branch, readdir error, subdir-skip, oldest-first trim ordering) - handleConn: 51.5% -> 93.9% (TypeBinary, TypeJSON, TypeFile, TypeFile with empty filename, TypeTrace happy path + parse-error branch, saveErr -> ERR ACK, unknown type) - saveInboxMessage: 73.9% -> 82.6% (mkdir error path; trip the periodic eviction tick once seq crosses inboxEvictCheckEvery) - receivedDir / inboxDir: 33.3% -> 83.3% (HOME-fallback branch via t.Setenv) - Adds a Start -> Stop happy-path lifecycle test
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 ☂️ |
4 tasks
TeoSlayer
added a commit
that referenced
this pull request
May 28, 2026
Round 2 follows the round-1 PR (#1) and lifts the test surface from the 69% post-round-1 baseline (./...) to 80%, with the dataexchange package itself moving from 82.5% to 95.3% of statements. New files: - zz_client_test.go — fake daemon (unix socket + IPC framer) plus end-to-end coverage for every Client method (Dial, SendText, SendJSON, SendBinary, SendFile, SendTrace, Recv, Close — all 0% → 100%). Also covers server.go ListenAndServe (0% → 90%) by pushing cmdAccept + cmdRecv at the driver and asserting the handler fires. - zz_service_errors_test.go — error-path drilling for service.go: saveReceivedFile EACCES + Events.Publish branches, saveInboxMessage Events.Publish branch, WriteFrame header/payload write errors, handleConn ACK-write-failure exit, Stop() ctx-cancelled branch, handleConn IncludeBase64=true branch. Includes two regression tests for PILOT-183 (evictInboxOverflow miscounts when subdirs are mixed with regular files) that pin the current behaviour and document the comment to remove once the fix lands. Per-function notable jumps: - client.go: 0% → 100% across all eight functions - server.go: ListenAndServe 0% → 90% - service.go: handleConn 93.9% → 97.0%, Stop 88.9% → 100%, evictInboxOverflow 92.3% → 96.2%, saveReceivedFile 72.7% → 90.9%, saveInboxMessage 82.6% → 87.0% Test fixtures: - fakeDaemon serialises all writes to the unix socket via writeMu — without it, daemon replies (cmdBindOK/cmdDialOK) interleave with test thread pushes (cmdAccept/cmdRecv) and corrupt the wire, surfacing as flaky "daemon disconnected" errors under -race. - waitForCompleteFrame polls the daemon's captured cmdSend stream until a full data-exchange Frame can be decoded — needed because driver.Conn.Write splits WriteFrame's header + payload writes into separate cmdSend IPC messages. Run: `go test -race -count=1 -timeout 180s ./...` — passes (12s, 0 flake across 20-iter stress). Co-authored-by: Teodor Calin <teodor@vulturelabs.io>
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
Adds a single new test file (
zz_coverage_test.go) covering thelowest-covered branches in
service.go. Coverage goes from 52.3% to68.8% (target was 55%+). No production code touched.
Function-level deltas
evictInboxOverflowhandleConnsaveInboxMessageinboxDir/receivedDirStop(lifecycle)What's covered
(10000), readdir error on missing dir, subdirectory skip.
TypeBinary,TypeJSON,TypeFile(with and without filename),TypeTrace(happy +parse-error), unknown type. Plus the
saveErr -> ERR ACKbranch.trip the periodic
inboxEvictCheckEverytick.receivedDir/inboxDir— HOME-fallback branch viat.Setenv.Start -> Stophappy path with a fake listener.Test plan
go test -race -count=1 -timeout 120s ./...passes locallyzz_coverage_test.goadded