[Pkg-javascript-commits] [node-coveralls] 99/332: export both getOptions and getBaseOptions from getOptions.js

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:53:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit 8078aa060a0361d358b069f92fa07af7f9e27bd4
Author: Matthew J. Morrison <mattjmorrison at mattjmorrison.com>
Date:   Fri Sep 6 22:31:08 2013 -0500

    export both getOptions and getBaseOptions from getOptions.js
    
    Also updated index.js to prevent any breaking API changes and added
    tests around both getOptions and getBaseOptions.
---
 index.js           |   2 +-
 lib/getOptions.js  |   4 +-
 test/getOptions.js | 202 +++++++++++++++++++++++++++++++++++------------------
 3 files changed, 136 insertions(+), 72 deletions(-)

diff --git a/index.js b/index.js
index fef5fd8..53cf95c 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,6 @@
 var dir = './lib/';
 exports.convertLcovToCoveralls = require(dir + 'convertLcovToCoveralls');
 exports.sendToCoveralls = require(dir + 'sendToCoveralls');
-exports.getOptions = require(dir + 'getOptions');
+exports.getOptions = require(dir + 'getOptions').getOptions;
 exports.handleInput = require(dir + 'handleInput');
 exports.logger = require(dir + 'logger');
diff --git a/lib/getOptions.js b/lib/getOptions.js
index 8ce948c..35187b4 100644
--- a/lib/getOptions.js
+++ b/lib/getOptions.js
@@ -98,5 +98,5 @@ var getOptions = function(cb){
   });
 };
 
-module.exports = getBaseOptions;
-module.exports = getOptions;
+module.exports.getBaseOptions = getBaseOptions;
+module.exports.getOptions = getOptions;
diff --git a/test/getOptions.js b/test/getOptions.js
index 67276af..87e5b80 100644
--- a/test/getOptions.js
+++ b/test/getOptions.js
@@ -1,5 +1,37 @@
 var should = require('should');
 var getOptions = require('../index').getOptions;
