From 3d83b4f29f2dbf6f4a642ba24976d4ecbd5d56b1 Mon Sep 17 00:00:00 2001 From: Ben Petty <22062601+benpetty@users.noreply.github.com> Date: Thu, 19 Mar 2020 10:06:13 -0700 Subject: Set service_name and/or repo_token from .coveralls.yml regardless of if $COVERALLS_REPO_TOKEN is set (#272) * using TRAVIS_COMMIT environment variable for git_commit * Setting repo token and service name from .coveralls.yml regardless of if $COVERALLS_REPO_TOKEN * only set options.repo_token from coveralls_yaml_conf if set in .coveralls.yml * Update lib/getOptions.js Co-Authored-By: Derek Herman --- test/getOptions.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/getOptions.js b/test/getOptions.js index becb31f..5850dc2 100644 --- a/test/getOptions.js +++ b/test/getOptions.js @@ -45,6 +45,9 @@ describe('getBaseOptions', () => { it('should set service_name and service_job_id if it\'s running on travis-ci', done => { testTravisCi(getBaseOptions, done); }); + it('should set service_name and service_job_id if it\'s running on travis-pro', done => { + testTravisPro(getBaseOptions, done); + }); it('should set service_name and service_job_id if it\'s running on jenkins', done => { testJenkins(getBaseOptions, done); }); @@ -137,6 +140,9 @@ describe('getOptions', () => { it('should set service_name and service_job_id if it\'s running on travis-ci', done => { testTravisCi(getOptions, done); }); + it('should set service_name and service_job_id if it\'s running on travis-pro', done => { + testTravisPro(getOptions, done); + }); it('should set service_name and service_job_id if it\'s running on jenkins', done => { testJenkins(getOptions, done); }); @@ -350,6 +356,23 @@ const testTravisCi = (sut, done) => { }); }; +const testTravisPro = (sut, done) => { + const file = path.join(process.cwd(), '.coveralls.yml'); + const service_name = 'travis-pro'; + fs.writeFileSync(file, `service_name: ${service_name}`); + process.env.TRAVIS = 'TRUE'; + process.env.TRAVIS_JOB_ID = '1234'; + process.env.TRAVIS_COMMIT = 'a12s2d3df4f435g45g45g67h5g6'; + sut((err, options) => { + should.not.exist(err); + options.service_name.should.equal(service_name); + options.service_job_id.should.equal('1234'); + options.git.head.id.should.equal('a12s2d3df4f435g45g45g67h5g6'); + fs.unlinkSync(file); + done(); + }); +}; + const testJenkins = (sut, done) => { process.env.JENKINS_URL = 'something'; process.env.BUILD_ID = '1234'; -- cgit v1.2.3