test: add PostWithRetry coverage in credentials - #994
Merged
Conversation
pkg/credentials/PostWithRetry had no test coverage. Add a request_test.go covering the success path, non-200 (no retry) path, the retry-then-recover path (port closed then a server comes up between attempts), and the exhausted-retries path (ECONNREFUSED wrapped and backoff elapsed).
✅ Deploy Preview for devsydev canceled.
|
✅ Deploy Preview for images-devsy-sh ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 12 |
| Duplication | 2 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
Set ReadHeaderTimeout on the test http.Server so gosec G112 (Potential Slowloris Attack because ReadHeaderTimeout is not configured) passes. Lint fix only; no behavior change. This commit was created by an AI agent (OpenHands) on behalf of the user.
skevetter
marked this pull request as ready for review
August 14, 2026 03:16
skevetter
enabled auto-merge (squash)
August 14, 2026 06:09
skevetter
disabled auto-merge
August 14, 2026 06:10
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Package reviewed
pkg/credentials— the credentials helper package, specificallyPostWithRetryinpkg/credentials/request.go.Issue found
PostWithRetry(the retry loop that posts to the local credentials helper) had no test coverage. Its behavior — returning the body on a 200, returning (not retrying) a non-200, retrying onECONNREFUSED, and exhausting retries — was entirely untested, so regressions to the retry/backoff contract would go unnoticed.Change
Add
pkg/credentials/request_test.gowith four focused tests (test-only change, no behavioral change torequest.go):TestPostWithRetry_ReturnsBodyOnSuccess— 200 returns the response body.TestPostWithRetry_ReturnsErrorOnNon200— a 500 returns an error mentioning the status and endpoint, and does not retry (asserts elapsed < 500ms).TestPostWithRetry_RetriesConnectionRefusedThenSucceeds— the port is initially closed (connection refused), a server comes up between attempts, and a later retry succeeds and returns the body. The helper server is started in a goroutine and shut down cleanly viat.Cleanup.TestPostWithRetry_ExhaustsRetriesOnConnectionRefused— a port with no listener yieldsECONNREFUSEDon every attempt; the loop exhausts its retries, returns an error wrappingsyscall.ECONNREFUSED, and at least one backoff step elapses.Verification performed
task cli:lint:ci— 0 issues.task cli:test—pkg/credentialspasses (coverage 0% → 25.8%). The only failing package ispkg/git(TestRepoClone*), which fails onorigin/mainas a known pre-existing stale assertion; this change does not touchpkg/git.go test ./pkg/credentials/ -run TestPostWithRetry -count=1 -v— all 4 tests pass; ran 3× with no flakiness.This PR was created by an AI agent as part of an automated daily package review job.