Skip to content

Refactor httpassert API to fluent Response wrapper and update tests/examples#9

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

Refactor httpassert API to fluent Response wrapper and update tests/examples#9
nfisher merged 2 commits into
mainfrom
codex/implement-fluent-response-assertion-type-5tr316

Conversation

@nfisher

@nfisher nfisher commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a more ergonomic, chainable API for HTTP assertions by moving from standalone functions to a Response wrapper with methods.
  • Improve nil-safety for receiver usage and streamline example/test usage to the new fluent API.

Description

  • Introduce Resp type and Response(resp *http.Response) *Resp constructor and implement methods Status, StatusInRange, Header, HeaderContains, BodyEqual, BodyContains, and BodyMatchesRegexp on it.
  • Add a nil-safe helper response() on Resp so method calls on a nil receiver return appropriate assertion failures.
  • Update readBody to be reused by the new methods without behavioral changes.
  • Update examples in example_test.go and all tests in httpassert_test.go to use the new httpassert.Response(...).<Method> form and rename example functions accordingly.
  • Replace the old requireFailure helper with assertions via eye.Spy in tests and add Test_Response_methods_failure_nil_receiver to verify nil-receiver behavior.

Testing

  • Ran package tests with go test ./hammy/httpassert and go test ./... and the test suite succeeded.
  • Verified the new Test_Response_methods_failure_nil_receiver passes and failure cases are asserted via eye.Spy as expected.
  • Examples output updated and validated via the example tests and they succeeded.

Codex Task

@nfisher nfisher merged commit 8959f85 into main Jun 16, 2026
1 check passed
@nfisher nfisher deleted the codex/implement-fluent-response-assertion-type-5tr316 branch June 16, 2026 19:38
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