From 1103e695914ee91f4aca43e6ecd6a63fb70e1137 Mon Sep 17 00:00:00 2001 From: Sash Date: Tue, 25 Apr 2017 15:18:47 +0100 Subject: [PATCH 1/3] 1.0.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad2a977..9bc844a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jackal", - "version": "1.0.13", + "version": "1.0.14", "description": "Consumer Driven Contracts Service", "main": "index.js", "bin": { From 0e4813e111f626e39a7f891049219db225015e15 Mon Sep 17 00:00:00 2001 From: Sash Date: Tue, 25 Apr 2017 17:03:06 +0100 Subject: [PATCH 2/3] Making no contract found scenrio return a 0 return code --- cli/reporter/index.js | 2 +- test/integration/cli/run.spec.js | 60 ++++++++++++++++---------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cli/reporter/index.js b/cli/reporter/index.js index b7f62e9..993eb38 100644 --- a/cli/reporter/index.js +++ b/cli/reporter/index.js @@ -12,7 +12,7 @@ const loggers = { const statusErrorMap = { SKIPPED: null, ERROR: 'Aborting', - NO_CONTRACTS: 'No contracts found', + NO_CONTRACTS: null, INVALID: 'Invalid contracts', FAILED: 'Tests failed', PASSED: null diff --git a/test/integration/cli/run.spec.js b/test/integration/cli/run.spec.js index d413804..480d2a8 100644 --- a/test/integration/cli/run.spec.js +++ b/test/integration/cli/run.spec.js @@ -158,9 +158,9 @@ describe('CLI.Run Integration Test', function () { } exec(`node index run -r json http://localhost:${port} provider_three`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(JSON.parse(stdout)).to.eql(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -217,9 +217,9 @@ describe('CLI.Run Integration Test', function () { } exec(`node index run -r json http://localhost:${port} provider_one`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(JSON.parse(stdout)).to.eql(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -232,9 +232,9 @@ describe('CLI.Run Integration Test', function () { } exec(`node index run -r json -p http://localhost:8381 http://localhost:${port} provider_one`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(JSON.parse(stdout)).to.eql(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -247,9 +247,9 @@ describe('CLI.Run Integration Test', function () { } exec(`node index run -r json http://localhost:${port} provider_two`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(JSON.parse(stdout)).to.eql(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -262,9 +262,9 @@ describe('CLI.Run Integration Test', function () { } exec(`node index run -r json -p http://localhost:8382 http://localhost:${port} provider_two`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(JSON.parse(stdout)).to.eql(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -363,9 +363,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_three\n' exec(`node index run -r spec http://localhost:${port} provider_three`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -418,9 +418,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_one\n' exec(`node index run -r spec http://localhost:${port} provider_one`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -429,9 +429,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_one\n' exec(`node index run -r spec -p http://localhost:8381 http://localhost:${port} provider_one`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -440,9 +440,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_two\n' exec(`node index run -r spec http://localhost:${port} provider_two`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -451,9 +451,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_two\n' exec(`node index run -r spec -p http://localhost:8382 http://localhost:${port} provider_two`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -552,9 +552,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_three\n' exec(`node index run -r teamcity http://localhost:${port} provider_three`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -607,9 +607,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_one\n' exec(`node index run -r teamcity http://localhost:${port} provider_one`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -618,9 +618,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_one\n' exec(`node index run -r teamcity -p http://localhost:8381 http://localhost:${port} provider_one`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -629,9 +629,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_two\n' exec(`node index run -r teamcity http://localhost:${port} provider_two`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) @@ -640,9 +640,9 @@ describe('CLI.Run Integration Test', function () { const expected = 'No contracts exist for provider: provider_two\n' exec(`node index run -r teamcity -p http://localhost:8382 http://localhost:${port} provider_two`, (err, stdout, stderr) => { - expect(err).to.exist + expect(err).not.to.exist expect(stdout).to.equal(expected) - expect(stderr).not.to.equal('') + expect(stderr).to.equal('') done() }) }) From 9a8ec7f5a0448b7334fbef30266ed1199d05d7b3 Mon Sep 17 00:00:00 2001 From: Sash Date: Wed, 26 Apr 2017 10:46:25 +0100 Subject: [PATCH 3/3] Removing coloring from stderr --- cli/index.js | 2 +- test/integration/cli/send.spec.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cli/index.js b/cli/index.js index 3f5954c..2da1276 100644 --- a/cli/index.js +++ b/cli/index.js @@ -53,7 +53,7 @@ const errorWrapper = (fn) => function () { const exitCodeHandler = (err) => { if (err) { /* eslint-disable no-console */ - console.error(prettyError.render(err)) + console.error(prettyError.withoutColors().render(err)) /* eslint-enble no-console */ process.exit(1) } diff --git a/test/integration/cli/send.spec.js b/test/integration/cli/send.spec.js index 5986eca..6814453 100644 --- a/test/integration/cli/send.spec.js +++ b/test/integration/cli/send.spec.js @@ -733,7 +733,7 @@ describe('CLI.Send Integration Test', function () { }) context('with missing contracts', function () { - const stderrOutput = ' \u001b[0m\u001b[97m\u001b[41mError\u001b[0m\u001b[90m:\u001b[0m\u001b[37m \u001b[0m\u001b[97mMissing contract file test/contracts/missing-contracts-file.json\u001b[0m\n\u001b[0m\n' + const stderrOutput = '.*Error:.*Missing contract file test/contracts/missing-contracts-file.json.*' context('using the JSON reporter', function () { let port, dbPath, options @@ -751,13 +751,13 @@ describe('CLI.Send Integration Test', function () { }) it('should return an error advising the contracts file is missing', function (done) { - const errMessage = 'Command failed: node index send -r json http://localhost:8378 test/contracts/missing-contracts-file.json\n \u001b[0m\u001b[97m\u001b[41mError\u001b[0m\u001b[90m:\u001b[0m\u001b[37m \u001b[0m\u001b[97mMissing contract file test/contracts/missing-contracts-file.json\u001b[0m\n\u001b[0m\n' + const errMessage = `Command failed: node index send -r json http://localhost:8378 test/contracts/missing-contracts-file.json\n ${stderrOutput}` exec(`node index send -r json http://localhost:${port} test/contracts/missing-contracts-file.json`, (err, stdout, stderr) => { - expect(err.message).to.equal(errMessage) + expect(err.message).to.match(new RegExp(errMessage)) expect(err.code).to.equal(1) expect(stdout).to.equal('') - expect(stderr).to.equal(stderrOutput) + expect(stderr).to.match(new RegExp(stderrOutput)) done() }) @@ -789,13 +789,13 @@ describe('CLI.Send Integration Test', function () { }) it('should return an error advising the contracts file is missing', function (done) { - const errMessage = 'Command failed: node index send -r spec http://localhost:8378 test/contracts/missing-contracts-file.json\n \u001b[0m\u001b[97m\u001b[41mError\u001b[0m\u001b[90m:\u001b[0m\u001b[37m \u001b[0m\u001b[97mMissing contract file test/contracts/missing-contracts-file.json\u001b[0m\n\u001b[0m\n' + const errMessage = `Command failed: node index send -r spec http://localhost:8378 test/contracts/missing-contracts-file.json\n ${stderrOutput}` exec(`node index send -r spec http://localhost:${port} test/contracts/missing-contracts-file.json`, (err, stdout, stderr) => { - expect(err.message).to.equal(errMessage) + expect(err.message).to.match(new RegExp(errMessage)) expect(err.code).to.equal(1) expect(stdout).to.equal('') - expect(stderr).to.equal(stderrOutput) + expect(stderr).to.match(new RegExp(stderrOutput)) done() }) @@ -827,13 +827,13 @@ describe('CLI.Send Integration Test', function () { }) it('should return an error advising the contracts file is missing', function (done) { - const errMessage = 'Command failed: node index send -r teamcity http://localhost:8378 test/contracts/missing-contracts-file.json\n \u001b[0m\u001b[97m\u001b[41mError\u001b[0m\u001b[90m:\u001b[0m\u001b[37m \u001b[0m\u001b[97mMissing contract file test/contracts/missing-contracts-file.json\u001b[0m\n\u001b[0m\n' + const errMessage = `Command failed: node index send -r teamcity http://localhost:8378 test/contracts/missing-contracts-file.json\n ${stderrOutput}` exec(`node index send -r teamcity http://localhost:${port} test/contracts/missing-contracts-file.json`, (err, stdout, stderr) => { - expect(err.message).to.equal(errMessage) + expect(err.message).to.match(new RegExp(errMessage)) expect(err.code).to.equal(1) expect(stdout).to.equal('') - expect(stderr).to.equal(stderrOutput) + expect(stderr).to.match(new RegExp(stderrOutput)) done() })