Skip to content

test: refactor low-signal tests and expand coverage past 95% - #116

Draft
domfahey wants to merge 5 commits into
RealGeeks:mainfrom
domfahey:test/coverage-and-refactor
Draft

domfahey wants to merge 5 commits into
RealGeeks:mainfrom
domfahey:test/coverage-and-refactor

Conversation

@domfahey

@domfahey domfahey commented Nov 25, 2026 •

Copy link
Copy Markdown

Raises test coverage from ~81% to ~98% of lines, mostly with new tests. Shipped behaviour changes are small and listed below.

Behaviour changes (review these closely)

  • Sidebar table heading: shows usage from the larger of used_by_count and the used_by list, and omits it when both are empty.
  • Config lookup: sources finds the config file without migrating a legacy ~/.config/realgeeks, so checking a path never renames anything (config_path_in_use).
  • Default key name: skips an empty HOSTNAME/COMPUTERNAME instead of saying "unknown host".
  • Test seams, no behaviour change: confirm_prompt, login_with, notify_with, read_limited_to, find_browser_with, format_panic, update::release_target_for.

Tests (skim)

  • New tests/error_paths.rs: 500/422/404 propagation, missing ids, usage errors for every resource command.
  • Unit tests no longer pass silently on errors (else { return; }, unwrap_or_default()).
  • Removed duplicate tests. The help-text checks for safety notes (area pages, pages update, guide fonts) are kept in one test.
  • Browser-login tests use the OS-assigned port (no probe-and-rebind race). The paging mock no longer depends on mockito's match order.
  • tests/common keeps LLVM_PROFILE_FILE, so cargo llvm-cov counts subprocess runs.

Coverage (cargo llvm-cov --summary-only)

Before After
Lines 81.4% 98.0%
Functions 83.2% 97.6%
Regions 76.4% 95.3%

Verification

cargo fmt --check, cargo clippy --all-targets -D warnings and cargo test (335 passed) all pass. The coverage figures were measured before the last two commits.

Merge note: conflicts with #114 and #115, mostly in the test files they also touch. Land those first, then rebase this.

🤖 Generated with Claude Code

domfahey and others added 5 commits November 25, 2026 07:36
Add tests/common/mod.rs so integration tests preserve LLVM_PROFILE_FILE across env_clear() instead of dropping subprocess coverage profiles, remove duplicate and prose-grep tests, replace vacuous or bypassing unit tests with boundary assertions, and add unit and integration tests across core modules and commands.

Coverage (cargo llvm-cov --summary-only): 91.32% regions, 93.97% functions, 96.04% lines.
Add in-process command error-propagation and edge-branch tests in tests/error_paths.rs, extract pure seams for interactive confirmation, browser launch, update notifications, response size limits, browser lookup, and panic formatting so those paths are tested deterministically, remove redundant error-mapping closures in inspect, and cover remaining unit edge cases across client, config, auth, provenance, search, and resource commands.

Coverage (cargo llvm-cov --summary-only): 95.27% regions, 97.58% functions, 97.96% lines.
Skip appending ", used by: 0 page(s): " when a sidebar's used_by array is empty (and drop the trailing colon when used_by_count is non-zero with no listed slugs), with unit tests for sidebar_heading.
…nd key names

- sources::why_refused finds the config file with config_path_in_use(),
  which does not move a legacy ~/.config/realgeeks, so checking which files
  may be sent (and the tests that do it) never renames a real config dir
- the sidebar heading uses the larger of used_by_count and the used_by
  list, so a stale 0 or a missing list no longer hides pages using it
- the default key name skips an empty HOSTNAME/COMPUTERNAME instead of
  falling through to "unknown host"
- the rename-failure test uses a dangling symlink, not a read-only dir,
  so it also fails the rename when run as root

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…checks

- browser login tests bind port 0 and learn the real port from the start
  request, instead of probing a free port and rebinding it
- the page-1 rate-limit mock matches the exact query and expects one hit
- the multi-section guide test checks the blank line between sections
- restore the area-pages, pages update and guide fonts help assertions
  dropped in the refactor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant