Skip to content

Add comprehensive test coverage for diff formatting and comparison#37

Merged
fullstackjam merged 2 commits intomainfrom
claude/add-unit-tests-QNHVf
Apr 19, 2026
Merged

Add comprehensive test coverage for diff formatting and comparison#37
fullstackjam merged 2 commits intomainfrom
claude/add-unit-tests-QNHVf

Conversation

@fullstackjam
Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds extensive unit test coverage for diff formatting (terminal and JSON output), diff result calculations, dotfiles/shell comparison logic, and API base URL handling.

Why?

This PR significantly improves test coverage across multiple packages:

  • format_test.go: Tests for terminal and JSON formatting of dotfiles, shell, and dev tools sections
  • diff_test.go: Tests for HasChanges(), TotalChanged() calculations, and utility functions (ToSet, PluginsEqual)
  • compare_test.go: Tests for macOS preferences comparison, dotfiles repo normalization, and edge cases
  • search_test.go: Tests for getAPIBase() environment variable handling and URL validation
  • screen_recording_test.go: Tests for non-Darwin stub implementations

These tests ensure correctness of diff calculations, proper handling of empty/nil sections, and secure API URL configuration.

Testing

  • go vet ./... passes
  • Relevant tests added (97 new test cases across 5 test files)
  • Tests cover edge cases: nil sections, empty collections, URL validation, git suffix normalization

Notes for reviewer

Key test scenarios covered:

  • Dotfiles section formatting with repo changes, dirty state, and unpushed commits
  • Shell section with theme and plugin changes
  • JSON output includes shell and dotfiles in summary calculations
  • TotalChanged() correctly counts changes across multiple sections
  • PluginsEqual() handles order-independent comparison
  • getAPIBase() validates URLs and rejects plain HTTP to non-loopback hosts
  • Non-Darwin screen recording stubs are properly tested

https://claude.ai/code/session_01TfJCwVRqyyW8dcfxs57Y1v

- diff: add direct tests for ToSet and PluginsEqual (previously untested)
- diff: cover HasChanges/TotalChanged dotfiles (dirty, unpushed, repoChanged)
  and shell branches; all previously untested code paths
- diff: add FormatTerminal tests for dotfiles and shell sections (all
  printDotfilesSection / printShellSection branches exercised)
- diff: add FormatJSON tests verifying shell, dotfiles, and dev_tools keys
  appear in output with correct summary counts
- diff: add CompareSnapshotToRemote test with macOS prefs in remote config
- diff: add diffDotfiles tests for .git suffix normalization, empty-reference
  no-change guarantee, and distinct-URL change detection
- search: add getAPIBase tests covering default URL, valid HTTPS override,
  valid localhost override, and disallowed HTTP non-loopback fallback
- permissions: test OpenScreenRecordingSettings non-darwin stub returns nil

https://claude.ai/code/session_01TfJCwVRqyyW8dcfxs57Y1v
@github-actions
Copy link
Copy Markdown

👋 Thanks for opening this pull request!

Before merging:

  • Code follows existing patterns in the codebase
  • go build ./... and go vet ./... pass
  • Commit message is clear and descriptive

@fullstackjam will review this soon. Thanks for contributing! 🚀

@github-actions github-actions bot added the tests Tests only label Apr 19, 2026
… case

- permissions: merge TestHasScreenRecordingPermission_NonDarwin into
  _Returns (both asserted IsType on the same call); rename
  TestOpenScreenRecordingSettings_NonDarwin to _Returns for symmetry
- diff: add inline comment on the duplicates-in-a PluginsEqual test case
  explaining why false is returned (set collapse, not length mismatch)

https://claude.ai/code/session_01TfJCwVRqyyW8dcfxs57Y1v
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullstackjam fullstackjam merged commit fca93de into main Apr 19, 2026
9 checks passed
@fullstackjam fullstackjam deleted the claude/add-unit-tests-QNHVf branch April 19, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants