Skip to content

Add fluent HTTP response assertions#3

Merged
nfisher merged 5 commits into
mainfrom
codex/implement-fluent-response-assertion-type
Jun 16, 2026
Merged

Add fluent HTTP response assertions#3
nfisher merged 5 commits into
mainfrom
codex/implement-fluent-response-assertion-type

Conversation

@nfisher

@nfisher nfisher commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a fluent API for making assertions against *http.Response values to improve ergonomics and chaining while preserving backwards compatibility with existing package-level functions.
  • Allow callers to use a Resp wrapper for method-style assertions and ensure graceful behavior for nil receivers.

Description

  • Add Response(resp *http.Response) *Resp and the Resp wrapper type with an actual *http.Response field to hammy/httpassert/httpassert.go.
  • Implement fluent methods Status, StatusInRange, Header, HeaderContains, BodyEqual, BodyContains, and BodyMatchesRegexp on *Resp and delegate the existing package-level functions to these methods for compatibility.
  • Add a response() helper on *Resp to handle nil-receiver cases safely, and reuse the existing readBody helper to preserve body restoration behavior.
  • Add tests in hammy/httpassert/httpassert_test.go that cover fluent success scenarios and nil-receiver handling for *Resp.

Testing

  • Ran go test ./hammy/httpassert and the package tests passed successfully.
  • Ran timeout 60s go test ./... and the full test suite completed successfully (all automated tests passed).

Codex Task

@nfisher nfisher merged commit 8a072a9 into main Jun 16, 2026
1 check passed
@nfisher nfisher deleted the codex/implement-fluent-response-assertion-type branch June 16, 2026 21:44
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