Skip to content

Instantly share code, notes, and snippets.

@richard-reece
Last active July 31, 2018 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richard-reece/85d58d296aa8e4806bd59496a39780d1 to your computer and use it in GitHub Desktop.
Save richard-reece/85d58d296aa8e4806bd59496a39780d1 to your computer and use it in GitHub Desktop.
pact example
Our pact:
{
"description": "a request for the flags of a product",
"request": {
"method": "POST",
"path": "/product-services/products/pricing-flags/retrieve",
"body": "[1400200]",
"headers": {
"Content-Type": "application/json"
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": [
{
"productNumber": "1400200",
"allowZeroCost": false,
"allowZeroPrice": false
}
]
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
Results in this failure:
Verifying a pact between PriceServicePython and ProductService
a request for the flags of a product
2018-07-31 15:43:06.518 INFO 29192 --- [ XNIO-2 task-24] a.c.r.r.c.f.CorrelationIdHeaderFilter : No correlationId found in Header Correlation-Id for request /product-services/products/pricing-flags/retrieve. Generated : 516935b5-2e72-48d5-a358-b6fcc769f0b0
2018-07-31 15:43:06.536 INFO 29192 --- [ XNIO-2 task-24] a.c.r.r.c.f.CorrelationIdHeaderFilter : Remove correlationId : 516935b5-2e72-48d5-a358-b6fcc769f0b0
returns a response which
has status code 200 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (FAILED)
Failures:
0) a request for the flags of a product returns a response which has a matching body
$.0.allowZeroPrice -> Expected false but received true
This is with:
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-maven_2.12</artifactId>
<version>3.5.16</version>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment