John Williams
06/20/2022, 7:08 AMNon-Ruby applications
To allow the correct data to be set up before each interaction is replayed, you will need to create an HTTP endpoint (which may or may not actually be in the same application as your provider) that accepts a JSON document describing the state. The exact format of this document depends on whether you are using the JVM implementation, or one of the wrapped Ruby implementations (effectively everything that isn't JVM).
The endpoint should set up the given provider state for the given consumer synchronously, and return an error if the provider state is not recognised. Namespacing your provider states within each consumer will avoid clashes if more than one consumer defines the same provider state with different data.
See the pact-provider-verifier documentation for the exact details of implementing a provider-states-setup-url.
my devs are asking what difference in doing this than using a mock graphql server?Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Timothy Jones
06/20/2022, 7:33 AMTimothy Jones
06/20/2022, 7:34 AMTimothy Jones
06/20/2022, 7:34 AMJohn Williams
06/20/2022, 7:49 AMJohn Williams
06/20/2022, 7:52 AMTimothy Jones
06/20/2022, 7:53 AMTimothy Jones
06/20/2022, 7:53 AMJohn Williams
06/20/2022, 7:53 AMTimothy Jones
06/20/2022, 7:53 AMJohn Williams
06/20/2022, 7:54 AMJohn Williams
06/20/2022, 7:55 AMJohn Williams
06/20/2022, 7:55 AMTimothy Jones
06/20/2022, 7:55 AMTimothy Jones
06/20/2022, 7:57 AMThat data isnt in our monolith appilcationWhat do you mean by "isn't in the application"? If the consumer test is expecting a structure that isn't implemented, then verification will (correctly) fail. If you mean the monolith doesn't come with that data pre-setup, then yes - this is what the state change endpoints or functions are for
Timothy Jones
06/20/2022, 7:57 AMJohn Williams
06/20/2022, 7:57 AMJohn Williams
06/20/2022, 7:58 AMexport const MUTATION_RESPONSE = {
status: 200,
headers: {
"Content-Type": "application/json; charset=utf-8"
},
body: {
data: {
signUp: {
user: {
username: like("Alice"),
accounts: eachLike({
id: like(1),
uuid: like("0001")
})
}
}
}
}
}
John Williams
06/20/2022, 7:58 AMJohn Williams
06/20/2022, 7:58 AMJohn Williams
06/20/2022, 7:59 AMTimothy Jones
06/20/2022, 8:01 AMJohn Williams
06/20/2022, 8:02 AMTimothy Jones
06/20/2022, 8:02 AMTimothy Jones
06/20/2022, 8:02 AMJohn Williams
06/20/2022, 8:02 AMTimothy Jones
06/20/2022, 8:02 AMTimothy Jones
06/20/2022, 8:03 AMTimothy Jones
06/20/2022, 8:04 AMJohn Williams
06/20/2022, 8:04 AMJohn Williams
06/20/2022, 8:05 AMJohn Williams
06/20/2022, 8:05 AM"Has some animals": () => {
importData()
return Promise.resolve(`Animals added to the db`)
},
Timothy Jones
06/20/2022, 8:06 AMTimothy Jones
06/20/2022, 8:06 AMJohn Williams
06/20/2022, 8:06 AMTimothy Jones
06/20/2022, 8:06 AMTimothy Jones
06/20/2022, 8:06 AMJohn Williams
06/20/2022, 8:07 AMTimothy Jones
06/20/2022, 8:07 AMTimothy Jones
06/20/2022, 8:08 AMJohn Williams
06/20/2022, 8:08 AMJohn Williams
06/20/2022, 8:08 AMTimothy Jones
06/20/2022, 8:08 AMTimothy Jones
06/20/2022, 8:08 AMJohn Williams
06/20/2022, 8:10 AMTimothy Jones
06/20/2022, 8:10 AMTimothy Jones
06/20/2022, 8:10 AMJohn Williams
06/20/2022, 8:10 AMJohn Williams
06/20/2022, 8:10 AMTimothy Jones
06/20/2022, 8:26 AMTimothy Jones
06/20/2022, 8:27 AMJohn Williams
06/20/2022, 9:52 AMTimothy Jones
06/20/2022, 9:58 AMTimothy Jones
06/20/2022, 9:59 AMJohn Williams
06/20/2022, 10:05 AMFor deleteLink graphql mutation, the request param must contains the link id which we want to delete, this id can not be changed after consumer side generate the contract, in provider side, every time contract test running, it must provider a link with the same id.
So we can not create a new link with the same id using graphql mutation every time before running deleteLink test, it just can operate the database to prepare the data.
John Williams
06/20/2022, 10:07 AMyes, but the id in contract can not be changed in provider side, because pact thinks that if provider can modify the request of contract means that the contract is not trusted.
I meantioned that maybe setup a new link to delete but apparently the provider contract doesnt allow that?Timothy Jones
06/20/2022, 10:21 AMTimothy Jones
06/20/2022, 10:23 AMTimothy Jones
06/20/2022, 10:23 AMTimothy Jones
06/20/2022, 10:24 AMTimothy Jones
06/20/2022, 10:24 AMMatt (pactflow.io / pact-js / pact-go)
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 land you back in integration test hell, which is the nasty place you’re trying to escape by using pacts.
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
John Williams
06/20/2022, 11:01 PMMatt (pactflow.io / pact-js / pact-go)
Timothy Jones
06/20/2022, 11:41 PMJohn Williams
06/21/2022, 12:21 AMTimothy Jones
06/21/2022, 12:22 AMJohn Williams
06/21/2022, 12:22 AM