Skip to content

test(api): cover the transport-error path (HTTP.Do failure)#255

Merged
saadqbal merged 1 commit into
developfrom
test/api-transport-error
Jul 14, 2026
Merged

test(api): cover the transport-error path (HTTP.Do failure)#255
saadqbal merged 1 commit into
developfrom
test/api-transport-error

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

The api transport-error harness from the coverage audit — an errRoundTripper that fails every request, simulating the most common real-world API failure the httptest tests can't reach (connection refused / DNS / reset, i.e. HTTP.Do itself erroring). Previously untested in get / bodyRequest.

  • get wraps the transport error (errors.Is).
  • bodyRequest surfaces it.
  • an exported call (WhoAmI) fails on a dead transport rather than reading a zero-value identity as success.

make ci green. No production changes.

🤖 Generated with Claude Code


Note

Low Risk
Test-only addition with no runtime or production behavior changes.

Overview
Adds internal/api/transport_test.go with an errRoundTripper stub so tests can force HTTP.Do to fail (connection refused / DNS / reset) without a real server—paths that httptest-based tests do not cover.

TestTransportError asserts that get wraps the transport error (checkable via errors.Is), bodyRequest returns an error, and WhoAmI fails instead of treating a zero Identity as success when the transport is down.

No production code changes.

Reviewed by Cursor Bugbot for commit f1b129d. Bugbot is set up for automated code reviews on this repo. Configure here.

The api transport-error harness from the coverage audit — an errRoundTripper
that fails every request, simulating the most common real-world API failure
the httptest-server tests can't reach (connection refused / DNS / reset, i.e.
HTTP.Do itself erroring). Previously untested in get / bodyRequest.

- get wraps the transport error (errors.Is).
- bodyRequest surfaces it.
- an exported call (WhoAmI) fails on a dead transport rather than reading a
  zero-value identity as success.

make ci green. No production changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f1b129d. Configure here.

@LukasWodka LukasWodka self-assigned this Jul 14, 2026

@saadqbal saadqbal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 The errRoundTripper is the right way to hit the HTTP.Do failure branch the httptest tests can't reach, and get/bodyRequest both wrap with %w so the errors.Is check holds through the url.Error layer.

@saadqbal
saadqbal merged commit 623fc5d into develop Jul 14, 2026
22 checks passed
@saadqbal
saadqbal deleted the test/api-transport-error branch July 14, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants