Skip to content

Conversation

@lowhung
Copy link
Owner

@lowhung lowhung commented Dec 23, 2025

Summary

This PR adds comprehensive test coverage across all core modules and introduces a code coverage workflow.

Changes

Tests Added:

  • buswatch-types: 83 tests covering Microseconds, ReadMetrics, WriteMetrics, ModuleMetrics, SchemaVersion, and Snapshot with serialization roundtrips
  • buswatch-sdk: 36 tests covering state management, ModuleHandle, Instrumentor, backlog computation, and thread safety
  • buswatch-adapters: 32 tests covering RabbitMQ queue metrics parsing, Kafka/NATS builders, and error handling
  • buswatch-tui: 62 tests covering duration parsing/formatting, MonitorData health computation, History sparklines, and DataFlowGraph

CI/CD:

  • New coverage.yml workflow using cargo-tarpaulin
  • Generates XML and HTML coverage reports
  • Uploads reports as artifacts (14 day retention)
  • Runs on push to main and on PRs

Testing

All tests pass locally:

cargo test --all-features --workspace

- Add extensive tests for Microseconds (conversions, ordering, edge cases)
- Add tests for ReadMetrics and WriteMetrics (builders, health checks, edge cases)
- Add tests for ModuleMetrics (multiple topics, unicode, special chars)
- Add tests for SchemaVersion (compatibility, const functions)
- Add tests for Snapshot (builders, iteration, serialization roundtrips)
- Test coverage for serde JSON and minicbor CBOR serialization
- Add tests for state management (Arc sharing, backlog computation)
- Add tests for ModuleHandle (pending guards, cloning, global counters)
- Add tests for Instrumentor (multi-module scenarios, builder patterns)
- Add thread safety test for concurrent metric increments
- Add tests verifying pending time measurement
- Add tests for AdapterError display formatting
- Add tests for RabbitMQ queue metrics conversion edge cases
- Add tests for RabbitMQ JSON deserialization of queue info
- Add tests for Kafka builder options
- Add tests for NATS builder options
- Add tests for duration parsing and formatting
- Add tests for MonitorData health status computation and sorting
- Add tests for History sparkline generation and rate calculation
- Add tests for DataFlowGraph producer/consumer tracking
- Run coverage on push to main and on PRs
- Generate XML and HTML coverage reports
- Upload reports as artifacts for 14 days
- Replace .is_none() with !contains_key() in flow.rs tests
- Add --workspace flag to CI test job to run all crate tests
@lowhung lowhung merged commit baddbe9 into main Dec 23, 2025
5 checks passed
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