1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
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");
});
it ("should get a filepath if there is one, even in verbose mode", 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 hash if it exists", function(){
process.env.COVERALLS_GIT_COMMIT = "e3e3e3e3e3e3e3e3e";
getOptions().git.head.id.should.equal("e3e3e3e3e3e3e3e3e");
});
it ("should set git hash if it exists", function(){
process.env.COVERALLS_GIT_COMMIT = "e3e3e3e3e3e3e3e3e";
process.env.COVERALLS_GIT_BRANCH = "master";
getOptions().git.branch.should.equal("master");
});
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");
});
it ("should set service_name and service_job_id if it's running on jenkins", function(){
process.env.JENKINS_URL = "something";
process.env.BUILD_ID = "1234";
process.env.GIT_COMMIT = "a12s2d3df4f435g45g45g67h5g6";
process.env.GIT_BRANCH = "master";
var options = getOptions();
options.service_name.should.equal("jenkins");
options.service_job_id.should.equal("1234");
options.git.should.eql({ head:
{ id: 'a12s2d3df4f435g45g45g67h5g6',
author_name: 'Unknown Author',
author_email: '',
committer_name: 'Unknown Committer',
committer_email: '',
message: 'Unknown Commit Message' },
branch: 'master',
remotes: [] });
});
it ("should set service_name and service_job_id if it's running on circleci", function(){
process.env.CIRCLECI = true;
process.env.CIRCLE_BRANCH = "master";
process.env.CIRCLE_BUILD_NUM = "1234";
process.env.CIRCLE_SHA1 = "e3e3e3e3e3e3e3e3e";
var options = getOptions();
options.service_name.should.equal("circleci");
options.service_job_id.should.equal("1234");
options.git.should.eql({ head:
{ id: 'e3e3e3e3e3e3e3e3e',
author_name: 'Unknown Author',
author_email: '',
committer_name: 'Unknown Committer',
committer_email: '',
message: 'Unknown Commit Message' },
branch: 'master',
remotes: [] });
});
});
|