Open creckord opened 1 week ago
👋🏾 Hey
There are eachKey and eachValue matching rules for dealing with maps/lists
Expressions can be composed
What expressions did you try with the following?
I also tried to write matchers at the "hashes" level:
entry("hashes", "atMost(2)") entry("hashes", "eachValue(...)")
Is it possible to create a minimal reproducible example either in this repo or a separate one. It would aid the core maintainer, and myself in trying to help you out.
An example from the protobuf plugin that may be useful
Here's a repro with a bunch of different attempts at writing matchers for bytes and maps of non-string values:
An example from the protobuf plugin that may be useful
That got me a little farther. I would never have gotten the bit with the pact:match
entry from pact-plugins docs. I updated my example repo.
That took care of the atMost(2)
expression, but lead to some new errors related to eachKey/eachValue
, which I think I did 1:1 as in the protobuf example.
The problem with matching on a bytes
value remains as well.
I have a field like this in my Avro schema, and I'm struggling with how to write a match expression for it:
My pact setup, written in Java, looks like this (following the example from the plugin docs):
I can see in the plugin code that for
bytes
fields something is supposed to happen with AvroStrings, but I couldn't make heads or tails of it wrt how to write the matcher for the map entries. I tried unsuccessfully:entry("sha-256", "00000000")
entry("sha-256", notEmpty('00000000'))
entry("sha-256", new byte[0])
entry("sha-256", ByteBuffer.wrap(new byte[0]))
All those failed with various type conversion/class cast errors.
I also tried to write matchers at the "hashes" level:
entry("hashes", "atMost(2)")
entry("hashes", "eachValue(...)")
But those failed, because the value for "hashes" was expected to be a Map, not a String.
Right now, the only way I could get it to run the pact successfully, was by providing an empty map as a value for "hashes".