-
Notifications
You must be signed in to change notification settings - Fork 46
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
Validate example values for eachLike
, eachKey
, eachValue
#303
Comments
Not sure I really understand, but what I assume is happening: You set up a type matcher, with five examples, the first one has fields for "father" and "mother" while the other four do not. This will not fail validation, because the other four values will be matched without the definition of those fields, so will ignore them. I.e., this is setting up a template with five values, and those will be be applied to the actual five values, while the example that does fail has a template of one value, and that gets applied to all values. So is this issue asking to reject any configuration where there is more than one example? |
yes
It was fine.
I'm not clear about this one yet.
no, this issue is not about rejecting if there are more than 1 example. This issue is about rejecting if other 4 examples are incompatible with the first example. The first example defined |
I'll try to explain what is going on, as this is not so much a bug as a deficiency in the FFI interface. By default, when you say However, when you use However, the issue is the eachLike matcher has a dual purpose. It defines a template, but also creates the examples to use in the consumer test. I.e., |
Because example values are not validated against matchers, I can define consumer test like this:
Consumer test (with invalid example value)
NOTE:
user
is valid example value, butfather
,mother
,child
andspouse
are invalid, because they are missing "father" and "mother" fields. The field "birthday" probably also has the same problem, but let ignore it for now.Run this test and I got this pact file:
Pact (with invalid example value)
pact-with-invalid-example-values.json.txt
Provider response data like this:
Provider response body
Provider verification passed with this log (it should failed instead):
Provider verification log
provider verification log
Now removed all invalid example values from consumer test:
Consumer test (without invalid example values)
New pact generated (exactly the same, but without invalid example values):
Pact (without invalid example values)
pact-without-invalid-example-values.json.txt
Provider verification will failed as expected:
Provider verification log: expected
Link to Slack discussion https://pact-foundation.slack.com/archives/C9VBGLUM9/p1690472580471449
The text was updated successfully, but these errors were encountered: