diff options
| author | cainus <[email protected]> | 2013-06-22 14:39:16 -0700 |
|---|---|---|
| committer | cainus <[email protected]> | 2013-06-22 14:39:16 -0700 |
| commit | 311cdeedb62363ec047f0cfe8f1d9460a9735c3a (patch) | |
| tree | 061d9cc2b807a6972532c78b5f9b5f501236ab10 /test | |
| parent | 82cf2e8e13f84d6efb34c70db5a9673ec4dd100e (diff) | |
| download | node-coveralls-311cdeedb62363ec047f0cfe8f1d9460a9735c3a.tar.xz node-coveralls-311cdeedb62363ec047f0cfe8f1d9460a9735c3a.zip | |
improved testing.
Diffstat (limited to 'test')
| -rw-r--r-- | test/convertLcovToCoveralls.js | 19 | ||||
| -rw-r--r-- | test/getOptions.js | 26 | ||||
| -rw-r--r-- | test/logger.js | 11 |
3 files changed, 55 insertions, 1 deletions
diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js index c83dc6c..aea36a1 100644 --- a/test/convertLcovToCoveralls.js +++ b/test/convertLcovToCoveralls.js @@ -1,4 +1,5 @@ var convertLcovToCoveralls = require('../index').convertLcovToCoveralls; +var getOptions = require('../index').getOptions; var should = require('should'); var fs = require('fs'); var logger = require('../lib/logger'); @@ -19,6 +20,24 @@ describe("convertLcovToCoveralls", function(){ }); }); + it ("should pass on all appropriate parameters from the environment", function(){ + process.env.TRAVIS_JOB_ID = -1; + process.env.COVERALLS_GIT = "GIT_HASH"; + process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME"; + process.env.COVERALLS_SERVICE_JOB_ID = "SERVICE_JOB_ID"; + process.env.COVERALLS_REPO_TOKEN = "REPO_TOKEN"; + + var options = getOptions(); + var path = __dirname + "/../fixtures/onefile.lcov"; + var input = fs.readFileSync(path, "utf8"); + var libpath = "fixtures/lib"; + options.filepath = libpath; + convertLcovToCoveralls(input, options, function(err, output){ + should.not.exist(err); + console.log(output); + //output.git.should.equal("GIT_HASH"); + }); + }); it ("should work with a relative path as well", function(){ process.env.TRAVIS_JOB_ID = -1; var path = __dirname + "/../fixtures/onefile.lcov"; diff --git a/test/getOptions.js b/test/getOptions.js index e8e3c7a..c1c2133 100644 --- a/test/getOptions.js +++ b/test/getOptions.js @@ -2,6 +2,9 @@ var should = require('should'); var getOptions = require('../index').getOptions; describe("getOptions", function(){ + beforeEach(function(){ + process.env = {}; + }); it ("should get a filepath if there is one", function(){ process.argv[2] = "somepath"; getOptions().filepath.should.equal("somepath"); @@ -11,7 +14,28 @@ describe("getOptions", function(){ process.argv[2] = "--verbose"; process.argv[3] = "somepath"; getOptions().filepath.should.equal("somepath"); - + }); + it ("should set service_job_id if it exists", function(){ + process.env.COVERALLS_SERVICE_JOB_ID = "SERVICE_JOB_ID"; + getOptions().service_job_id.should.equal("SERVICE_JOB_ID"); + }); + it ("should set git if it exists", function(){ + process.env.COVERALLS_GIT = "qwer"; + getOptions().git.should.equal("qwer"); + }); + it ("should set repo_token if it exists", function(){ + process.env.COVERALLS_REPO_TOKEN = "REPO_TOKEN"; + getOptions().repo_token.should.equal("REPO_TOKEN"); + }); + it ("should set service_name if it exists", function(){ + process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME"; + getOptions().service_name.should.equal("SERVICE_NAME"); + }); + it ("should set service_name and service_job_id if it's running on travis-ci", function(){ + process.env.TRAVIS = "TRUE"; + process.env.TRAVIS_JOB_ID = "1234"; + getOptions().service_name.should.equal("travis-ci"); + getOptions().service_job_id.should.equal("1234"); }); }); diff --git a/test/logger.js b/test/logger.js new file mode 100644 index 0000000..c6899db --- /dev/null +++ b/test/logger.js @@ -0,0 +1,11 @@ +var should = require('should'); +var sinon = require('sinon-restore'); +var index = require('../index'); + +describe("logger", function(){ + it ("should log at debug level when --verbose is set", function(){ + process.argv[2] = '--verbose'; + var logger = require('../index').logger(); + logger.level.should.equal('debug'); + }); +}); |
