Giter Club home page Giter Club logo

cdc-with-pact's Introduction

cdc-with-pact

Code for "Consumer Driven Contracts with Pact" talk

How to spin up Pact Broker

Taken from: https://github.com/DiUS/pact_broker-docker/blob/master/POSTGRESQL.md


Start the docker machine:

docker-machine start default
eval $(docker-machine env default)

Create the Postgres container:

docker run --name pactbroker-db -e POSTGRES_PASSWORD=ThePostgresPassword -e POSTGRES_USER=admin -e PGDATA=/var/lib/postgresql/data/pgdata -v /var/lib/postgresql/data:/var/lib/postgresql/data -d postgres

Or start it:

docker start pactbroker-db

Access Postgres CLI:

docker run -it --link pactbroker-db:postgres --rm postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U admin'

Create the DB user:

CREATE USER pactbrokeruser WITH PASSWORD 'TheUserPassword';
CREATE DATABASE pactbroker WITH OWNER pactbrokeruser;
GRANT ALL PRIVILEGES ON DATABASE pactbroker TO pactbrokeruser;

Create the Pact Broker container:

docker run --name pactbroker --link pactbroker-db:postgres -e PACT_BROKER_DATABASE_USERNAME=pactbrokeruser -e PACT_BROKER_DATABASE_PASSWORD=TheUserPassword -e PACT_BROKER_DATABASE_HOST=postgres -e PACT_BROKER_DATABASE_NAME=pactbroker -d  -p 9292:9292 pactfoundation/pact-broker

Or start it:

docker start pactbroker

Contracts

frontend - flights

When available:

Request: GET /flights/{departure}/{arrival}/?date={date}

Response: 200 status with body:

{
  "flights": [
    {
      "id": "47e2f0e6-a848-48c8-b1ab-e3dd80a80829",
      "departure": {
        "time": "2019-06-16T18:00:00.000Z",
        "airport": "MXP"
      },
      "arrival": {
        "time": "2019-06-16T20:00:00.000Z",
        "airport": "STN"
      },
      "price": {
        "amount": 50,
        "currency": "EUR"
      }
    }
  ]
}

When not available:

Request: GET /flights/{departure}/{arrival}/?date={date}

Response: 404 with empty body

cdc-with-pact's People

Contributors

gdipaolantonio avatar

Stargazers

Emanuele 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.