feat: fix and extend working with GET, add accept headers#8
Merged
Conversation
There was a problem hiding this comment.
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, andExpectation.Requestfromstringto*stringwithomitemptytags. - Added GET query-parameter matching by encoding
r.URL.Query()for matching. - Added “smart”
Content-Typebehavior 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.