test: improve cmd/review-bot coverage — doc-map validation, validateurl success path, isValidateError nil #139
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The
cmd/review-botpackage has 44.6% coverage. Three specific gaps are straightforward to close:isValidateError(nil, ...)— the nil-input early-return is untestedrunValidateURLsuccess path — the "OK: ... is safe" output is never exercised in tests--doc-mapvalidation inmain()— subprocess tests for invalid doc-map path (path traversal, nonexistent file)validateURLwith empty-host URL — thehost == ""branchNone of these require network access or a real LLM — they exercise local validation logic.
Acceptance Criteria
TestIsValidateError_Nil: confirmsisValidateError(nil, &ve)returns falseTestRunValidateURL_SuccessPath: test a URL that resolves to a public IP (e.g.https://example.com) or mock DNS; confirms OK output and exit 0TestValidateURL_EmptyHost: confirms error for URL likehttps://(no host)TestMainSubprocess_InvalidDocMapPath: subprocess test —--doc-map ../../../etc/passwdfails with path traversal errorTestMainSubprocess_InvalidDocMapFile: subprocess test —--doc-map nonexistent.ymlfails with workspace resolve error (nonexistent file)cmd/review-botimproves from 44.6% to ≥50%