test: remove credential-gated GitHub tests superseded by contract tests#809
test: remove credential-gated GitHub tests superseded by contract tests#809
Conversation
TestPREvidenceForCommit, TestPullRequestsForCommit, and TestGetPullRequestApprovers all called SkipIfEnvVarUnset and tested internal GithubConfig methods against the real GitHub API. Their behaviour is fully covered by TestGitHubContract_Fake (always runs) and TestGitHubContract_RealGitHub (skips without credentials). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @jumboduck's task in 2m 21s —— View job PR Review: Remove credential-gated GitHub tests
Static AnalysisAll checks pass — Review SummaryThis is a clean, well-motivated PR. The deletion of 181 lines of credential-gated tests in What's good
One observation (non-blocking)In VerdictNo issues found. The PR correctly follows the fake-and-contract pattern established for AWS Lambda. The deleted tests are fully superseded and the |
The hardcoded SHA 480e5a0 was a squash-merged feature branch commit not reachable from main's linear history, causing CI to report "reference not found" even with fetch-depth: 0. Resolve HEAD and HEAD~1 at SetupTest time so the SHAs always exist in whichever history the CI checkout has. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
internal/github/github_test.gocontained three test methods that calledtestHelpers.SkipIfEnvVarUnset(t, []string{"KOSLI_GITHUB_TOKEN"}):TestPREvidenceForCommitTestPullRequestsForCommitTestGetPullRequestApproversThese tests hit the real GitHub API and were silently skipped in any environment
without a token, giving false confidence in CI runs that lacked the credential.
Decision: delete the skipping tests, rely on fakes and contract tests
We removed all three methods and replaced the coverage with the
fake-and-contract pattern already established for AWS Lambda
(
internal/aws/fake_lambda.go+internal/aws/lambda_contract_test.go).Why the deleted tests were the wrong layer
TestPullRequestsForCommitandTestGetPullRequestApproverstestedGithubConfigmethods (PullRequestsForCommit,GetPullRequestApprovers)that are internal implementation details — they are not on the
types.PRRetrieverinterface. Testing implementation details couples the testsuite to the HTTP client internals of
go-github, requiring real credentialsjust to verify plumbing that is already exercised indirectly by the interface
contract.
TestPREvidenceForCommittestedGithubConfig.PREvidenceForCommitV2, whichis on the interface — but the contract tests already cover it completely.
The pattern we follow
internal/types/types.go(PRRetriever)internal/github/fake_github.go(FakeGitHubClient)internal/github/github_contract_test.go(TestGitHubContract_Fake)internal/github/github_contract_test.go(TestGitHubContract_RealGitHub)KOSLI_GITHUB_TOKENinternal/github/github.go(NewGithubRetrieverFunc)TestGitHubContract_Fakeverifies the full V1/V2 contract — happy path,unknown commit, error injection,
ProviderAndLabel— without any networkaccess, every time the suite runs.
TestGitHubContract_RealGitHubruns the identical assertions against the liveGitHub API when
KOSLI_GITHUB_TOKENis present (nightly CI, developermachines with the token set). This is the one legitimate place that requires
real credentials, exactly mirroring
TestLambdaContract_RealAWS.Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com