test: improve cmd/review-bot coverage — doc-map validation, validateurl success path, isValidateError nil #139

Closed
opened 2026-05-15 04:12:20 +00:00 by rodin · 0 comments
Owner

Why

The cmd/review-bot package has 44.6% coverage. Three specific gaps are straightforward to close:

  1. isValidateError(nil, ...) — the nil-input early-return is untested
  2. runValidateURL success path — the "OK: ... is safe" output is never exercised in tests
  3. --doc-map validation in main() — subprocess tests for invalid doc-map path (path traversal, nonexistent file)
  4. validateURL with empty-host URL — the host == "" branch

None of these require network access or a real LLM — they exercise local validation logic.

Acceptance Criteria

  • TestIsValidateError_Nil: confirms isValidateError(nil, &ve) returns false
  • TestRunValidateURL_SuccessPath: test a URL that resolves to a public IP (e.g. https://example.com) or mock DNS; confirms OK output and exit 0
  • TestValidateURL_EmptyHost: confirms error for URL like https:// (no host)
  • TestMainSubprocess_InvalidDocMapPath: subprocess test — --doc-map ../../../etc/passwd fails with path traversal error
  • TestMainSubprocess_InvalidDocMapFile: subprocess test — --doc-map nonexistent.yml fails with workspace resolve error (nonexistent file)
  • Coverage for cmd/review-bot improves from 44.6% to ≥50%
  • All existing tests still pass
  • No new production code changes — tests only
## Why The `cmd/review-bot` package has 44.6% coverage. Three specific gaps are straightforward to close: 1. `isValidateError(nil, ...)` — the nil-input early-return is untested 2. `runValidateURL` success path — the "OK: ... is safe" output is never exercised in tests 3. `--doc-map` validation in `main()` — subprocess tests for invalid doc-map path (path traversal, nonexistent file) 4. `validateURL` with empty-host URL — the `host == ""` branch None of these require network access or a real LLM — they exercise local validation logic. ## Acceptance Criteria - [ ] `TestIsValidateError_Nil`: confirms `isValidateError(nil, &ve)` returns false - [ ] `TestRunValidateURL_SuccessPath`: test a URL that resolves to a public IP (e.g. `https://example.com`) or mock DNS; confirms OK output and exit 0 - [ ] `TestValidateURL_EmptyHost`: confirms error for URL like `https://` (no host) - [ ] `TestMainSubprocess_InvalidDocMapPath`: subprocess test — `--doc-map ../../../etc/passwd` fails with path traversal error - [ ] `TestMainSubprocess_InvalidDocMapFile`: subprocess test — `--doc-map nonexistent.yml` fails with workspace resolve error (nonexistent file) - [ ] Coverage for `cmd/review-bot` improves from 44.6% to ≥50% - [ ] All existing tests still pass - [ ] No new production code changes — tests only
rodin closed this issue 2026-05-15 04:35:54 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rodin/review-bot#139