-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return most specific match when multiple matches are found #138
Comments
Can you confirm the version you are using? I can't replicate this, it works correctly for me. With a Pact file with those 3 interactions, I get:
|
Hi @rholshausen, thanks for the response. I've just created https://github.com/jstockwin/pact-issue-demo to demonstrate this issue. If I The I probably should have mentioned that I'm doing this through the Overriding the command there to run the |
Ah! Yeah, that would need to be addressed with the pact-cli project. It is a different implementation. |
I'll move this issue to that project |
I have a contract for
/endpoint
, which returns a list of items. It's possible to apply filters in query params, e.g./endpoint?type=foo
, but this is optional.Let's say I have three interactions:
/endpoint
(no query)/endpoint
, query:type=foo
/endpoint
, query:type=bar
When running the stub server, if I make a request for
/endpoint?type=foo
the stub service matches both (1) and (2). It (correctly) does not match (3). It throws a warning about multiple matches, and saysWARN -- : Sorting responses by response status and returning first.
I understand that we're trying to be permissive here - i.e. in the case that interaction (2) didn't exist, I'd see why you'd want to return (1) instead of 404/500. However, in the case that one match is more specific, it'd be nice to return this.
In my case, I'm getting the response from (1), which is returning all items instead of only items with type=foo. Then when trying to use the stub-service for integration testing, the filtering appears to not work.
I have tried explicitly setting
query=""
when running my unit tests (to make 1 more explicit), but this does not get saved into the contract file.My current workaround is to put
xxxx
into my test name for the one with no query params. This means the test runs last, and so is the last entry in the contract json file, meaning the more specific one happens to get picked first.The text was updated successfully, but these errors were encountered: