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

Commit 37746ab

Browse files
committed
Added test to make sure that options are being properly conveyed to both the CLI and handle input pieces.
1 parent a00d6b5 commit 37746ab

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

lib/handleInput.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function (parser, reporter, getGitData, logger, Promise) {
1+
(function (parser, reporter, getGitData, logger, Promise, util) {
22
'use strict';
33
module.exports = function (input, opts) {
44
opts = opts || {};
@@ -18,6 +18,9 @@
1818
return Promise.reject(new Error('Token is required'));
1919
}
2020

21+
loggerImpl.info(util.format('Handling input for: token [%j], commitId [%j], endpoint [%j], format [%j], path prefix [%j], verbose [%j], debug [%j]',
22+
token, commit, opts.endpoint, format, pathPrefix, opts.verbose, opts.debug));
23+
2124
// Parse the coverage data for the given format and retrieve the commit id if we don't have it.
2225
return Promise.all([parser.getParser(format).parse(pathPrefix, input), getGitData.getCommitId(commit)]).spread(function (parsedCoverage, commitId) {
2326
// Now that we've parse the coverage data to the correct format, send it to Codacy.
@@ -28,4 +31,4 @@
2831
}).sendCoverage(token, commitId, parsedCoverage);
2932
});
3033
};
31-
}(require('./coverageParser'), require('./reporter'), require('./getGitData'), require('./logger'), require('bluebird')));
34+
}(require('./coverageParser'), require('./reporter'), require('./getGitData'), require('./logger'), require('bluebird'), require('util')));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codacy-coverage",
3-
"version": "1.0.4",
3+
"version": "1.1.0",
44
"description": "Code Coverage reporter for Codacy.com",
55
"keywords": [
66
"codacy",

test/cli.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,21 @@
5050
}
5151

5252
expect(res).to.match(/Status Code \[404\] - Error \[{"error":"not found"}\]/);
53-
console.log(res);
5453
//nock.done(); //TODO: Need to figure out how to use nock here. Since it's a separate process, it's not tied together.
5554
done();
5655
});
5756
});
5857
});
58+
it('should be able to set options', function (done) {
59+
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) {
60+
if (err) {
61+
return done(err);
62+
}
63+
64+
expect(res).to.match(/Started with: token \["1234"], commitId \["4321"], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
65+
expect(res).to.match(/Handling input for: token \["1234"], commitId \["4321"], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
66+
done();
67+
});
68+
});
5969
});
6070
}(require('child_process').exec, require('joi'), require('../'), require('./helper')));

0 commit comments

Comments
 (0)