And the pack successfully published to the broker. Let's go back and review here the contract. This is the contract, the PACT, okay? A few seconds ago. If you click on view PACT interactions, we can view this list of directions would describe how the consumer expects the provider to behave. Okay, with status 200, test json to one, test json two, et cetera.
Now, the next steps are from the provider side, from the utility, that they should verify the contract. How can they do this? The simplest way is to use a local file, that it means that if you don't have a broker, then the consumer write the test and they copy the contract to a share file system. But if you have a PACT broker, like we did in our example, you don't pull the PACT file from the file system, but from the broker using a URL.
So you create a webhook. In order to create a webhook, you can use either the PACT CLI tool or the PACT broker UI. So if I use the PACT CLI tool, I can go here and create a test, a sample test, I bought the library, I have the provider name, the provider base URL, the PACT broker URL, and I use the method verify provider. And I say publish verification results true. To verify a contract is a half story. You should publish the results back to the broker. You can use the docker command, verify set the way again, you have to you say give the broker token, the public verification results, et cetera. So if you run this, it's going to reject or verify the contract. Okay. But of course, you can use the PACT broker UI. If you go at settings, at the web hooks, you can create here a web hook. That's going to be triggered by your CI-CD workflow. And since I said CI-CD workflow, I'm going to show you example of CI workflow of consumer. So here's the start, the checkout, then been installed, you run the consumer test with Cypress, you publish the contract, the packed file to the pack broker, then the CI workflow provider is triggered by web hook in order to verify the pack, the contract, and sends back the results with a new web hook. And then, I can use the, can I deploy a command from the pack CLI tool that asks if we can deploy in a particular environment. So, this will be an example of, of a CI workflow of consumer.
So, summary. Codetests ensure seamless communication between microservices reducing the risk of errors and breakdowns. Cypress MOCs can be transformed into pack consumer contracts by using the correct adapter and please use PackBroker to manage your contracts and your CI, CD workflow. I hope you found useful the Cypress Codetests for your software journey from good to great.
Comments