Example Consumer

Source Code

https://github.com/pactflow/example-consumer-golang

badge__3_.svg

pactflow--example--provider--golang_pact-verified-brightgreen.svg: https://test.pactflow.io/pacts/provider/pactflow-example-provider-golang/consumer/pactflow-example-consumer-golang/latest (latest pact)

pact_not_found-unknown-lightgrey.svg: https://test.pactflow.io/pacts/provider/pactflow-example-provider-golang/consumer/pactflow-example-consumer-golang/latest/prod (prod/prod pact)

This is an example of a Golang consumer using Pact to create a consumer driven contract and sharing it via API Hub for Contract Testing.

It is using a public tenant on API Hub for Contract Testing, which you can access here using the credentials dXfltyFMgNOFZAxr8io9wJ37iUpY42M/O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1. The latest version of the Example Consumer/Example Provider pact is published here.

The project uses a Makefile to simulate a very simple build pipeline with two stages - test and deploy.

  • Test

    • Run tests (including the pact tests that generate the contract)

    • Publish pacts, tagging the consumer version with the name of the current branch

    • Check if we are safe to deploy to prod (ie. has the pact content been successfully verified)

  • Deploy (only from master)

    • Deploy app (just pretend for the purposes of this example!)

    • Tag the deployed consumer version as 'prod'

Usage

See the API Hub for Contract Testing CI/CD Workshop for further details.

Publication date: