PR #131: githubAPIURL() function has no unit tests #134

Closed
opened 2026-05-14 22:16:13 +00:00 by rodin · 0 comments
Owner

What was missed

githubAPIURL() in cmd/review-bot/main.go contains non-trivial URL-derivation logic: it maps https://github.comhttps://api.github.com and maps any other host (GHES) → <host>/api/v3. This function has no unit tests in main_test.go.

Go patterns require public functions (and significant private helpers used in routing) to have test coverage. An incorrect GHES URL will silently cause all GitHub API calls to fail at runtime without a clear error message.

Source

  • PR: #131 — feat: implement GitHub API methods and VCS routing (issue #130)
  • Code quality rule: Test table driven / missing tests for new/modified functions
  • File: cmd/review-bot/main.go line 695–706

What needs to happen

Add TestGithubAPIURL in cmd/review-bot/main_test.go with table-driven cases covering:

  • Empty string → https://api.github.com
  • https://github.comhttps://api.github.com
  • https://github.com/ (trailing slash) → https://api.github.com
  • https://ghe.example.comhttps://ghe.example.com/api/v3
  • https://github.concur.comhttps://github.concur.com/api/v3 (GHES with concur domain does NOT map to api.github.com)

References

## What was missed `githubAPIURL()` in `cmd/review-bot/main.go` contains non-trivial URL-derivation logic: it maps `https://github.com` → `https://api.github.com` and maps any other host (GHES) → `<host>/api/v3`. This function has no unit tests in `main_test.go`. Go patterns require public functions (and significant private helpers used in routing) to have test coverage. An incorrect GHES URL will silently cause all GitHub API calls to fail at runtime without a clear error message. ## Source - PR: #131 — feat: implement GitHub API methods and VCS routing (issue #130) - Code quality rule: Test table driven / missing tests for new/modified functions - File: `cmd/review-bot/main.go` line 695–706 ## What needs to happen Add `TestGithubAPIURL` in `cmd/review-bot/main_test.go` with table-driven cases covering: - Empty string → `https://api.github.com` - `https://github.com` → `https://api.github.com` - `https://github.com/` (trailing slash) → `https://api.github.com` - `https://ghe.example.com` → `https://ghe.example.com/api/v3` - `https://github.concur.com` → `https://github.concur.com/api/v3` (GHES with concur domain does NOT map to api.github.com) ## References - [PR #131](https://gitea.weiker.me/rodin/review-bot/pulls/131) - [Issue #130](https://gitea.weiker.me/rodin/review-bot/issues/130)
rodin added the ai-reviewbug labels 2026-05-14 22:16:13 +00:00
rodin closed this issue 2026-05-14 22:53:44 +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#134