+var getBaseOptions = require('../lib/getOptions').getBaseOptions;
+
+
+describe("getBaseOptions", function(){
+  beforeEach(function(){
+    process.env = {};
+  });
+  it ("should set service_job_id if it exists", function(done){
+    testServiceJobId(getBaseOptions, done);
+  });
+  it ("should set git hash if it exists", function(done){
+    testGitHash(getBaseOptions, done);
+  });
+  it ("should set git branch if it exists", function(done){
+    testGitBranch(getBaseOptions, done);
+  });
+  it ("should set repo_token if it exists", function(done){
+    testRepoToken(getBaseOptions, done);
+  });
+  it ("should set service_name if it exists", function(done){
+    testServiceName(getBaseOptions, done);
+  });
+  it ("should set service_name and service_job_id if it's running on travis-ci", function(done){
+    testTravisCi(getBaseOptions, done);
+  });
+  it ("should set service_name and service_job_id if it's running on jenkins", function(done){
+    testJenkins(getBaseOptions, done);
+  });
+  it ("should set service_name and service_job_id if it's running on circleci", function(done){
+    testCircleCi(getBaseOptions, done);
+  });
+});
 
 describe("getOptions", function(){
   beforeEach(function(){
@@ -22,88 +54,120 @@ describe("getOptions", function(){
     });
   });
   it ("should set service_job_id if it exists", function(done){
-    process.env.COVERALLS_SERVICE_JOB_ID = "SERVICE_JOB_ID";
-    getOptions(function(err, options){
-      options.service_job_id.should.equal("SERVICE_JOB_ID");
-      done();
-    });
+    testServiceJobId(getOptions, done);
   });
   it ("should set git hash if it exists", function(done){
-    process.env.COVERALLS_GIT_COMMIT = "e3e3e3e3e3e3e3e3e";
-    getOptions(function(err, options){
-      options.git.head.id.should.equal("e3e3e3e3e3e3e3e3e");
-      done();
-    });
+    testGitHash(getOptions, done);
   });
-  it ("should set git hash if it exists", function(done){
-    process.env.COVERALLS_GIT_COMMIT = "e3e3e3e3e3e3e3e3e";
-    process.env.COVERALLS_GIT_BRANCH = "master";
-    getOptions(function(err, options){
-      options.git.branch.should.equal("master");
-      done();
-    });
+  it ("should set git branch if it exists", function(done){
+    testGitBranch(getOptions, done);
   });
   it ("should set repo_token if it exists", function(done){
-    process.env.COVERALLS_REPO_TOKEN = "REPO_TOKEN";
-    getOptions(function(err, options){
-      options.repo_token.should.equal("REPO_TOKEN");
-      done();
-    });
+    testRepoToken(getOptions, done);
   });
   it ("should set service_name if it exists", function(done){
-    process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME";
-    getOptions(function(err, options){
-      options.service_name.should.equal("SERVICE_NAME");
-      done();
-    });
+    testServiceName(getOptions, done);
   });
   it ("should set service_name and service_job_id if it's running on travis-ci", function(done){
-    process.env.TRAVIS = "TRUE";
-    process.env.TRAVIS_JOB_ID = "1234";
-    getOptions(function(err, options){
-      options.service_name.should.equal("travis-ci");
-      options.service_job_id.should.equal("1234");
-      done();
-    });
+    testTravisCi(getOptions, done);
   });
   it ("should set service_name and service_job_id if it's running on jenkins", function(done){
-    process.env.JENKINS_URL = "something";
-    process.env.BUILD_ID = "1234";
-    process.env.GIT_COMMIT = "a12s2d3df4f435g45g45g67h5g6";
-    process.env.GIT_BRANCH = "master";
-    getOptions(function(err, options){
-      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: [] });
-      done();
-    });
+    testJenkins(getOptions, done);
   });
   it ("should set service_name and service_job_id if it's running on circleci", function(done){
-    process.env.CIRCLECI = true;
-    process.env.CIRCLE_BRANCH = "master";
-    process.env.CIRCLE_BUILD_NUM = "1234";
-    process.env.CIRCLE_SHA1 = "e3e3e3e3e3e3e3e3e";
-    getOptions(function(err, options){
-      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: [] });
+    testCircleCi(getOptions, done);
+  });
+});
+
+var testServiceJobId = function(sut, done){
+    process.env.COVERALLS_SERVICE_JOB_ID = "SERVICE_JOB_ID";
+    sut(function(err, options){
+      options.service_job_id.should.equal("SERVICE_JOB_ID");
       done();
     });
+};
+
+var testGitHash = function(sut, done){
+  process.env.COVERALLS_GIT_COMMIT = "e3e3e3e3e3e3e3e3e";
+  sut(function(err, options){
+    options.git.head.id.should.equal("e3e3e3e3e3e3e3e3e");
+    done();
   });
-});
+};
+
+var testGitBranch = function(sut, done){
+  process.env.COVERALLS_GIT_COMMIT = "e3e3e3e3e3e3e3e3e";
+  process.env.COVERALLS_GIT_BRANCH = "master";
+  sut(function(err, options){
+    options.git.branch.should.equal("master");
+    done();
+  });
+};
+
+var testRepoToken = function(sut, done){
+  process.env.COVERALLS_REPO_TOKEN = "REPO_TOKEN";
+  sut(function(err, options){
+    options.repo_token.should.equal("REPO_TOKEN");
+    done();
+  });
+};
+
+var testServiceName = function(sut, done){
+  process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME";
+  sut(function(err, options){
+    options.service_name.should.equal("SERVICE_NAME");
+    done();
+  });
+};
+
+var testTravisCi = function(sut, done){
+  process.env.TRAVIS = "TRUE";
+  process.env.TRAVIS_JOB_ID = "1234";
+  sut(function(err, options){
+    options.service_name.should.equal("travis-ci");
+    options.service_job_id.should.equal("1234");
+    done();
+  });
+};
+
+var testJenkins = function(sut, done){
+  process.env.JENKINS_URL = "something";
+  process.env.BUILD_ID = "1234";
+  process.env.GIT_COMMIT = "a12s2d3df4f435g45g45g67h5g6";
+  process.env.GIT_BRANCH = "master";
+  sut(function(err, options){
+    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: [] });
+    done();
+  });
+};
+
+var testCircleCi = function(sut, done){
+  process.env.CIRCLECI = true;
+  process.env.CIRCLE_BRANCH = "master";
+  process.env.CIRCLE_BUILD_NUM = "1234";
+  process.env.CIRCLE_SHA1 = "e3e3e3e3e3e3e3e3e";
+  sut(function(err, options){
+    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: [] });
+    done();
+  });
+};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list