Alasdair
07/25/2022, 11:00 AMMatt (pactflow.io / pact-js / pact-go)
Slackbot
07/25/2022, 12:48 PMMatt (pactflow.io / pact-js / pact-go)
Alasdair
07/25/2022, 1:21 PMTimothy Jones
07/26/2022, 12:32 AM"AUTH_TOKEN"
Timothy Jones
07/26/2022, 12:32 AMAlasdair
07/26/2022, 10:08 AMMatt (pactflow.io / pact-js / pact-go)
Timothy Jones
07/27/2022, 1:07 AMTimothy Jones
07/27/2022, 1:07 AMTimothy Jones
07/27/2022, 1:11 AMreceive request
-> validate auth token
-> unmarshal request
-> do something with it
-> marshal response
What I do is:
real receive request
-> stub that checks the token is "AUTH_TOKEN"
-> real unmarshal request
-> real do something with it
-> real marshal response
Matt (pactflow.io / pact-js / pact-go)
To be clear, I’m not proposing stubbing the whole endpoint, just the auth validation. I don’t consider the auth token to be part of the contractAh, that’s a good point. I didn’t consider that might be how the suggestion was interpreted
Timothy Jones
07/27/2022, 1:12 AMTimothy Jones
07/27/2022, 1:18 AMTimothy Jones
07/27/2022, 1:18 AMMatt (pactflow.io / pact-js / pact-go)
After looking at the response from Timothy Jones - what does he mean by “Unmarshal / Marshal”? is he suggesting to compare a real request response and a pact contract manually? is there a better example you can share or create? ThanksWhat Tim is saying is that he just stubs the auth part of your provider code base, so when the Pact verifier sends the request to the Provider, only the auth is stubbed out. The rest of the interaction with your Provider talks to the real controllers, models etc. You will also want to stub out any 3rd party systems so that you have a level of determinism and speed in your tests. This means you have a higher level of confidence in your Pact tests because they actually test a broader set of layers and act as a good form of integration test. eg. https://docs.pact.io/provider#stub-calls-to-downstream-systems