tests: lift gateway coverage 74.1% -> 96.8%#1
Merged
Conversation
Adds zz_coverage_test.go covering previously-untested branches:
- New: invalid-subnet error + default subnet/ports applied
- Map: happy path (auto + explicit IP) via startProxy under stubbed
ip/ifconfig binaries on PATH; invalid-IP + outside-subnet errors
- Unmap: real listener teardown + alias removal; malformed-host:port
listener key is skipped without panic
- Stop: idempotent re-Stop, nil-dialer safety, alias slice cleanup,
dialer.Close error tolerated
- addLoopbackAlias / removeLoopbackAlias: both success (rc=0) and
failure (rc=1) exec paths via PATH-shadowed POSIX stubs. Guarded
with os.Getuid() != 0 and runtime.GOOS in {linux,darwin} so the
tests never mutate the real loopback table or run on Windows.
- bridgeConnection: pilot-side read-error path (peer-close triggers
symmetric teardown)
- listenPort: full bind/accept/Stop lifecycle
- Service (L11 plugin adapter): NewService/Name/Order/Start/Stop
Remaining ~3.2% is structural: the linux/darwin branches of
add/removeLoopbackAlias are mutually exclusive at runtime and the
"default" unsupported-OS branch is unreachable without crossbuild.
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
zz_coverage_test.gocovering previously-untested branches ofgateway.goandservice.goMap,startProxy,addLoopbackAlias,Service.{New,Name,Order,Start,Stop}) are now at 100%What is covered
New: invalid-subnet error path + default subnet/portsMap: happy path (auto + explicit IP) viastartProxyunder stubbedip/ifconfigonPATH; invalid-IP + outside-subnet errorsUnmap: real listener teardown + alias removal; malformedhost:portlistener keys are skipped without panicStop: idempotent re-Stop, nil-dialer safety, alias slice cleanup, dialer.Close error toleratedaddLoopbackAlias/removeLoopbackAlias: both success (rc=0) and failure (rc=1) exec paths via PATH-shadowed POSIX stubs. Guarded withos.Getuid() != 0andruntime.GOOS in {linux,darwin}so the tests never touch the real loopback table and skip cleanly on Windows.bridgeConnection: pilot-side read-error branch (peer close triggers symmetric teardown)listenPort: full bind / accept / Stop lifecycleService(L11 plugin adapter):NewService,Name,Order,Start,StopCeiling
Remaining ~3.2% is the linux-vs-darwin
switchlegs inadd/removeLoopbackAlias(mutually exclusive at runtime on a given host) plus thedefaultunsupported-OS arm (unreachable without crossbuild). Per-function the only sub-100% items are those two alias helpers, both at 62.5% — that's the structural ceiling on this host.Test plan
go test -race -count=1 -timeout 180s ./...passesgo tool cover -funcand-html*_test.go