pact-go | Pact is a contract testing framework | REST library
kandi X-RAY | pact-go Summary
kandi X-RAY | pact-go Summary
From the Pact website:. The Pact family of frameworks provide support for Consumer Driven Contracts testing. A Contract is a collection of agreements between a client (Consumer) and an API (Provider) that describes the interactions that can take place between them. Consumer Driven Contracts is a pattern that drives the development of the Provider from its Consumers point of view. Pact is a testing tool that guarantees those Contracts are satisfied. Read Getting started with Pact for more information for beginners.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pact-go
pact-go Key Features
pact-go Examples and Code Snippets
Community Discussions
Trending Discussions on pact-go
QUESTION
I'm using the Pact Go implementation to try out contract testing. I've made a provider test that isn't working because I need to mock out my service's request to Twilio.
I've made one Pact object for the contract between my consumer and this provider, and then another one called twilioPact for the contract between my provider and Twilio. I've added an interaction for the POST to the Twilio endpoint, but in the pact.log I'm not seeing it get registered. My test is making the request correctly, but there's no interaction registered for it so I get the 500 error from the mock server.
Does anyone have any experience using Pact with a 'provider' that is also a 'consumer'?
EDIT: After talking with Matt Fellows I was informed that I was using Pact incorrectly, and shouldn't be trying to run a mock service while running a provider verification. I had suspected as much, but none of the examples I had seen were for a provider that had a dependency. I was able to get my provider verification to work by writing a consumer test and passing the generated pact file to the pact-stub-service to act as the mock to Twilio.
...ANSWER
Answered 2018-Mar-15 at 10:39Here's a few things to consider:
- It's better to have two separate contract tests between your
client
<->Twilio Adapter
, andTwilio Adapter <-> Twilio
. It's possible to do what you're doing, but it will make the tests more complicated and probably harder to read/comprehend. Testing them in isolation gives you much more control. - When doing the former contract test, rather then daisy chain another pact mock service for your Twilio Adapter's (Provider) dependency (Twilio), you're best using standard mock/stub tooling for this job - either code based mocks/doubles, service doubles (e.g. Mountebank) or the stub server shipped with Pact [1]. Don't forget you will get to validate these assumptions with the other contract test, so you're safe to do this.
- It's possible that because you have two mock servers running (one to mock the Twilio Adapter and another to mock Twilio) that your requests are being sent to the same mock service, and getting all tangled up
[1] Here is are the list of binaries etc. that are shipped with pact-go:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pact-go
Download the latest CLI tools of the standalone tools and ensure the binaries are on your PATH:
Unzip the package into a known location, and ensuring the pact and other binaries in the bin directory are on the PATH.
Run go get github.com/pact-foundation/pact-go@v1 to install the source packages
The following will install pact binaries into /opt/pact/bin:. NOTE: the above script installs the latest standalone tools at the time it was ran. It is recommended you pin the installation to a specific version of a release so that you may control the upgrade cycle.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page