Tien Vo
11/03/2023, 2:30 AMeachValue
matcher for query parameter. See this thread for more details:Tien Vo
11/03/2023, 2:30 AMregex
matcher with array of values to match multiple values for query parameter works fine. See this thread https://pact-foundation.slack.com/archives/C02BXLDJ7JR/p1698024666918839Tien Vo
11/03/2023, 2:31 AMregex
by eachValue
matcher, it doesn't work as I expected:Tien Vo
11/03/2023, 2:33 AM- 'locales[]' => [
- json_encode($this->matcher->regex(['en-US'], '^[a-z]{2}-[A-Z]{2}$')),
- ],
+ 'locales[]' => [
+ json_encode($this->matcher->eachValue(['en-US'], [$this->matcher->regex(null, '^[a-z]{2}-[A-Z]{2}$')])),
+ ],
Tien Vo
11/03/2023, 2:33 AMpactffi_with_query_parameter_v2($interactionId, 'locales[]', 0, '"{"rules":[{"regex":"^[a-z]{2}-[A-Z]{2}$","pact:matcher:type":"regex","pact:generator:type":"Regex"}],"value":["en-US"],"pact:matcher:type":"eachValue"}"');
Tien Vo
11/03/2023, 2:34 AMlocales[]=en-US&locales[]=en-AU
Tien Vo
11/03/2023, 2:34 AM2023-10-28T07:21:35.888456Z DEBUG tokio-runtime-worker pact_matching::matchers: String -> String: comparing 'en-US' to 'en-US' ==> false cascaded=false matcher=EachValue(MatchingRuleDefinition { value: "[\"en-US\"]", value_type: Unknown, rules: [Left(Regex("^[a-z]{2}-[A-Z]{2}$"))], generator: None })
2023-10-28T07:21:35.888506Z DEBUG tokio-runtime-worker pact_matching::matchers: String -> String: comparing '' to 'en-AU' ==> false cascaded=false matcher=EachValue(MatchingRuleDefinition { value: "[\"en-US\"]", value_type: Unknown, rules: [Left(Regex("^[a-z]{2}-[A-Z]{2}$"))], generator: None })
2023-10-28T07:21:35.888576Z DEBUG tokio-runtime-worker pact_matching: --> Mismatches: [QueryMismatch { parameter: "locales[]", expected: "en-US", actual: "en-US", mismatch: "Unable to match 'en-US' using EachValue(MatchingRuleDefinition { value: \"[\\\"en-US\\\"]\", value_type: Unknown, rules: [Left(Regex(\"^[a-z]{2}-[A-Z]{2}$\"))], generator: None })" }, QueryMismatch { parameter: "locales[]", expected: "", actual: "en-AU", mismatch: "Unable to match '' using EachValue(MatchingRuleDefinition { value: \"[\\\"en-US\\\"]\", value_type: Unknown, rules: [Left(Regex(\"^[a-z]{2}-[A-Z]{2}$\"))], generator: None })" }]
Tien Vo
11/03/2023, 3:05 AMrholshausen
11/10/2023, 12:15 AMEachValue
was written to support ignoring the keys in a map like structure in the body. Only really for JSON objects. It will probably not work with anything else.rholshausen
11/10/2023, 12:15 AMEachKey
is the same