Skip to content

Cover every reachable branch - #6

Merged
winebarrel merged 2 commits into
mainfrom
raise-coverage
Aug 9, 2026
Merged

Cover every reachable branch#6
winebarrel merged 2 commits into
mainfrom
raise-coverage

Conversation

@winebarrel

Copy link
Copy Markdown
Owner

Coverage goes from 93.1% to 99.0%, with tests only. codecov.yml's floor moves from 90% to 99% with no threshold slack. The implementation is untouched.

What the new tests reach

branch how
Profiles() open error, config and credentials files a path whose parent is a file, so the failure is not "does not exist"
list_profiles error result same
wrapTool schema error a tool whose InputSchema cannot be marshalled
discoverTools profile-listing error same as above
tools/list failure receiving middleware on the fake server rejects the method
a tool whose inputSchema is not an object receiving middleware rewrites the result
pagination fake server with ServerOptions{PageSize: 1} and two tools
a cancelled tool call cancelled context, and the session must survive it
connectCtx with no base context called directly
Run over stdio actually run; under go test stdin is /dev/null, so the client is at EOF and Run returns after serving
the session race a gate holds one connect open while a session for the same profile is published, so the loser's session is discarded deterministically
drainBody read error a reader that always fails
GetBody on a bodyless request called, and asserted to stay bodyless

Why 99% and not 100%

Three statements cannot be reached from a test:

  • json.Marshal on map[string]any{"profiles": []string}
  • json.Marshal on a map json.Unmarshal just produced -- JSON has no NaN or Inf, so the round trip cannot fail
  • SignHTTP's error, whose only source in aws-sdk-go-v2 v1.43.4 is buildSignature -> HMAC, which does not fail

Dropping those checks to reach a round number would be worse than the number, and Codecov has no line-level ignore -- only paths. So the target is 99% with threshold: 0%: the real ceiling, gated exactly.

Raises coverage from 93.1% to 99.0% with tests only; the implementation is
unchanged. The upstream error paths are driven through receiving middleware on
the fake server, the shared-config read errors through a path whose parent is a
file, and the session race through a gate that holds a connect open while
another session is published for the same profile.

The remaining three statements cannot be reached: json.Marshal cannot fail on a
[]string or on a map json.Unmarshal just produced, and SignHTTP's only error
source is an HMAC write. The checks stay, so the codecov floor becomes 99% with
no slack rather than a rounded-down 100%.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@winebarrel
winebarrel enabled auto-merge August 9, 2026 04:06
auto-merge was automatically disabled August 9, 2026 04:07

Repository rule violations found

@winebarrel
winebarrel enabled auto-merge August 9, 2026 04:07
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (e7ccb58) to head (f84062e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #6      +/-   ##
==========================================
+ Coverage   91.12%   98.38%   +7.25%     
==========================================
  Files           5        5              
  Lines         372      372              
==========================================
+ Hits          339      366      +27     
+ Misses         19        3      -16     
+ Partials       14        3      -11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Codecov counts lines and reports 98.38%, where `go tool cover` counts
statements and reports 99.0%. The 99% target was set from the wrong number, so
the check failed on a fully covered tree.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@winebarrel
winebarrel merged commit 5b16b77 into main Aug 9, 2026
5 checks passed
@winebarrel
winebarrel deleted the raise-coverage branch August 9, 2026 04:13
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