Skip to content

Add unit tests for AlertHistory.query() filter combinations #4

@jason-h23

Description

@jason-h23

Summary

AlertHistory in src/sentinel/history.rs has filtering methods but no test coverage for the query() method, especially for filter combinations and pagination edge cases.

What To Do

Add ~15-20 unit tests covering:

  1. Single filters: priority alone, block range alone, pattern type alone
  2. Combined filters: all three filters at once
  3. Pagination: correct items per page, page boundaries, page > total_pages, page_size clamping (>100)
  4. Edge cases: empty file, invalid JSON lines, zero matching alerts
  5. Sort order: verify Newest vs Oldest ordering

Files

  • src/sentinel/history.rs (add tests at bottom)

Acceptance Criteria

  • 15+ test cases covering the scenarios above
  • All tests pass (cargo test --all-features)
  • No changes to production code (test-only PR)
  • Clippy passes

Estimated Effort

~150-200 lines of test code, 2-3 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions