-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
"eachKeyLike" verification changing behaviour between PACT Provider versions #1789
Comments
Can you provide your Pact file and debug logs? |
Hi - see below: Debug logs from the verification step in our pipeline:
And the PACT uploaded to the broker:
Cheers |
4.1.x doesn't properly support the each-key matcher. Either upgrade your consumer to use 4.6.x and re-run the test. If you can't upgrade to a 4.6 version, you can upgrade the consumer side to 4.1.42 and then set FeatureToggles.toggleFeature(Feature.UseMatchValuesMatcher, true);
val providerResponseBody = PactDslJsonBody()
.eachKeyLike("abcde")
.stringType("name", "productSet")
.stringType("value", setId)
.closeObject() in the consumer test. Note that this will generate a Pact file that can't be verified with a 4.1 version, but will pass ok with 4.6. You should use the latest 4.6 version which is currently 4.6.9. |
We seem to have had a scenario where updating our provider side library is causing a failing in verification on an eachKeyLike matcher.
The endpoint
Example response JSON:
...where there will be any number of keys like
abcde
, but with different values based on the body sent to the endpoint. The structure of the object hanging off the key will always be consistent, with a name and a value.i.e. this would also be a valid response
Consumer Matching Code:
On the consumer side, the team have been using the
eachKeyLike
matcher to account for these behaviours:With version
"au.com.dius:pact-jvm-consumer-junit:4.0.10"
.On the provider side, when using
"au.com.dius.pact.provider:junit5:4.1.42"
we see the contract test passing.However, when attempting to migrate the provider side to
"au.com.dius.pact.provider:junit5:4.6.0"
we see the following failure:So, from my reading, it's now complaining that in the response it got back from the endpoint during the verification, it received the
pj41
key, not theabcde
key.Are you able to explain why this is happening? It looks as though the later provider side version is doing some kind of value matching in the verification now, whereas clearly in the previous version we used it did not.
The PACT is generated from the consumer side to the designated Spec, and that code has not changed, so our assumption was updating the Provider side library should not cause this kind of issue?
Thanks
The text was updated successfully, but these errors were encountered: