Skip to content

Refactor test suite for consistency and maintainability - #54

Closed
wesm wants to merge 4 commits into
mainfrom
metrics-display-fixes
Closed

Refactor test suite for consistency and maintainability#54
wesm wants to merge 4 commits into
mainfrom
metrics-display-fixes

Conversation

@wesm

@wesm wesm commented Feb 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Split monolithic parser tests (parser_test.go) into per-agent files (claude_parser_test.go, codex_parser_test.go, gemini_parser_test.go)
  • Convert many tests to table-driven format
  • Add test fixture files under internal/parser/testdata/
  • Refactor watcher tests to use real fsnotify events instead of mocking internal state
  • Make analytics test assertions dynamic (derived from seed data instead of hardcoded)
  • Small production code improvements: deterministic prune output, http.Method constants in export.go, error handling on io.ReadAll

Test plan

  • make test passes
  • make vet passes
  • No coverage regressions (test count increased from 23 to 33 parser functions)

🤖 Generated with Claude Code

wesm and others added 4 commits February 25, 2026 18:32
… model

Use post-filter counts (after pairAndFilter removes empty tool_result
messages) for session.MessageCount and UserMessageCount so analytics
matches the status bar total. Add postFilterCounts() helper and reorder
writeBatch/writeSessionFull to compute filtered messages before upsert.

Add "All" time range preset to the analytics date picker.

Update Gemini insight model from gemini-3-pro-preview to
gemini-3.1-pro-preview.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change ALL_FROM from 2020-01-01 to 1970-01-01 so the "All" date range
preset is truly universal regardless of session age.

Add integration tests verifying that both writeBatch (SyncAll) and
writeSessionFull (SyncSingleSession) persist post-filter message counts
when sessions contain empty user+tool_result messages that get removed
by pairAndFilter.

Add ClaudeToolResultUserJSON helper to testjsonl for constructing user
messages with only tool_result content blocks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Corrupt stored counts and clear file_mtime between SyncAll and
SyncSingleSession so the skip logic doesn't short-circuit. This
ensures writeSessionFull runs and the assertion verifies it writes
correct post-filter counts, not stale values from SyncAll.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Check RowsAffected() == 1 after the UPDATE so a mismatched session ID
causes a clear failure instead of a silent no-op.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wesm wesm closed this Feb 26, 2026
@roborev-ci

roborev-ci Bot commented Feb 26, 2026

Copy link
Copy Markdown

roborev: Combined Review (f23ade1)

Summary Verdict: All agents agree the code is clean; no
medium, high, or critical severity issues were identified.


Synthesized from 4 reviews (agents: codex, gemini | types: default, security)

@wesm
wesm deleted the metrics-display-fixes branch June 25, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant