Skip to content

Commit

Permalink
feat(example): add better readme, cleanup linting for E2E example
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Jan 18, 2017
1 parent 491f641 commit 4a8e8cb
Show file tree
Hide file tree
Showing 10 changed files with 360 additions and 309 deletions.
170 changes: 0 additions & 170 deletions examples/e2e/.eslintrc.json

This file was deleted.

17 changes: 17 additions & 0 deletions examples/e2e/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rules:
indent:
- 2
- 2
quotes:
- 2
- single
linebreak-style:
- 2
- unix
semi:
- 2
- always
env:
es6: true
node: true
extends: 'eslint:recommended'
84 changes: 82 additions & 2 deletions examples/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ Using a simple animal dating API, we demonstrate the following Pact features:

This comprises a complete E2E example that can be used as a basis for projects.

<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->

- [The Example Project](#the-example-project)
- [Provider (Profile API)](#provider-profile-api)
- [Consumer (Matching API)](#consumer-matching-api)
- [Running the tests](#running-the-tests)
- [Running the API](#running-the-api)
- [Animal Profile API](#animal-profile-api)
- [GET /animals](#get-animals)
- [GET /animals/:id](#get-animalsid)
- [GET /animals/available](#get-animalsavailable)
- [POST /animals](#post-animals)
- [Matching service](#matching-service)
- [GET /suggestions/:id](#get-suggestionsid)
- [Viewing contracts with the Pact Broker](#viewing-contracts-with-the-pact-broker)

<!-- /TOC -->

## The Example Project

[Matching API] -> [Profile API]+\(DB\)
Expand All @@ -29,18 +47,80 @@ Given an animal profile, recommends a suitable partner based on similar interest
1. `npm test:publish` - Publish contracts to the broker
1. `npm test:provider` - Run provider tests

# Running the API
## Running the API

If you want to experiment with the API to get an understanding:

1. `npm run api` - Runs the both provider and consumer API

or individually :

1. `npm run provider` - Runs the provider API (animal service)
1. `npm run consumer` - Runs the consumer API (matching service)

### Animal Profile API

The APIs are described below, including a bunch of cURL statements to invoke them.
There is also a [Postman Collection](./pact-js-e2e.postman_collection).

#### GET /animals

```
curl -X GET "http://localhost:8081/animals"
```

#### GET /animals/:id

```
curl -X GET "http://localhost:8081/animals/1"
```

#### GET /animals/available

```
curl -X GET http://localhost:8081/animals/available
```

#### POST /animals

```
curl -X POST -H "Content-Type: application/json" -d '{
"first_name": "aoeu",
"last_name": "aoeu",
"age": 21,
"gender": "M",
"location": {
"description": "Melbourne Zoo",
"country": "Australia",
"post_code": 3000
},
"eligibility": {
"available": true,
"previously_married": false
},
"interests": [
"walks in the garden/meadow",
"munching on a paddock bomb",
"parkour"
]
}' "http://localhost:8081/animals"
```

### Matching service
#### GET /suggestions/:id

```
curl -X GET http://localhost:8080/suggestions/1
```

## Viewing contracts with the Pact Broker

A test [Pact Boker](https://github.com/bethesque/pact_broker) is running at https://test.pact.dius.com.au:

* Username: `dXfltyFMgNOFZAxr8io9wJ37iUpY42M`
* Password: `O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1`

Or use the API: `curl -v -u 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M:O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1' https://test.pact.dius.com.au`
Or use the API:

```curl -v -u 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M:O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1' https://test.pact.dius.com.au
```
Loading

0 comments on commit 4a8e8cb

Please sign in to comment.