-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repro for issue pact-foundation/pact-js-core/issues/120
- Loading branch information
Showing
3 changed files
with
93 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: '3' | ||
|
||
services: | ||
|
||
postgres: | ||
image: postgres | ||
healthcheck: | ||
test: psql postgres --command "select 1" -U postgres | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: postgres | ||
|
||
broker_app: | ||
image: dius/pact-broker | ||
ports: | ||
- "80:80" | ||
links: | ||
- postgres | ||
environment: | ||
PACT_BROKER_DATABASE_USERNAME: postgres | ||
PACT_BROKER_DATABASE_PASSWORD: password | ||
PACT_BROKER_DATABASE_HOST: postgres | ||
PACT_BROKER_DATABASE_NAME: postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,60 @@ | ||
const { | ||
Verifier | ||
} = require('../../../dist/pact') | ||
const path = require('path') | ||
const chai = require('chai') | ||
const chaiAsPromised = require('chai-as-promised') | ||
const expect = chai.expect | ||
const { | ||
VerifierOptions | ||
} = require('@pact-foundation/pact-node'); | ||
chai.use(chaiAsPromised) | ||
const { | ||
server, | ||
importData, | ||
animalRepository | ||
} = require('../provider.js') | ||
const { Verifier } = require("../../../dist/pact"); | ||
const path = require("path"); | ||
const chai = require("chai"); | ||
const chaiAsPromised = require("chai-as-promised"); | ||
const expect = chai.expect; | ||
const { VerifierOptions } = require("@pact-foundation/pact-node"); | ||
chai.use(chaiAsPromised); | ||
const { server, importData, animalRepository } = require("../provider.js"); | ||
|
||
server.post('/setup', (req, res) => { | ||
const state = req.body.state | ||
server.post("/setup", (req, res) => { | ||
const state = req.body.state; | ||
|
||
animalRepository.clear() | ||
animalRepository.clear(); | ||
switch (state) { | ||
case 'Has no animals': | ||
case "Has no animals": | ||
// do nothing | ||
break | ||
break; | ||
default: | ||
importData() | ||
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"); | ||
}); | ||
|
||
// Verify that the provider meets all consumer expectations | ||
describe('Pact Verification', () => { | ||
it('should validate the expectations of Matching Service', function () { // lexical binding required here | ||
this.timeout(10000) | ||
describe("Pact Verification", () => { | ||
it("should validate the expectations of Matching Service", function() { | ||
// lexical binding required here | ||
this.timeout(10000); | ||
|
||
let opts = { | ||
provider: 'Animal Profile Service', | ||
providerBaseUrl: 'http://localhost:8081', | ||
providerStatesSetupUrl: 'http://localhost:8081/setup', | ||
provider: "Animal Profile Service", | ||
providerBaseUrl: "http://localhost:8081", | ||
providerStatesSetupUrl: "http://localhost:8081/setup", | ||
// Fetch pacts from broker | ||
pactBrokerUrl: 'https://test.pact.dius.com.au/', | ||
// pactBrokerUrl: 'https://test.pact.dius.com.au/', | ||
pactBrokerUrl: "http://localhost", | ||
// Fetch from broker with given tags | ||
tags: ['prod', 'sit5'], | ||
tags: ["prod", "sit5"], | ||
// Specific Remote pacts (doesn't need to be a broker) | ||
// pactFilesOrDirs: ['https://test.pact.dius.com.au/pacts/provider/Animal%20Profile%20Service/consumer/Matching%20Service/latest'], | ||
// Local pacts | ||
// pactFilesOrDirs: [path.resolve(process.cwd(), './pacts/matching_service-animal_profile_service.json')], | ||
pactBrokerUsername: 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M', | ||
pactBrokerPassword: 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1', | ||
pactBrokerUsername: "dXfltyFMgNOFZAxr8io9wJ37iUpY42M", | ||
pactBrokerPassword: "O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1", | ||
publishVerificationResult: true, | ||
providerVersion: "1.0.0", | ||
customProviderHeaders: ['Authorization: basic e5e5e5e5e5e5e5'] | ||
} | ||
customProviderHeaders: ["Authorization: basic e5e5e5e5e5e5e5"] | ||
}; | ||
|
||
return new Verifier().verifyProvider(opts) | ||
.then(output => { | ||
console.log('Pact Verification Complete!') | ||
console.log(output) | ||
}) | ||
}) | ||
}) | ||
return new Verifier().verifyProvider(opts).then(output => { | ||
console.log("Pact Verification Complete!"); | ||
console.log(output); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
const pact = require('@pact-foundation/pact-node') | ||
const path = require('path') | ||
const pact = require("@pact-foundation/pact-node"); | ||
const path = require("path"); | ||
const opts = { | ||
pactFilesOrDirs: [path.resolve(__dirname, '../pacts/matching_service-animal_profile_service.json')], | ||
pactBroker: 'https://test.pact.dius.com.au', | ||
pactBrokerUsername: 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M', | ||
pactBrokerPassword: 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1', | ||
tags: ['prod', 'test'], | ||
consumerVersion: '1.0.' + ((process.env.TRAVIS_BUILD_NUMBER) ? process.env.TRAVIS_BUILD_NUMBER : Math.floor(new Date() / 1000)) | ||
} | ||
pactFilesOrDirs: [ | ||
path.resolve( | ||
__dirname, | ||
"../pacts/matching_service-animal_profile_service.json" | ||
) | ||
], | ||
// pactBroker: 'https://test.pact.dius.com.au', | ||
pactBroker: "http://localhost", | ||
pactBrokerUsername: "dXfltyFMgNOFZAxr8io9wJ37iUpY42M", | ||
pactBrokerPassword: "O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1", | ||
tags: ["prod", "test"], | ||
consumerVersion: | ||
"1.0." + | ||
(process.env.TRAVIS_BUILD_NUMBER | ||
? process.env.TRAVIS_BUILD_NUMBER | ||
: Math.floor(new Date() / 1000)) | ||
}; | ||
|
||
pact.publishPacts(opts) | ||
pact | ||
.publishPacts(opts) | ||
.then(() => { | ||
console.log('Pact contract publishing complete!') | ||
console.log('') | ||
console.log('Head over to https://test.pact.dius.com.au/ and login with') | ||
console.log('=> Username: dXfltyFMgNOFZAxr8io9wJ37iUpY42M') | ||
console.log('=> Password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1') | ||
console.log('to see your published contracts.') | ||
console.log("Pact contract publishing complete!"); | ||
console.log(""); | ||
console.log("Head over to https://test.pact.dius.com.au/ and login with"); | ||
console.log("=> Username: dXfltyFMgNOFZAxr8io9wJ37iUpY42M"); | ||
console.log("=> Password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1"); | ||
console.log("to see your published contracts."); | ||
}) | ||
.catch(e => { | ||
console.log('Pact contract publishing failed: ', e) | ||
}) | ||
console.log("Pact contract publishing failed: ", e); | ||
}); |