Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Set exit code to non-zero value on error
Browse files Browse the repository at this point in the history
  • Loading branch information
bobisjan committed Mar 1, 2018
1 parent 8b768a3 commit 5ee98b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions bin/codacy-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
}, function (err) {
loggerImpl.error('Error sending coverage');
loggerImpl.error(err);
process.exitCode = 1;
});
});

Expand Down
10 changes: 6 additions & 4 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,26 @@

helper.setupMockEndpoint('1234', '4321', Joi.compile(bodyObject)).then(function () {
exec('cat ./test/mock/lcov.info | node ./bin/codacy-coverage.js --token 1234 --commit 4321', function (err, res) {
if (err) {
return done(err);
if (!err) {
return done(new Error('Should return with error'));
}

expect(res).to.match(/Status Code \[404\] - Error \[{"error":"not found"}\]/);
expect(err.code).to.equal(1);
//nock.done(); //TODO: Need to figure out how to use nock here. Since it's a separate process, it's not tied together.
done();
});
});
});
it('should be able to set options', function (done) {
exec('cat ./test/mock/no-lines.info | node ./bin/codacy-coverage.js --debug --verbose --token 1234 --commit 4321 --prefix asdf/ --endpoint something --format lcov', function (err, res) {
if (err) {
return done(err);
if (!err) {
return done(new Error('Should return with error'));
}

expect(res).to.match(/Started with: token \["1234"], commitId \["4321"], language \[undefined], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
expect(res).to.match(/Handling input for: token \["1234"], commitId \["4321"], language \[undefined], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
expect(err.code).to.equal(1);
done();
});
});
Expand Down

0 comments on commit 5ee98b8

Please sign in to comment.