https://pact.io logo
#pact-go
Title
# pact-go
a

Ancy Aziz

03/09/2022, 3:51 AM
I have a response body with contents like below, is there a way to match the values in Header using dsl.Match and just validate the type of the fields inside Body part using dsl.Like in pact.AddInteraction WillRespondWith section?
Copy code
[
    {
        "Body": {
             "environments": [
                               {
                                    "createdDate": "2020-05-20",
                                    "id": "abc",
                                    "name": "abc",
                                    "state": "YES",
                                    "tags": [],
                                    "status": false
                                }
                            ],
               "nPageKey": "aabbgggcc==",
               "pageSize": 1,
               "totalCount": 1
              },
        "Header": {
               "ResponseCode": 200,
               "Region": "xyz"
         }
     }
 ]
m

Matt (pactflow.io / pact-js / pact-go)

03/09/2022, 4:21 AM
You want to match exact values in the header, but types in the body?
I think so, you just need to not put matchers (via struct tags) on the things that should be exact matched
a

Ancy Aziz

03/09/2022, 4:48 AM
Thank you for the reply! Do you mean if I don't put pact:"example=value" on Struct, it will work using dsl.Match? sorry I am new to pact, so confirming.
m

Matt (pactflow.io / pact-js / pact-go)

03/09/2022, 5:10 AM
Yes it should just mean "match exact value"
If that doesn't work, you might need to use the standard matchers
a

Ancy Aziz

03/09/2022, 8:11 AM
thank you so much!
👍 1
2 Views