Skip to content

test: add PostWithRetry coverage in credentials - #994

Merged
skevetter merged 4 commits into
mainfrom
pkg-ssh-git/credentials-postretry-tests
Aug 18, 2026
Merged

test: add PostWithRetry coverage in credentials#994
skevetter merged 4 commits into
mainfrom
pkg-ssh-git/credentials-postretry-tests

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/credentials — the credentials helper package, specifically PostWithRetry in pkg/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 on ECONNREFUSED, and exhausting retries — was entirely untested, so regressions to the retry/backoff contract would go unnoticed.

Change

Add pkg/credentials/request_test.go with four focused tests (test-only change, no behavioral change to request.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 via t.Cleanup.
  • TestPostWithRetry_ExhaustsRetriesOnConnectionRefused — a port with no listener yields ECONNREFUSED on every attempt; the loop exhausts its retries, returns an error wrapping syscall.ECONNREFUSED, and at least one backoff step elapses.

Verification performed

  • task cli:lint:ci0 issues.
  • task cli:testpkg/credentials passes (coverage 0% → 25.8%). The only failing package is pkg/git (TestRepoClone*), which fails on origin/main as a known pre-existing stale assertion; this change does not touch pkg/git.
  • Focused run: 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.

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).
@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 62d98a1
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a83db6b11e8530008979b05

@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh ready!

Name Link
🔨 Latest commit 62d98a1
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a83db6b5611200008a219f6
😎 Deploy Preview https://deploy-preview-994--images-devsy-sh.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 12 complexity · 2 duplication

Metric Results
Complexity 12
Duplication 2

View in Codacy

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.

Run reviewer

TIP This summary will be updated as you push new changes.

devsy-app Bot and others added 2 commits August 13, 2026 16:41
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
skevetter marked this pull request as ready for review August 14, 2026 03:16
@skevetter
skevetter enabled auto-merge (squash) August 14, 2026 06:09
@skevetter
skevetter disabled auto-merge August 14, 2026 06:10
@mergify

mergify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skevetter
skevetter merged commit c9c4d9a into main Aug 18, 2026
78 checks passed
@skevetter
skevetter deleted the pkg-ssh-git/credentials-postretry-tests branch August 18, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant