PR #131: githubAPIURL() function has no unit tests #134
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?
What was missed
githubAPIURL()incmd/review-bot/main.gocontains non-trivial URL-derivation logic: it mapshttps://github.com→https://api.github.comand maps any other host (GHES) →<host>/api/v3. This function has no unit tests inmain_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
cmd/review-bot/main.goline 695–706What needs to happen
Add
TestGithubAPIURLincmd/review-bot/main_test.gowith table-driven cases covering:https://api.github.comhttps://github.com→https://api.github.comhttps://github.com/(trailing slash) →https://api.github.comhttps://ghe.example.com→https://ghe.example.com/api/v3https://github.concur.com→https://github.concur.com/api/v3(GHES with concur domain does NOT map to api.github.com)References