Skip to content

Introduce constructor-style HTTP assertion wrappers and alias methods; update docs and tests#13

Merged
nfisher merged 1 commit into
mainfrom
codex/review-method-names-for-consistency
Jun 22, 2026
Merged

Introduce constructor-style HTTP assertion wrappers and alias methods; update docs and tests#13
nfisher merged 1 commit into
mainfrom
codex/review-method-names-for-consistency

Conversation

@nfisher

@nfisher nfisher commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a constructor-style API for HTTP assertions so actual HTTP values live in assertion structs and methods remain chainable and backward-compatible.
  • Add clearer, more descriptive method names (aliases) to improve ergonomics when migrating to constructor-style and to support JSON/YAML constructor-style refactors.

Description

  • Add constructor wrappers and alias methods in hammy/httpassert (Response, Request, Recorder) and implement aliases such as HasStatus, HasStatusInRange, HeaderEqualTo, HasHeader, HasHeaderContaining, BodyEqualTo, HasBodyContaining, BodyMatches, HasMethod, HasPath, URLEqualTo, HasHost, HasQueryParam, and others as thin wrappers over existing methods.
  • Update request/recorder/response implementations (request.go, recorder.go, httpassert.go) to include the alias methods while preserving original behavior.
  • Update the README to document the constructor-style usage and prefer the wrapper-based examples, and modify example_test.go and other tests to use the new API names.
  • Adjust body-related tests to explicitly verify that request/response bodies are restored after reads instead of chaining assertions that could consume bodies, and add new unit tests verifying each alias method.

Testing

  • Ran the updated unit tests for the HTTP assertion package with go test ./hammy/httpassert -v and the repository tests with go test ./..., and all tests succeeded.
  • Added and executed alias-specific tests (e.g. Test_Response_HasStatus_alias_success, Test_Request_HasMethod_alias_success, Test_Recorder_BodyEqualTo_alias_success), which passed.

Codex Task

@nfisher nfisher merged commit 9d87da6 into main Jun 22, 2026
1 check passed
@nfisher nfisher deleted the codex/review-method-names-for-consistency branch June 22, 2026 13:56
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