-
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
Support composing matching rules in FFI #399
Comments
The work required for this should be partially covered by #383. I had to implement that to allow low-level JSON matching rules to be given straight to the FFI, because I found myself rewriting a matching rule parser in Python. The FFI is the low-level implementation which will take the bare matching rule JSON, and the downstream libraries would likely need to implement a high level abstraction to help build these matching rules in a manner which makes most sense to each language. |
Nice!
Yes, and we should probably update the compatibility suite also if that's not already covered. |
Well, I added this because of the compatibility suite. I found myself implementing a parser for the matching rules to convert them into the other JSON format as described in integrationJson. This in itself begs the questions as to why we even had these two different formats, though I am sure there's a good reason. |
Hi. I see that issue closed but maybe can you provide the code example how to use this new feature?
|
This has been implemented in the Rust core, but still needs work to use it in Pact-JS |
Created pact-foundation/pact-js#1203 to track the Pact JS request @sergewar |
From the original request
Would we also want to support the
DslPart body = new PactDslJsonBody()
.numberValue("valueA", 100)
.and("valueB","AB", PM.includesStr("A"), PM.includesStr("B")) // Must match both matching rules
.or("valueC", null, PM.date(), PM.nullValue()) // will match either a valid date or a null value |
We want to discourage using OR as it can lead to situations where not all variations are covered in the Pact tests. |
Pact JVM supports combining matching rules using the
AND
logical expression.It is currently not possible to do this via the FFI (e.g. using https://docs.pact.io/implementation_guides/rust/pact_ffi/integrationjson as a guide).
The matching definition expressions do support nesting, however they are not supported via the FFI in the integration JSON.
There are two options to support this:
Ideally, a method that allows the most flexible
Example
From a request in slack.
How might you write a matcher to check both the keys and values and the same time (use
eachKeyMatches
andeachValueMatches
simultaneously):The text was updated successfully, but these errors were encountered: