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

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

03/19/2022, 5:08 AM
I'm not sure I understand sorry, you can definitely test the body shape in that JSON you shared. This looks like it's failing the verification though, which would indicate the request is not eliciting the response shape you're after.. Can you please share the req/res details your expecting, the consumer pact test and the provider verification output?
a

Ancy Aziz

03/21/2022, 12:33 AM
sorry for delayed response. My issue here is that when the RespCode is 200, I get an an array of "monitors" object, and when the RespCode is 404, I get a hash of "error", so it's not matching for cases with RespCode 404 with my Matcher code. I am trying to see if there is an option to match with both cases. Our internal provider is reading data from a third party and providing the response, that's why we are getting RespCode 200 and 404.
m

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

03/21/2022, 12:36 AM
You need to create two separate test cases - one for each of the
200
and
404
scenarios. You would then use a Provider State in the consumer test to control the desired outcome from the provider. Pact is not designed to be tested against a live system for this reason - it’s hard to control the state of the provider. You really should be running the provider in a controlled (unit test-like) environment, where you can manipulate external dependencies as needed
a

Ancy Aziz

03/21/2022, 3:16 AM
thank you so much for your quick response!! much appreciated.
👍 1
2 Views