From 25f0562e6413818d4e36af6f35f9f045fc1b41fc Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Tue, 15 Jun 2021 17:29:06 +1000 Subject: [PATCH] docs: clarify what a provider state is --- docs/consumer.md | 5 +++++ docs/provider.md | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/consumer.md b/docs/consumer.md index 0a6378166..7331002aa 100644 --- a/docs/consumer.md +++ b/docs/consumer.md @@ -185,6 +185,11 @@ Two builder methods exist for binary/file payloads: ### Managing Test Data (using Provider States) +Each interaction in a pact should be verified in isolation, with no context maintained from the previous interactions. Tests that depend on the outcome of previous tests are brittle and hard to manage. +Provider states is the feature that allows you to test a request that requires data to exist on the provider. + +Read more about [provider states](https://docs.pact.io/getting_started/provider_states/) + There are several ways to define a provider state: 1. Using the `Given` builder method passing in a plain string. diff --git a/docs/provider.md b/docs/provider.md index 983afbf42..98f4b5938 100644 --- a/docs/provider.md +++ b/docs/provider.md @@ -46,9 +46,14 @@ func TestV3HTTPProvider(t *testing.T) { } ``` -### Managing Data (Provider States) +### Managing Test Data (Provider States) -If you have defined any states (as denoted by a `Given()`) in your consumer tests, the `Verifier` can put the provider into the correct state prior to sending the actual request for validation. For example, the provider can use the state to mock away certain database queries. To support this, set up a `StateHandler` for each state using hooks on the `StateHandlers` property. Here is an example: +Each interaction in a pact should be verified in isolation, with no context maintained from the previous interactions. Tests that depend on the outcome of previous tests are brittle and hard to manage. +Provider states is the feature that allows you to test a request that requires data to exist on the provider. + +Read more about [provider states](https://docs.pact.io/getting_started/provider_states/). + +If you have defined any states (as denoted by a `Given()`) in your consumer tests, the `Verifier` can put the provider into the correct state prior to sending the actual request for validation. For example, the provider can use the state to mock away certain API endpoints or seed data into a database. To support this, you registar a `StateHandler` func for each state using hooks on the `StateHandlers` property. Here is an example: ```go pact.VerifyProvider(t, types.VerifyRequest{