test: lift statement coverage from 2.5% to 91.9%#1
Merged
Conversation
Add structural tests for every adapter the runtime owns: streams (Listen, Dial, SendDatagram, Accept, full stream-adapter accessor set + Read EOF + Write error), handshake (Runtime accessors + all 13 service-adapter shims), policy (Runtime accessors + full policy-manager + runner adapter delegation), events (Publish / Subscribe happy + nil-daemon short-circuits), trust (asCoreapiTrust bridge), and lifecycle (StartPlugins / StopPlugins / dep wiring). Tests use the daemon's real PortManager + TunnelManager via the public surface (AddTunnelPeer, RegisterTrustChecker, RegisterHandshakeService, Ports().NewConnection, Listener.TrySend, ProcessRelayedApproval), so no fakes shadow the production paths. Remaining sub-100% functions (DialAndSend success path, identity-bearing PublicKey/Sign, Registry, Dial success) are ceiling-bound: each requires either a daemon constructed with a real Ed25519 identity (only settable via Start, which requires a live registry) or a successfully ESTABLISHED TCP-style handshake against a peer daemon. Neither is reachable from a single-process unit test in this package. 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
runtimepackage owns: streams, handshake, policy, events, trust, lifecycle.Coverage delta
go test -race -count=1 -timeout 180s ./...passes.What landed
zz_adapters_test.go— HandshakeRuntime / PolicyRuntime / HandshakeServiceAdapter read-only pathszz_deps_test.go— Runtime.StartPlugins / StopPlugins / Deps wiring (Streams, Identity, Events)zz_handshake_adapter_test.go— ApproveHandshake / RevokeTrust shim delegationzz_listener_test.go— daemonListener Accept-after-Close + Port accessorzz_policy_manager_test.go— full policyManagerAdapter + runnerAdapter delegation (every method, both error and happy paths)zz_trust_test.go— asCoreapiTrust nil-bridge + delegatezz_streams_ceiling_test.go— pushes Dial / SendDatagram / Listen error path / TrustedPeers loop body / IsTrusted-with-registered-checker / DialAndSend error path / streamAdapter accessors+Read EOF+Write error / RejectHandshake+SendRequest shimszz_eventbus_internal_test.go— covers daemonEventBus nil-daemon early-return branches (internal-package test)Ceiling-bound (genuinely untestable from a single-process unit test)
These 7 functions sit at 36–75% and cannot reach 100% without standing up a live daemon with identity + registry + a peer that completes a 3-way handshake:
HandshakeRuntime.DialAndSendHandshakeRuntime.PublicKey,Sign,IdentityAdapter.PublicKey,Signd.identity != nil. The daemon only sets that insideStart(), which requires a workingRegistryAddr. The nil branches are covered.HandshakeRuntime.RegistryregConn != nil, only set byStart()→ registry. The nil branch is covered.daemonStreams.DialnewStreamAdapterto wire a successfully-dialed conn — i.e. live tunnel handshake. The cancelled-ctx and other error branches are covered.Test plan
go test -race -count=1 -timeout 180s ./...passes locallygo tool cover -func=...reports 91.9% total