Skip to content

tests: raise eventstream coverage from 65% to 75%#1

Merged
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage
May 27, 2026
Merged

tests: raise eventstream coverage from 65% to 75%#1
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

Adds focused tests for previously uncovered broker and server branches. No production code changes — single new file zz_added_coverage_test.go.

Coverage delta:

  • package eventstream: 77.1% -> 89.2%
  • module total (incl. examples/): 65.2% -> 75.4%

Per-function highlights:

  • server.handleConn 0% -> 100%
  • service.Stop 88.9% -> 100%
  • broker.handleConn 72.4% -> 100%
  • publishWith 89.7% -> 100%
  • takeToken 94.7% -> 100%

What the tests cover

  • Server.handleConn full subscribe/publish/cleanup with net.Pipe connections
  • Server.publish wildcard sender-skipped + topic literal * no-double-deliver branches
  • broker.handleConn subscribe-read-fail early-return path
  • All four pubsub bus event branches (pubsub.subscribed, pubsub.unsubscribed, pubsub.published, pubsub.rate_limited) via a recording stub EventBus
  • broker.publishWith wildcard fan-out, sender-skip on wildcard, and topic-is-wildcard skip branch
  • Service.Stop ctx.Done() early-return when shutdown blocks
  • takeToken refill clamp at publishBurstBudget

Approach: a pipeStream adapter wires net.Pipe into coreapi.Stream, letting broker.handleConn run end-to-end without a real driver/tunnel. Same trick (raw net.Pipe) drives Server.handleConn since it takes net.Conn directly.

Test plan

  • go test -race -count=1 -timeout 120s ./... passes
  • go vet ./... clean
  • go tool cover -func confirms 75.4% module / 89.2% package

Cover the remaining broker branches by driving handleConn through
net.Pipe-backed coreapi.Stream / net.Conn pairs:

- Server.handleConn full subscribe/publish/cleanup path
- Server.publish wildcard sender-skipped + topic '*' no-double-deliver
- broker.handleConn subscribe-read-fail early return
- broker.handleConn pubsub.subscribed / .unsubscribed / .published /
  .rate_limited bus event branches via a recording stub EventBus
- broker.publishWith wildcard fan-out + wildcard topic skip + bus
  pubsub.published branch
- Service.Stop ctx.Done() branch
- takeToken refill cap at publishBurstBudget

Package coverage 77.1% -> 89.2%; module total 65.2% -> 75.4%.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

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 ☂️

@TeoSlayer TeoSlayer merged commit f3400e4 into main May 27, 2026
2 checks passed
@TeoSlayer TeoSlayer deleted the add-test-coverage branch May 27, 2026 22:45
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.

2 participants