Skip to content

Conversation

@hancengiz
Copy link
Contributor

Summary

This PR adds unit tests to increase the overall test coverage from 58.8% to 62.2%.

Changes

New Tests in cmd_test.go

  • TestFormatRelativeTime: Comprehensive tests for time difference formatting (seconds, minutes, hours, days, weeks)
  • TestFormatRelativeTimeBoundaries: Tests for boundary conditions between time intervals

New Tests in parser_test.go

  • TestGetProjectLastUpdate: Tests project last update time extraction with various session combinations
  • TestParseMessage_EdgeCases: Tests empty message content handling
  • TestParseMessage_NullParentUUID: Tests nil parent UUID handling
  • TestParseMessage_WithParentUUID: Tests valid parent UUID assignment
  • TestParseMessage_AlternateTimestampFormat: Tests RFC3339 timestamp parsing
  • TestParseMessage_InvalidTimestamp: Tests fallback behavior for invalid timestamps
  • TestParseSession_WithCWD: Tests CWD extraction from sessions
  • TestParseSession_SummaryFallback: Tests using first user message as summary fallback
  • TestParseSession_SummaryFallbackTruncation: Tests long message truncation
  • TestDiscoverProjects_SkipsNonEncodedPaths: Tests filtering of non-encoded directories
  • TestDiscoverProjects_NotADirectory: Tests error handling for file paths

Coverage Improvements

Function Before After
formatRelativeTime 0% 100%
getProjectLastUpdate 80% 100%
parseMessage 76.7% 86%
DiscoverProjects 81% 90.5%
ParseSession 63.8% 87.2%

Testing

All tests pass:

go test -cover ./...
ok      github.com/fabriqaai/claude-code-logs   3.209s  coverage: 62.2% of statements

@hancengiz can click here to continue refining the PR

- Add comprehensive tests for formatRelativeTime (0% -> 100%)
- Add tests for getProjectLastUpdate (80% -> 100%)
- Add tests for parseMessage edge cases (76.7% -> 86%)
- Add tests for DiscoverProjects edge cases (81% -> 90.5%)
- Add tests for ParseSession with CWD and summary fallback (63.8% -> 87.2%)

Overall coverage improved from 58.8% to 62.2%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants