Skip to content

test: increase code coverage to 100%#14

Merged
shenxianpeng merged 1 commit into
mainfrom
feature/100-percent-test-coverage
Jul 3, 2026
Merged

test: increase code coverage to 100%#14
shenxianpeng merged 1 commit into
mainfrom
feature/100-percent-test-coverage

Conversation

@shenxianpeng

Copy link
Copy Markdown
Member

Summary

Increases test coverage from 66% to 100% by adding comprehensive tests for all code paths in commit_check_mcp.server.

Changes

New test coverage for:

  • _normalize_config — non-dict input raises ValueError
  • _normalize_repo_path — non-string, empty, non-existent, file-path inputs
  • _normalize_config_path — non-string, empty, non-existent, non-file inputs
  • _working_directory — actual chdir/restore behavior with a real path
  • _validate_message — real commit-check engine calls (passing and failing)
  • _validate_branch — real engine call with branch name
  • _validate_push — real engine enforcement of no_force_push rule
  • _validate_author — all branches: both name+email, only name, only email, neither
  • _validate_all — all combinations: message, branch, author name, author email
  • All MCP tool error paths — empty/non-string inputs raise proper errors
  • validate_repository_state — all flag combinations, overall fail status
  • describe_validation_rules — config override merging
  • server_health — returns all expected keys
  • main() — entry point invokes mcp.run(transport="stdio")

Retained existing tests

All original tests are preserved (and improved where needed), including:

  • Push safety rule enforcement with mocked _run_checks
  • Config merging with repo defaults
  • Config path resolution relative to repo
  • Repository state with combined checks

Details

  • 65 tests total (up from 11)
  • 100% statement coverage on server.py and __init__.py
  • No source code changes — only test file additions
  • All tests pass cleanly

Add comprehensive tests covering all code paths:
- All _normalize_* helper edge cases (non-dict, non-string, empty,
  non-existent, non-directory, non-file inputs)
- _working_directory with real path (chdir/restore)
- _validate_message, _validate_branch real engine calls
- _validate_push, _validate_author, _validate_all internal branches
- All MCP tool error paths (empty/none values)
- validate_repository_state with all flag combinations
- server_health, describe_validation_rules edge cases
- main() entry point via patched mcp.run

65 tests total, 100% statement coverage on server.py
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@shenxianpeng, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7fcddd2e-d1cf-44c4-9ac7-ef31e02ec486

📥 Commits

Reviewing files that changed from the base of the PR and between aede8c3 and 547e4a3.

📒 Files selected for processing (1)
  • tests/test_server.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/100-percent-test-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added enhancement New feature or request tests labels Jul 3, 2026
@shenxianpeng shenxianpeng removed the enhancement New feature or request label Jul 3, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (aede8c3) to head (547e4a3).

Additional details and impacted files
@@             Coverage Diff              @@
##             main       #14       +/-   ##
============================================
+ Coverage   66.02%   100.00%   +33.97%     
============================================
  Files           2         2               
  Lines         209       209               
============================================
+ Hits          138       209       +71     
+ Misses         71         0       -71     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shenxianpeng shenxianpeng merged commit 1dc8fba into main Jul 3, 2026
7 checks passed
@shenxianpeng shenxianpeng deleted the feature/100-percent-test-coverage branch July 3, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants