Skip to content

Close the last zero-coverage core modules: events.rs and audit.rs #92

Description

@Zlyzart

Summary

Two core modules need direct unit tests. events.rs already has one test (published_event_reaches_a_subscriber) but is missing the subscriber-drop-then-publish safety case. audit.rs has zero tests and needs a #[cfg(test)] query helper on Db plus assertions on both row presence and the detail-format string.

Acceptance criteria

  • events.rs: a test exercises publish after the only subscriber has been dropped — it must not panic (the let _ already discards the error; the test explicitly covers that path).
  • audit.rs: a test calls record_override on a temp Db, then asserts: one row exists with kind = "override", the correct issue_key, the correct reason, and detail formatted as "step_run {step_run_id} ({step_id})".
  • A #[cfg(test)] helper on Db (e.g. list_audit_rows) returns the raw audit-log rows so test assertions can inspect field values — this is test-only surface, not a new public method.
  • All new tests live inline as #[cfg(test)] blocks in their respective modules (no new test files).
  • cargo test -p clabby-core passes with no new #[ignore] or #[allow(dead_code)].

Out of scope

  • The existing published_event_reaches_a_subscriber test in events.rs — already present, do not remove or rewrite it.
  • A test for publish with no subscribers — the let _ = self.tx.send(ev) already makes this explicit; a test would only restate the code.
  • Any coverage for db.rs itself or other modules.
  • New public (non-#[cfg(test)]) methods on Db.

Files in scope

  • crates/core/src/events.rs — append subscriber-drop test to the existing #[cfg(test)] block.
  • crates/core/src/audit.rs — add a new #[cfg(test)] block with the record_override test; construct Db via Db::connect(path) against a tempfile::tempdir() (same pattern as crates/core/tests/e2e.rs).
  • crates/core/src/db.rs — add a #[cfg(test)] list_audit_rows (or equivalent) method that returns all rows from audit_log so the audit.rs test can assert field values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:engineRust core/CLI: crates/core, crates/cli.area:testsUnit, integration, and e2e test suites.complexity:haikuSmall and self-contained; an agent can ship this in one shot.priority:highSignificant impact; schedule in next cycle.status:refinedAgent-refined (acceptance criteria + proposed complexity); awaiting a human's go.type:tech-debtKnown shortcut to repay; reduces future friction.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions