diff options
| author | Nick Merwin <[email protected]> | 2015-12-10 12:52:55 -0800 |
|---|---|---|
| committer | Nick Merwin <[email protected]> | 2015-12-10 12:52:55 -0800 |
| commit | d084add18e87fd1a292315de7c9eb171e8fd4b93 (patch) | |
| tree | c90578e6a9540b8af75a930dc25d3c07be4efee6 /test | |
| parent | 712e6e4bb4d8e1a60f646d954743a6808aa7f13e (diff) | |
| parent | d60635885d243abef2cbc5b2a0da7a27d752a14b (diff) | |
| download | node-coveralls-pr/96.tar.xz node-coveralls-pr/96.zip | |
merge conflictspr/96
Diffstat (limited to 'test')
| -rw-r--r-- | test/convertLcovToCoveralls.js | 2 | ||||
| -rw-r--r-- | test/getOptions.js | 19 | ||||
| -rw-r--r-- | test/sendToCoveralls.js | 31 |
3 files changed, 50 insertions, 2 deletions
diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js index 6a64eda..24fa6c8 100644 --- a/test/convertLcovToCoveralls.js +++ b/test/convertLcovToCoveralls.js @@ -29,6 +29,7 @@ describe("convertLcovToCoveralls", function(){ process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME"; process.env.COVERALLS_SERVICE_JOB_ID = "SERVICE_JOB_ID"; process.env.COVERALLS_REPO_TOKEN = "REPO_TOKEN"; + process.env.CI_PULL_REQUEST = "https://github.com/fake/fake/pulls/123"; getOptions(function(err, options){ var lcovpath = __dirname + "/../fixtures/onefile.lcov"; @@ -37,6 +38,7 @@ describe("convertLcovToCoveralls", function(){ options.filepath = libpath; convertLcovToCoveralls(input, options, function(err, output){ should.not.exist(err); + output.service_pull_request.should.equal("123"); //output.git.should.equal("GIT_HASH"); done(); }); diff --git a/test/getOptions.js b/test/getOptions.js index 8a77708..ac26caf 100644 --- a/test/getOptions.js +++ b/test/getOptions.js @@ -115,6 +115,9 @@ describe("getOptions", function(){ it ("should set service_name if it exists", function(done){ testServiceName(getOptions, done); }); + it("should set service_pull_request if it exists", function(done){ + testServicePullRequest(getOptions, done); + }); it ("should set service_name and service_job_id if it's running on travis-ci", function(done){ testTravisCi(getOptions, done); }); @@ -135,6 +138,14 @@ describe("getOptions", function(){ it ("should set service_name and service_job_id if it's running on wercker", function(done){ testWercker(getOptions, done); }); + it ("should override set options with user options", function(done){ + var userOptions = {service_name: 'OVERRIDDEN_SERVICE_NAME'}; + process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME"; + getOptions(function(err, options){ + options.service_name.should.equal("OVERRIDDEN_SERVICE_NAME"); + done(); + }, userOptions); + }); }); var testServiceJobId = function(sut, done){ @@ -246,6 +257,14 @@ var testServiceName = function(sut, done){ }); }; +var testServicePullRequest = function(sut, done){ + process.env.CI_PULL_REQUEST = "https://github.com/fake/fake/pulls/123"; + sut(function(err, options){ + options.service_pull_request.should.equal("123"); + done(); + }); +}; + var testTravisCi = function(sut, done){ process.env.TRAVIS = "TRUE"; process.env.TRAVIS_JOB_ID = "1234"; diff --git a/test/sendToCoveralls.js b/test/sendToCoveralls.js index 937df95..f809319 100644 --- a/test/sendToCoveralls.js +++ b/test/sendToCoveralls.js @@ -5,9 +5,20 @@ var index = require('../index'); logger = require('log-driver')({level : false}); describe("sendToCoveralls", function(){ + var realCoverallsHost; + beforeEach(function() { + realCoverallsHost = process.env.COVERALLS_ENDPOINT; + }); + afterEach(function() { sinon.restoreAll(); + if (realCoverallsHost !== undefined) { + process.env.COVERALLS_ENDPOINT = realCoverallsHost; + } else { + delete process.env.COVERALLS_ENDPOINT; + } }); + it ("passes on the correct params to request.post", function(done){ sinon.stub(request, 'post', function(obj, cb){ obj.url.should.equal('https://coveralls.io/api/v1/jobs'); @@ -16,12 +27,28 @@ describe("sendToCoveralls", function(){ }); var obj = {"some":"obj"}; - index.sendToCoveralls(obj, function(err, response, body){ + index.sendToCoveralls(obj, function(err, response, body){ + err.should.equal('err'); + response.should.equal('response'); + body.should.equal('body'); + done(); + }); + }); + + it ("allows sending to enterprise url", function(done){ + process.env.COVERALLS_ENDPOINT = 'https://coveralls-ubuntu.domain.com'; + sinon.stub(request, 'post', function(obj, cb){ + obj.url.should.equal('https://coveralls-ubuntu.domain.com/api/v1/jobs'); + obj.form.should.eql({json : '{"some":"obj"}'}); + cb('err', 'response', 'body'); + }); + + var obj = {"some":"obj"}; + index.sendToCoveralls(obj, function(err, response, body){ err.should.equal('err'); response.should.equal('response'); body.should.equal('body'); done(); - }); }); }); |
