Skip to content

test: expand httpclient error path coverage#246

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/expand-httpclient-test-coverage
Draft

test: expand httpclient error path coverage#246
Copilot wants to merge 4 commits intomainfrom
copilot/expand-httpclient-test-coverage

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

HTTP callback tests only validated happy paths. Error handling for malformed payloads, transport failures, and body read errors was untested.

Changes

  • TestErrorPaths: Table-driven tests for invalid protobufs/JSON, malformed URLs, invalid methods
  • TestTransportFailures: Connection errors, unreachable endpoints
  • TestBodyReadFailures: Simulated connection drops during response read
  • TestErrorSemantics: Validates consistent error handling across protobuf and JSON paths

Coverage

Increases from ~80% to 96%. All error branches in Call() and callJSON() now tested, including:

  • Payload parsing errors → 400 status
  • Request construction errors → 400 status
  • Transport/network errors → 500 status
  • Response body read errors → 500 status

Example test structure:

tests := []struct {
    name           string
    setup          func() ([]byte, error)
    expectErr      bool
    expectCode     int32
    expectContains string
}{
    {
        name: "Invalid Method in Request",
        setup: func() ([]byte, error) {
            return pb.Marshal(&proto.HTTPClient{
                Method: "INVALID\nMETHOD",
                Url:    "http://localhost",
            })
        },
        expectErr:      true,
        expectCode:     400,
        expectContains: "Unable to create HTTP request",
    },
    // ...
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Expand httpclient callback tests for error-path coverage</issue_title>
<issue_description>## Summary
HTTP callback client tests focus on happy paths and miss several operational failures.

Problem

Invalid proto payloads, request build errors, transport failures, and response read errors are not comprehensively tested.

Scope

  • Add table-driven tests for all key error branches
  • Use custom round-tripper/readers to simulate network/body failures
  • Verify returned status codes and wrapped errors

Acceptance Criteria

  • Error branches in Call/callJSON are covered
  • Tests verify consistent error semantics
  • make tests passes for affected package

References

  • pkg/callbacks/httpclient/httpclient.go</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 15, 2026 17:01
Add table-driven tests for error scenarios in httpclient callback:
- Invalid proto/JSON payloads
- Request build errors (invalid method/URL)
- Transport failures (connection errors)
- Response body read errors (simulated connection drops)
- Verify error semantics and status codes

Coverage increased to 96% for httpclient package.

Co-authored-by: madflojo <1731256+madflojo@users.noreply.github.com>
- Remove unused errorReader type and methods
- Fix unused parameter warnings with underscore
- Fix ineffectual assignment warnings
All tests pass and linting is clean.

Co-authored-by: madflojo <1731256+madflojo@users.noreply.github.com>
- Remove unused failingRoundTripper type
- Use blank identifier directly for intentionally unused errors
- Add explanatory comment about transport mocking limitation
All tests pass and linting is clean.

Co-authored-by: madflojo <1731256+madflojo@users.noreply.github.com>
Copilot AI changed the title [WIP] Expand httpclient callback tests for error-path coverage test: expand httpclient error path coverage Feb 15, 2026
Copilot AI requested a review from madflojo February 15, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Expand httpclient callback tests for error-path coverage

2 participants

Comments