Provider states set up the right test data on the provider before each request. can-i-deploy checks whether a version is safe to release. Together they make contract tests a reliable gate before deploy.
Provider states. A pact is the contract file the consumer writes. Each interaction in a pact carries a provider state, such as "user 42 exists" or "order 7 is cancelled". During verification, Pact replays the consumer's requests against the real provider. Before each request, a handler in the provider test puts the provider in that state. It usually inserts data or stubs the provider's own dependencies. Why does this matter? Without states, verification depends on whatever data happens to be in the database.
can-i-deploy. The Pact Broker is a server that stores pacts and results. It records:
- which consumer and provider versions have verified against each other
- which versions are deployed in which environment
can-i-deploy asks the broker: "Is this version compatible with the versions already in the target environment?" If not, it fails the pipeline.
In short: you know a change is safe without starting every service together.
- Provider states describe what must be true before an interaction runs.
- State handlers set up data before each replayed request.
- The broker tracks verification results and which versions are deployed where.
can-i-deployblocks a release if the versions are not compatible.
- Pact docs (https://docs.pact.io/)docs.pact.io