From 4a8e8cb7a917c23e98804ac1e74eddedf37efd8e Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Thu, 19 Jan 2017 08:01:48 +1100 Subject: [PATCH] feat(example): add better readme, cleanup linting for E2E example --- examples/e2e/.eslintrc.json | 170 -------------------- examples/e2e/.eslintrc.yml | 17 ++ examples/e2e/README.md | 84 +++++++++- examples/e2e/consumer.js | 118 +++++++------- examples/e2e/package.json | 7 +- examples/e2e/pact-js-e2e.postman_collection | 111 +++++++++++++ examples/e2e/provider.js | 72 +++++---- examples/e2e/repository.js | 30 ++-- examples/e2e/test/provider.spec.js | 54 ++++--- examples/e2e/test/publish.js | 6 +- 10 files changed, 360 insertions(+), 309 deletions(-) delete mode 100644 examples/e2e/.eslintrc.json create mode 100644 examples/e2e/.eslintrc.yml create mode 100644 examples/e2e/pact-js-e2e.postman_collection diff --git a/examples/e2e/.eslintrc.json b/examples/e2e/.eslintrc.json deleted file mode 100644 index 20749b93b..000000000 --- a/examples/e2e/.eslintrc.json +++ /dev/null @@ -1,170 +0,0 @@ -{ - "ecmaFeatures": { - "modules": true - }, - "env": { - "node": true, - "es6": true, - "mocha": true - }, - "globals": { - "ENV": true, - "browser": true - }, - "rules": { - "comma-dangle": 2, - "no-cond-assign": 2, - "no-console": 0, - "no-constant-condition": 2, - "no-control-regex": 2, - "no-debugger": 2, - "no-dupe-args": 2, - "no-dupe-keys": 2, - "no-duplicate-case": 2, - "no-empty-character-class": 2, - "no-empty": 2, - "no-ex-assign": 2, - "no-extra-boolean-cast": 2, - "no-extra-parens": 0, - "no-extra-semi": 2, - "no-func-assign": 2, - "no-inner-declarations": 2, - "no-invalid-regexp": 2, - "no-irregular-whitespace": 2, - "no-negated-in-lhs": 2, - "no-obj-calls": 2, - "no-regex-spaces": 2, - "no-sparse-arrays": 2, - "no-unexpected-multiline": 2, - "no-unreachable": 2, - "use-isnan": 2, - "valid-jsdoc": 0, - "valid-typeof": 2, - - "accessor-pairs": 0, - "block-scoped-var": 2, - "complexity": 0, - "consistent-return": 2, - "curly": [2, "all"], - "default-case": 2, - "dot-notation": 2, - "dot-location": [2, "property"], - "eqeqeq": 2, - "guard-for-in": 2, - "no-alert": 2, - "no-caller": 2, - "no-div-regex": 2, - "no-else-return": 2, - "no-eq-null": 2, - "no-eval": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-fallthrough": 2, - "no-floating-decimal": 2, - "no-implicit-coercion": 2, - "no-implied-eval": 2, - "no-invalid-this": 2, - "no-iterator": 2, - "no-labels": 2, - "no-lone-blocks": 2, - "no-loop-func": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-native-reassign": 2, - "no-new-func": 2, - "no-new-wrappers": 2, - "no-new": 2, - "no-octal-escape": 2, - "no-octal": 2, - "no-param-reassign": 2, - "no-process-env": 0, - "no-proto": 2, - "no-redeclare": 2, - "no-return-assign": 2, - "no-script-url": 2, - "no-self-compare": 2, - "no-sequences": 2, - "no-throw-literal": 2, - "no-unused-expressions": 2, - "no-useless-call": 2, - "no-void": 2, - "no-warning-comments": 2, - "no-with": 2, - "radix": 2, - "vars-on-top": 2, - "wrap-iife": 2, - "yoda": 2, - - "strict": [2, "never"], - - "init-declarations": 0, - "no-catch-shadow": 0, - "no-delete-var": 2, - "no-label-var": 2, - "no-shadow-restricted-names": 2, - "no-shadow": 2, - "no-undef-init": 2, - "no-undef": 2, - "no-undefined": 2, - "no-unused-vars": 2, - "no-use-before-define": 2, - - "callback-return": 0, - "handle-callback-err": 2, - "no-mixed-requires": 0, - "no-new-require": 2, - "no-path-concat": 2, - "no-process-exit": 2, - "no-restricted-modules": 2, - "no-sync": 2, - - "block-spacing": [2, "always"], - "brace-style": [2, "1tbs"], - "comma-spacing": [2, { "before": false, "after": true }], - "comma-style": [2, "last"], - "eol-last": 2, - "func-style": 0, - "indent": [2, 2, { "SwitchCase": 1 }], - "key-spacing": [2, { "beforeColon": false, "afterColon": true }], - "linebreak-style": [2, "unix"], - "new-cap": 2, - "new-parens": 2, - "no-lonely-if": 2, - "no-mixed-spaces-and-tabs": 2, - "no-multiple-empty-lines": [2, { "max": 1 }], - "no-nested-ternary": 2, - "no-spaced-func": 2, - "no-trailing-spaces": 2, - "no-unneeded-ternary": 2, - "object-curly-spacing": [2, "always"], - "operator-linebreak": [2, "after"], - "padded-blocks": [2, "never"], - "quotes": [2, "single"], - "semi-spacing": [2, {"before": false, "after": true}], - "semi": [2, "always"], - "space-after-keywords": [2, "always"], - "space-before-blocks": [2, "always"], - "space-before-function-paren": [2, "never"], - "space-in-parens": [2, "never"], - "space-infix-ops": 2, - "space-return-throw-case": 2, - "spaced-comment": [2, "always"], - - "arrow-parens": [2, "as-needed"], - "arrow-spacing": [2, { "before": true, "after": true }], - "constructor-super": 2, - "generator-star-spacing": [2, { "before": false, "after": true }], - "no-class-assign": 2, - "no-const-assign": 2, - "no-dupe-class-members": 2, - "no-this-before-super": 2, - "no-var": 2, - "object-shorthand": 2, - "prefer-arrow-callback": 0, - "prefer-const": 2, - "prefer-spread": 2, - "prefer-reflect": 0, - "prefer-template": 2, - "require-yield": 2 - } -} diff --git a/examples/e2e/.eslintrc.yml b/examples/e2e/.eslintrc.yml new file mode 100644 index 000000000..0ccc31ee5 --- /dev/null +++ b/examples/e2e/.eslintrc.yml @@ -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' diff --git a/examples/e2e/README.md b/examples/e2e/README.md index 473318b34..de0490412 100644 --- a/examples/e2e/README.md +++ b/examples/e2e/README.md @@ -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. + + +- [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) + + + ## The Example Project [Matching API] -> [Profile API]+\(DB\) @@ -29,13 +47,72 @@ 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: @@ -43,4 +120,7 @@ A test [Pact Boker](https://github.com/bethesque/pact_broker) is running at http * 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 +``` diff --git a/examples/e2e/consumer.js b/examples/e2e/consumer.js index fa54963cb..dcdf9e4dc 100644 --- a/examples/e2e/consumer.js +++ b/examples/e2e/consumer.js @@ -1,78 +1,78 @@ const express = require('express'); const request = require('superagent-bluebird-promise'); const server = express(); -const API_HOST = process.env.API_HOST; +const API_HOST = process.env.API_HOST || 'http://localhost:8081'; const availableAnimals = () => { return request - .get(`${API_HOST}/animals/available`) - .then(res => res.body, - err => []); - }; + .get(`${API_HOST}/animals/available`) + .then(res => res.body, + () => []); +}; - // Suggestions function: - // Given availability and sex etc. find available suitors. - const suggestion = mate => { - const predicates = [ - ((candidate, animal) => candidate.id !== animal.id), - ((candidate, animal) => candidate.gender !== animal.gender), - ((candidate, animal) => candidate.animal === animal.animal) - ]; +// Suggestions function: +// Given availability and sex etc. find available suitors. +const suggestion = mate => { + const predicates = [ + ((candidate, animal) => candidate.id !== animal.id), + ((candidate, animal) => candidate.gender !== animal.gender), + ((candidate, animal) => candidate.animal === animal.animal) + ]; - const weights = [ - ((candidate, animal) => Math.abs(candidate.age - animal.age)) - ]; + const weights = [ + ((candidate, animal) => Math.abs(candidate.age - animal.age)) + ]; - return availableAnimals().then(available => { - const eligible = available.filter(a => !predicates.map(p => p(a, mate)).includes(false)); + return availableAnimals().then(available => { + const eligible = available.filter(a => !predicates.map(p => p(a, mate)).includes(false)); - return { - suggestions: eligible.map(candidate => { - const score = weights.reduce((acc, weight) => { - return acc - weight(candidate, mate); - }, 100); + return { + suggestions: eligible.map(candidate => { + const score = weights.reduce((acc, weight) => { + return acc - weight(candidate, mate); + }, 100); - return { - score, - 'animal': candidate - }; - }) - }; - }); - }; + return { + score, + 'animal': candidate + }; + }) + }; + }); +}; const getAnimalById = (id) => { return request - .get(`${API_HOST}/animals/${id}`) - .then(res => res.body, - err => null); - }; + .get(`${API_HOST}/animals/${id}`) + .then(res => res.body, + () => null); +}; + +// API +server.get('/suggestions/:animalId', (req, res) => { + if (!req.params.animalId) { + res.writeHead(400); + res.end(); + } - // API - server.get('/suggestions/:animalId', (req, res) => { - if (!req.params.animalId) { - res.writeHead(400); + request(`${API_HOST}/animals/${req.params.animalId}`, (err, r) => { + if (!err && r.statusCode === 200) { + suggestion(r.body).then(suggestions => { + res.json(suggestions); + }); + } else if (r && r.statusCode === 404) { + res.writeHead(404); + res.end(); + } else { + res.writeHead(500); res.end(); } - - request(`${API_HOST}/animals/${req.params.animalId}`, (err, r) => { - if (!err && r.statusCode === 200) { - suggestion(r.body).then(suggestions => { - res.json(suggestions); - }); - } else if (r.statusCode === 404) { - res.writeHead(404); - res.end(); - } else { - res.writeHead(500); - res.end(); - } - }); }); +}); - module.exports = { - server, - availableAnimals, - suggestion, - getAnimalById - }; +module.exports = { + server, + availableAnimals, + suggestion, + getAnimalById +}; diff --git a/examples/e2e/package.json b/examples/e2e/package.json index 1d5f22acf..efc377d8a 100644 --- a/examples/e2e/package.json +++ b/examples/e2e/package.json @@ -6,15 +6,20 @@ "test:consumer": "./node_modules/.bin/mocha test/consumer.spec.js", "test:publish": "node test/publish.js", "test:provider": "node test/provider.spec.js", + "api": "concurrently 'npm run provider' 'npm run consumer'", "consumer": "node ./consumerService.js", "provider": "node ./providerService.js" }, "author": "matt.fellows@onegeek.com.au", "license": "MIT", "devDependencies": { - "@pact-foundation/pact-node": "^4.6.0" + "@pact-foundation/pact-node": "^4.6.0", + "concurrently": "^3.1.0", + "eslint": "^3.13.1", + "eslint-config-google": "^0.7.1" }, "dependencies": { + "bluebird": "^3.4.7", "chai": "^3.5.0", "chai-as-promised": "^6.0.0", "express": "^4.14.0", diff --git a/examples/e2e/pact-js-e2e.postman_collection b/examples/e2e/pact-js-e2e.postman_collection new file mode 100644 index 000000000..d92ffa2b9 --- /dev/null +++ b/examples/e2e/pact-js-e2e.postman_collection @@ -0,0 +1,111 @@ +{ + "variables": [], + "info": { + "name": "Pact JS - E2E", + "_postman_id": "ff8fb5f7-8f09-8f6d-2447-6c93c6dd97f5", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "POST /animals", + "request": { + "url": "http://localhost:8081/animals", + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"first_name\": \"aoeu\",\n \"last_name\": \"aoeu\",\n \"age\": 21,\n \"gender\": \"M\",\n \"location\": {\n \"description\": \"Melbourne Zoo\",\n \"country\": \"Australia\",\n \"post_code\": 3000\n },\n \"eligibility\": {\n \"available\": true,\n \"previously_married\": false\n },\n \"interests\": [\n \"walks in the garden/meadow\",\n \"munching on a paddock bomb\",\n \"parkour\"\n ]\n}" + }, + "description": "Create a new animal" + }, + "response": [] + }, + { + "name": "GET /animals", + "request": { + "url": "http://localhost:8081/animals", + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"first_name\": \"aoeu\",\n \"last_name\": \"aoeu\",\n \"age\": 21,\n \"gender\": \"M\",\n \"location\": {\n \"description\": \"Melbourne Zoo\",\n \"country\": \"Australia\",\n \"post_code\": 3000\n },\n \"eligibility\": {\n \"available\": true,\n \"previously_married\": false\n },\n \"interests\": [\n \"walks in the garden/meadow\",\n \"munching on a paddock bomb\",\n \"parkour\"\n ]\n}" + }, + "description": "GET all animals" + }, + "response": [] + }, + { + "name": "GET /animals/:id", + "request": { + "url": "http://localhost:8081/animals/1", + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"first_name\": \"aoeu\",\n \"last_name\": \"aoeu\",\n \"age\": 21,\n \"gender\": \"M\",\n \"location\": {\n \"description\": \"Melbourne Zoo\",\n \"country\": \"Australia\",\n \"post_code\": 3000\n },\n \"eligibility\": {\n \"available\": true,\n \"previously_married\": false\n },\n \"interests\": [\n \"walks in the garden/meadow\",\n \"munching on a paddock bomb\",\n \"parkour\"\n ]\n}" + }, + "description": "GET an animal by its ID" + }, + "response": [] + }, + { + "name": "GET /suggestions/:animal", + "request": { + "url": "http://localhost:8080/suggestions/1", + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"first_name\": \"aoeu\",\n \"last_name\": \"aoeu\",\n \"age\": 21,\n \"gender\": \"M\",\n \"location\": {\n \"description\": \"Melbourne Zoo\",\n \"country\": \"Australia\",\n \"post_code\": 3000\n },\n \"eligibility\": {\n \"available\": true,\n \"previously_married\": false\n },\n \"interests\": [\n \"walks in the garden/meadow\",\n \"munching on a paddock bomb\",\n \"parkour\"\n ]\n}" + }, + "description": "GET a suggestion for a given animal" + }, + "response": [] + }, + { + "name": "GET /animals/available", + "request": { + "url": "http://localhost:8081/animals/available", + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"first_name\": \"aoeu\",\n \"last_name\": \"aoeu\",\n \"age\": 21,\n \"gender\": \"M\",\n \"location\": {\n \"description\": \"Melbourne Zoo\",\n \"country\": \"Australia\",\n \"post_code\": 3000\n },\n \"eligibility\": {\n \"available\": true,\n \"previously_married\": false\n },\n \"interests\": [\n \"walks in the garden/meadow\",\n \"munching on a paddock bomb\",\n \"parkour\"\n ]\n}" + }, + "description": "GET all available animals" + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/examples/e2e/provider.js b/examples/e2e/provider.js index f9eccbec1..f208a53a9 100644 --- a/examples/e2e/provider.js +++ b/examples/e2e/provider.js @@ -6,7 +6,9 @@ const Repository = require('./repository'); const server = express(); server.use(cors()); server.use(bodyParser.json()); -server.use(bodyParser.urlencoded({ extended: true })); +server.use(bodyParser.urlencoded({ + extended: true +})); server.use((req, res, next) => { res.header('Content-Type', 'application/json; charset=utf-8'); next(); @@ -15,64 +17,64 @@ server.use((req, res, next) => { // Load data into a repository const animalRepository = new Repository(); const importData = () => { - const data = require('./data/animalData.json'); - data.reduce( (a, v) => { - v.id = a + 1; - animalRepository.insert(v); - return a + 1; - }, 0); -} + const data = require('./data/animalData.json'); + data.reduce((a, v) => { + v.id = a + 1; + animalRepository.insert(v); + return a + 1; + }, 0); +}; // Suggestions function: // Given availability and sex, find available suitors... const availableAnimals = () => { - return animalRepository.fetchAll().filter(a => { - return a.eligibility.available - }); -} + return animalRepository.fetchAll().filter(a => { + return a.eligibility.available; + }); +}; // Get all animals server.get('/animals', (req, res) => { - res.json(animalRepository.fetchAll()); + res.json(animalRepository.fetchAll()); }); // Get all animals server.get('/animals/available', (req, res) => { - res.json(availableAnimals()); + res.json(availableAnimals()); }); // Find an animal by ID server.get('/animals/:id', (req, res) => { - const response = animalRepository.getById(req.params.id); - if (response) { - res.end(JSON.stringify(response)); - } else { - res.writeHead(404); - res.end(); - } + const response = animalRepository.getById(req.params.id); + if (response) { + res.end(JSON.stringify(response)); + } else { + res.writeHead(404); + res.end(); + } }); // Register a new Animal for the service server.post('/animals', (req, res) => { - const animal = req.body; + const animal = req.body; - // Really basic validation - if (!animal || !animal.first_name) { - res.writeHead(400); - res.end(); + // Really basic validation + if (!animal || !animal.first_name) { + res.writeHead(400); + res.end(); - return; - } + return; + } - animal.id = animalRepository.fetchAll().length;; - animalRepository.insert(animal); + animal.id = animalRepository.fetchAll().length; + animalRepository.insert(animal); - res.writeHead(200); - res.end(); + res.writeHead(200); + res.end(); }); module.exports = { - server, - importData, - animalRepository + server, + importData, + animalRepository }; diff --git a/examples/e2e/repository.js b/examples/e2e/repository.js index 5456867c9..3bfb51254 100644 --- a/examples/e2e/repository.js +++ b/examples/e2e/repository.js @@ -1,24 +1,24 @@ // Simple object repository class Repository { - constructor() { - this.entities = []; - } + constructor() { + this.entities = []; + } - fetchAll() { - return this.entities; - } + fetchAll() { + return this.entities; + } - getById(id) { - return this.entities.find((entity) => id == entity.id); - } + getById(id) { + return this.entities.find((entity) => id == entity.id); + } - insert(entity) { - this.entities.push(entity); - } + insert(entity) { + this.entities.push(entity); + } - clear() { - this.entities = []; - } + clear() { + this.entities = []; + } } module.exports = Repository; diff --git a/examples/e2e/test/provider.spec.js b/examples/e2e/test/provider.spec.js index 20ee3b184..568831256 100644 --- a/examples/e2e/test/provider.spec.js +++ b/examples/e2e/test/provider.spec.js @@ -1,44 +1,50 @@ const pact = require('@pact-foundation/pact-node'); const path = require('path'); -const { server, importData, animalRepository } = require('../provider.js'); +const { + server, + importData, + animalRepository +} = require('../provider.js'); // Append some extra endpoints to mutate current state of the API server.get('/states', (req, res) => { - res.json({"Matching Service": ['Has some animals', 'Has no animals', 'Has an animal with ID 1']}); + res.json({ + "Matching Service": ['Has some animals', 'Has no animals', 'Has an animal with ID 1'] + }); }); server.post('/setup', (req, res) => { - const state = req.body.state; + const state = req.body.state; - animalRepository.clear(); - switch (state) { - case 'Has no animals': - // do nothing - break; - default: - importData(); - } + animalRepository.clear(); + switch (state) { + case 'Has no animals': + // do nothing + break; + default: + importData(); + } - res.end(); + res.end(); }); server.listen(8081, () => { - console.log('Animal Profile Service listening on http://localhost:8081'); + console.log('Animal Profile Service listening on http://localhost:8081'); }); let opts = { - providerBaseUrl: 'http://localhost:8081', - providerStatesUrl: 'http://localhost:8081/states', - providerStatesSetupUrl: 'http://localhost:8081/setup', - pactUrls: ['https://test.pact.dius.com.au/pacts/provider/Animal%20Profile%20Service/consumer/Matching%20Service/latest'], - pactBrokerUsername: 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M', - pactBrokerPassword: 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1' + providerBaseUrl: 'http://localhost:8081', + providerStatesUrl: 'http://localhost:8081/states', + providerStatesSetupUrl: 'http://localhost:8081/setup', + pactUrls: ['https://test.pact.dius.com.au/pacts/provider/Animal%20Profile%20Service/consumer/Matching%20Service/latest'], + pactBrokerUsername: 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M', + pactBrokerPassword: 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1' }; pact.verifyPacts(opts).then((res) => { - console.log('Pact Verification Complete!'); - console.log(res); - process.exit(0); + console.log('Pact Verification Complete!'); + console.log(res); + process.exit(0); }).catch((error) => { - console.log('Pact Verification Failed: ', error); - process.exit(1); + console.log('Pact Verification Failed: ', error); + process.exit(1); }); diff --git a/examples/e2e/test/publish.js b/examples/e2e/test/publish.js index e5aa5a47b..701b6e188 100644 --- a/examples/e2e/test/publish.js +++ b/examples/e2e/test/publish.js @@ -1,10 +1,10 @@ const pact = require('@pact-foundation/pact-node'); const path = require('path'); const opts = { - pactUrls: [path.resolve(__dirname, '../pacts/matching_service-animal_profile_service.json')], // Array of local Pact files or directories containing them. Required. + pactUrls: [path.resolve(__dirname, '../pacts/matching_service-animal_profile_service.json')], // Array of local Pact files or directories containing them. Required. pactBroker: 'https://test.pact.dius.com.au', - pactBrokerUsername: 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M', - pactBrokerPassword: 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1', + pactBrokerUsername: 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M', + pactBrokerPassword: 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1', tags: ['prod', 'test'], consumerVersion: '1.0.0' };