test(tracker): close Diagnose/Audit/Doctor API coverage gaps and align MostRecent warning routing#138
Conversation
Agent-Logs-Url: https://github.com/2389-research/tracker/sessions/7ebb52b0-1114-4314-802f-e1d3d1f8af12 Co-authored-by: clintecker <26985+clintecker@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR strengthens test coverage for the newly promoted tracker library APIs (Diagnose/Audit/Doctor) by exercising previously untested selection and error/warning paths, and it refactors repetitive CLI doctor flag-parsing tests into a table-driven form.
Changes:
- Added coverage for
DiagnoseMostRecent,MostRecentRunID,ResolveRunDir, and Diagnose warning-on-malformed-status behavior. - Added Audit error-path coverage for missing/malformed checkpoints and empty run directories.
- Added a minimal Doctor probe seam (
probeProviderFn) to enable credential-free provider probing tests, plus refactored CLI doctor flag tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tracker_doctor.go | Adds a probe function indirection to allow mocking provider probes in tests. |
| tracker_doctor_test.go | Adds a unit test verifying probe-path execution via the probe seam. |
| tracker_diagnose_test.go | Adds tests for newest-run selection and malformed status warning continuation. |
| tracker_audit_test.go | Adds tests for Audit checkpoint-related error paths. |
| tracker_activity.go | Updates MostRecentRunID to emit warnings on malformed checkpoints. |
| tracker_activity_test.go | Adds tests for no-match resolution and most-recent-run selection/error branches (including stderr warning capture). |
| cmd/tracker/doctor_test.go | Refactors multiple flag-parsing tests into a single table-driven test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if !os.IsNotExist(err) { | ||
| fmt.Fprintf(os.Stderr, "warning: cannot load checkpoint for run %s: %v\n", e.Name(), err) | ||
| } |
There was a problem hiding this comment.
MostRecentRunID now writes warnings directly to os.Stderr for malformed checkpoints. This introduces an unavoidable side effect for library callers (and for DiagnoseMostRecent, which calls MostRecentRunID) and is inconsistent with the existing pattern where warnings are routed through configurable LogWriter fields that default to io.Discard (e.g., DiagnoseConfig/AuditConfig). Consider keeping MostRecentRunID silent and surfacing malformed-checkpoint warnings via a configurable writer (e.g., passed in from DiagnoseMostRecent/CLI) or by returning warnings alongside the selected run ID.
| if !os.IsNotExist(err) { | |
| fmt.Fprintf(os.Stderr, "warning: cannot load checkpoint for run %s: %v\n", e.Name(), err) | |
| } |
|
@copilot reivew all the feedback |
…a Diagnose config Agent-Logs-Url: https://github.com/2389-research/tracker/sessions/b37e8677-fc44-46d7-99ab-35bf8c085969 Co-authored-by: clintecker <26985+clintecker@users.noreply.github.com>
Addressed the feedback in commit |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR addresses outstanding test coverage gaps called out in review for the library APIs added in #101, specifically around untested error/selection branches in Diagnose/Audit/Doctor and repetitive CLI doctor flag-parsing tests.
Diagnose/resolve-path coverage
DiagnoseMostRecentcoverage for selecting the newest run by checkpoint timestamp and delegating toDiagnose.MostRecentRunIDbranch coverage for:no runs found)ResolveRunDirno-match test (no run found matching %q).Diagnose malformed status warning path
status.jsonto verify warning emission viaDiagnoseConfig.LogWriterand graceful continuation (no hard failure).Audit error-path coverage
checkpoint.jsonDoctor probe path without real credentials
tracker_doctor.go:probeProviderFnvariable (defaults toprobeProvider)checkProvidersnow callsprobeProviderFn(...)ProbeProviders: truethat mocks probe behavior and verifies probe-path execution without network/API keys.CLI doctor flag parsing cleanup
TestParseFlagsDoctor*tests incmd/tracker/doctor_test.gointo one table-driven test while preserving assertions and coverage intent.Feedback follow-up: library warning side effects
os.Stderrwarning output from exportedMostRecentRunIDso library callers do not get unavoidable stderr side effects.DiagnoseMostRecentusesDiagnoseConfig.LogWriter).MostRecentRunIDremains silent by default.DiagnoseMostRecentemits malformed-checkpoint warnings via the providedLogWriter.