Skip to content

This is a python application for an explanation of Contract Testing based on Pact.

Notifications You must be signed in to change notification settings

pperzyna/pact-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PACT Example Application

This is a python application for explanation of Contract Testing based on Pact.

Getting Started

Build Status

Prerequisites

What kind of things you need to install on your local computer to start:

Installing

Run local stack via docker-compose

docker-compose up --build

Provider

This is a sample Flask application that expose endpoints with REST standard.

endpoint method payload description
/user GET show all users
/user POST {'name','description'} create user
/user/:id GET show user with :id
/user/:id DELETE delete user with :id

Consumer

This is a sample python script, which consume the information from provider.

variable default description
API_PROVIDER_URL http://localhost:5000 URL of provider app

Pact

Sample Contract (Pact): consumer/src/pact/Consumer-Provider-pact.json.

GENERATE

Run the tests on the consumer application. Check out the entrypoint.sh file.

PUBLISH

docker run -v $PWD/consumer/src/pact/:/usr/src/app/pact pactfoundation/pact-cli publish /usr/src/app/pact/ --consumer-app-version $GIT_COMMIT --tag=$GIT_BRANCH

VERIFY

docker run pactfoundation/pact-cli verify --pact-broker-base-url=${PACT_BROKER_URL} --provider-base-url=${PROVIDER_URL} --provider-states-setup-url=${PROVIDER_URL}/_pact/provider_state --provider=Provider --provider-app-version=${GIT_COMMIT} --publish-verification-results --verbose

CAN-I-DEPLOY

docker run pactfoundation/pact-cli broker can-i-deploy --broker-base-url=${PACT_BROKER_URL} -a Provider -e $GIT_COMMIT --to $GIT_BRANCH

CREATE-VERSION-TAG

docker run pactfoundation/pact-cli broker create-version-tag -a Consumer -e $GIT_COMMIT -t $GIT_BRANCH

About

This is a python application for an explanation of Contract Testing based on Pact.

Topics

Resources

Stars

Watchers

Forks