fixed node messaging example
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test:consumer": "mocha src/consumer/*.spec.js",
|
||||
"test:provider": "mocha src/provider/*.spec.js",
|
||||
"test:pact:consumer": "mocha src/consumer/*.spec.js --exit",
|
||||
"test:pact:provider": "mocha src/provider/*.spec.js --exit",
|
||||
"publish:pact": "node pact/publish.js"
|
||||
},
|
||||
"author": "Tom Hombergs",
|
||||
|
||||
@@ -27,8 +27,8 @@ describe("message consumer", () => {
|
||||
"content-type": "application/json",
|
||||
})
|
||||
.verify(synchronousBodyHandler(handleHeroCreatedEvent))
|
||||
.then(done, (error) => done(error));
|
||||
});
|
||||
.then(() => done(), (error) => done(error));
|
||||
}).timeout(5000);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const HeroCreatedMessage = require('../common/hero-created-message');
|
||||
|
||||
function produceHeroCreatedEvent(id) {
|
||||
function produceHeroCreatedEvent() {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({foo: "this is an invalid message that does not match the contract!"});
|
||||
resolve(new HeroCreatedMessage("Superman", "Flying", "DC", 42));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,19 +6,21 @@ describe("message producer", () => {
|
||||
|
||||
const messagePact = new MessageProviderPact({
|
||||
messageProviders: {
|
||||
"a hero created message": () => produceHeroCreatedEvent(42),
|
||||
"a hero created message": () => produceHeroCreatedEvent(),
|
||||
},
|
||||
log: path.resolve(process.cwd(), "logs"),
|
||||
logLevel: "debug",
|
||||
log: path.resolve(process.cwd(), "logs", "pact.log"),
|
||||
logLevel: "info",
|
||||
provider: "node-message-provider",
|
||||
|
||||
pactUrls: [path.resolve(process.cwd(), "pacts", "node-message-consumer-node-message-provider.json")],
|
||||
|
||||
// Pact seems not to load a pact file from a pact broker, so we have to make do with the local pact file
|
||||
// see https://github.com/pact-foundation/pact-js/issues/248
|
||||
// pactBrokerUrl: "https://adesso.pact.dius.com.au",
|
||||
// pactBrokerUsername: process.env.PACT_USERNAME,
|
||||
// pactBrokerPassword: process.env.PACT_PASSWORD,
|
||||
publishVerificationResult: true,
|
||||
providerVersion: '1.0.0',
|
||||
// publishVerificationResult: true,
|
||||
// providerVersion: '1.0.0',
|
||||
tags: ['latest']
|
||||
});
|
||||
|
||||
@@ -28,7 +30,7 @@ describe("message producer", () => {
|
||||
it("should create a valid hero created message", (done) => {
|
||||
messagePact
|
||||
.verify()
|
||||
.then(done, (error) => done(error));
|
||||
.then(() => done(), (error) => done(error));
|
||||
}).timeout(5000);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user