test: add unit tests for health module (#334)#347
Merged
Conversation
The health module had 537 lines of code with zero test coverage. This adds 24 tests covering health status calculation, session enrichment, aggregation, snapshot storage, and history cleanup. Refactors storage functions to accept &Path parameter for testability with tempfile::TempDir, keeping public API unchanged. Fixes #334
Owner
Author
Self Code ReviewSummarySolid test-only PR that adds 24 unit tests covering all business logic in the health module (operations.rs + storage.rs). No behavioral changes. FindingsStrengths
Scope notes (non-blocking)
Security
Checklist
|
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
&Pathfor testability (public API unchanged)Changes
crates/kild-core/src/health/operations.rscalculate_health_status(9),enrich_session_with_health(3),aggregate_health_stats(2)crates/kild-core/src/health/storage.rssave_snapshot_to,load_history_from,cleanup_old_history_ininternal variants + 10 tests for snapshot conversion, round-trip storage, cleanup, and date filteringTesting
cargo test -p kild-core -- health— 24 new tests passcargo test --all— 146 tests pass, no regressionscargo clippy --all -- -D warnings— cleancargo fmt --check— cleanValidation
Issue
Fixes #334