Coder Social home page Coder Social logo

pact-example's Introduction

Pact example

Requirements

Run the pact-broker

  • Go to pact-broker folder

  • Create broker.env and database.env files based on sample files in the same folder. Have in mind that the same values should be applied to both files or the app won't connect with the database

  • In order to use https you have to add your ssl certificate, generate pact_cert.pem and pact_cert.key files and push them into packages/pact-broker/ssl/cert folder. Uncomment the SSL section of Nginx Configuration file and set your desired configuration, lines 16 and 17, with your custom certificate paths. Use the following command to generate the certificates.

    openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout pact_cert.key -out pact_cert.pem
  • Run docker-compose up -d

  • Use your browser to open http://localhost or https://localhost if ssl is configured correctly

Javascript


Javascript set up

  1. Go to javascript folder

  2. Install dependencies with yarn

    cd javascript
    yarn
  3. Run pact tests ⤵️

Running Pact tests

  • In the javascript directory, run yarn pact. It will run the pact tests in each project and will generate the pacts inside each package within the pacts folder. yarn pact:publish will publish the pact results of the consumers. yarn pact:verify will verify all existing published pacts by each respective provider.
  • You can also run manually each pact test or publishing with the following commands:
    • yarn pact:hachebo: hachebo pact testing and generate pacts
    • yarn pact:hachebo:publish: hachebo pact publish results
    • yarn pact:neflis: neflis pact testing and generate pacts
    • yarn pact:neflis:publish: neflis pact publish results
    • yarn pact:tv-shows: tv shows pact testing and generate pacts
    • yarn pact:tv-shows:publish: tv shows pact publish results
    • yarn pact:tv-shows:verify: tv shows verify pacts

Python


Python set up

cd pact-example/python
python3 -m venv venv
source ./venv/bin/activate
pip install .

Start local apps

Start duration-provider

cd duration_provider
uvicorn main:app --reload --port 9000

Start movies-api

cd movies-api
uvicorn main:app --reload --port 9001

Start all servers in background

make servers-start

Shutdown servers

make servers-shutdown

Pacts

Generate movies-api pacts

make movies-api-generate

Publish movies-api pacts

make movies-api-publish

Verify movies-api pacts

make movies-api-verify

Verify duration-provider pacts

make duration-provider-verify

Schemas


Regarding consumer schemas information, check this

pact-example's People

Contributors

sauldeleon avatar miguelcatalan avatar valeriocos avatar

Stargazers

Javier Saez avatar Alvaro del Castillo avatar Borja González avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar Javier Saez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.