For header, see this thread
# libpact_ffi-users
t
For header, see this thread
FFI call:
Copy code
pactffi_with_header_v2($interactionId, $ffi->InteractionPart_Response, 'X-IMPROVED', 0, '{"value":["like","regex","values","arrayContaining"],"pact:matcher:type":"values"}');
Trimmed pact file:
Copy code
{
  "consumer": {
    "name": "matchersConsumer"
  },
  "interactions": [
    {
      "description": "A get request to /matchers",
      "request": {},
      "response": {
        "body": {},
        "headers": {
          "X-IMPROVED": [
            "like",
            "regex",
            "values",
            "arrayContaining"
          ]
        },
        "matchingRules": {
          "header": {
            "$['X-IMPROVED']": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "values"
                }
              ]
            }
          }
        },
        "status": 200
      },
      "transport": "http",
      "type": "Synchronous/HTTP"
    }
  ],
  "metadata": {
    "pactSpecification": {
      "version": "4.0"
    }
  },
  "provider": {
    "name": "matchersProvider"
  }
}
Provider's response header:
Copy code
X-IMPROVED: regex, like, values, arrayContaining
Weird message from provider's verifier:
Copy code
Failures:

1) Verifying a pact between matchersConsumer and matchersProvider Given Get Matchers - A get request to /matchers
    1.1) includes header 'X-IMPROVED' with value 'like'
           Expected header 'X-IMPROVED' to have value 'like' but was 'like'
           Expected header 'X-IMPROVED' to have value 'regex' but was 'regex'
           Expected header 'X-IMPROVED' to have value 'values' but was 'values'
           Expected header 'X-IMPROVED' to have value 'arrayContaining' but was 'arrayContaining'
r
What are you trying to achieve here? That any of the provided values must be present, but in any order?
t
yes, but let ignore the order for now. I provided the values exactly as expected, in the same order, why I still see that error? Plus, the error is trying to say that 2 exact same string are not equals? e.g.
'like' is not equals to 'like'
?
r
That is really odd
I have never tested
"match": "values"
with headers. It doesn't make much sense using that, as it sets up a type matcher, and headers are all the same type (strings)
A regex matcher makes more sense
But it does seem to be a bug
t
If we are allowed to use matchers like
values
or
arrayContaining
for headers, then I will report this bug. If we are NOT allowed, then I think we need a way to prevent this from happening, and show some other errors instead. btw, I will report the bug for now.