Skip to content

feat: fix and extend working with GET, add accept headers#8

Merged
andboson merged 2 commits into
mainfrom
andboson/fix-get-request-headers
Feb 7, 2026
Merged

feat: fix and extend working with GET, add accept headers#8
andboson merged 2 commits into
mainfrom
andboson/fix-get-request-headers

Conversation

@andboson

@andboson andboson commented Feb 7, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI 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.

Pull request overview

This PR updates the mock server’s request-matching model to support optional matching fields, extends GET matching to incorporate query parameters, and adds a defaulting behavior for response Content-Type based on the request’s Accept header.

Changes:

  • Switched Expectation.Method, Expectation.Path, and Expectation.Request from string to *string with omitempty tags.
  • Added GET query-parameter matching by encoding r.URL.Query() for matching.
  • Added “smart” Content-Type behavior when no response headers are provided, and updated docs/tests accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
internal/models/expectation.go Makes matching fields optional and adds GET query normalization logic for request matching.
internal/services/server/mocks_handler.go Uses query encoding for GET matching and derives response Content-Type from request Accept in some cases.
internal/services/server/mocks_handler_test.go Updates expectations to pointer fields and adds GET query matching test cases.
internal/services/server/server_test.go Updates server tests for pointer-based Expectation fields.
internal/services/server/expectation_handler_test.go Updates assertion to dereference pointer Path.
internal/models/expectation_test.go Updates model tests for pointer fields and adds GET query matching scenarios.
internal/config/config_test.go Updates config tests to handle pointer fields after unmarshalling.
README.md Documents GET query matching and the new Content-Type behavior.

Comment thread internal/models/expectation.go
Comment thread internal/models/expectation.go
Comment thread internal/models/expectation.go
Comment thread internal/models/expectation.go
Comment thread internal/services/server/mocks_handler.go
Comment thread internal/models/expectation_test.go
Comment thread internal/services/server/mocks_handler.go
Comment thread internal/models/expectation.go
Comment thread internal/services/server/expectation_handler_test.go
Comment thread README.md
@andboson andboson merged commit 4067729 into main Feb 7, 2026
1 check passed
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