From 771ec6a490e11e6a31a5690110c50f5375c91733 Mon Sep 17 00:00:00 2001 From: Thomas Kurpick Date: Mon, 28 May 2018 19:01:27 +0200 Subject: [PATCH 1/3] append environment variable BS_LOCALIDENTIFIER_POSTFIX to given localIdentifier from gemini config --- lib/plugin.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/plugin.js b/lib/plugin.js index 88919cf..dd4cb4a 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -19,6 +19,10 @@ module.exports = function(gemini, opts) { var browserStack = BrowserStack(); expandCredentials(opts); + + if (process.env.BS_LOCALIDENTIFIER_POSTFIX && opts.localIdentifier) { + opts.localIdentifier += '-' + process.env.BS_LOCALIDENTIFIER_POSTFIX; + } gemini.on('startRunner', function(runner) { var deferred = Q.defer(); From 74651fee9cd74adaee731aa7c501ae7707eae103 Mon Sep 17 00:00:00 2001 From: Thomas Kurpick Date: Tue, 29 May 2018 09:22:47 +0200 Subject: [PATCH 2/3] add unit test for env postfix variable --- test/plugin.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/plugin.js b/test/plugin.js index ac7e955..e24c063 100644 --- a/test/plugin.js +++ b/test/plugin.js @@ -93,6 +93,23 @@ describe('plugin', function() { expect(gemini.config._browsers.chrome.desiredCapabilities['browserstack.localIdentifier']).to.equal('abc123'); }); + it ('should read localIdentifier postfix from env', function() { + process.env.BS_LOCALIDENTIFIER_POSTFIX = 'foo'; + + var opts = {username: 'foo', accessKey: 'bar', localIdentifier: "abc123"}; + gemini.config._browsers = {'chrome': {desiredCapabilities: {platform: 'Windows'}}}; + + plugin(gemini, opts); + + browserstack.start = function(opts, cb) { + cb(null, {}); + }; + + gemini['startRunner']() + + expect(gemini.config._browsers.chrome.desiredCapabilities['browserstack.localIdentifier']).to.equal('abc123-foo'); + }); + function init() { plugin(gemini, {username: 'foo', accessKey: 'bar'}); }; From 5ef8caf7269005c233f90f3d2f4b444589bf0c0f Mon Sep 17 00:00:00 2001 From: Thomas Kurpick Date: Tue, 29 May 2018 09:26:01 +0200 Subject: [PATCH 3/3] add negative test for env variable --- test/plugin.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/plugin.js b/test/plugin.js index e24c063..654f710 100644 --- a/test/plugin.js +++ b/test/plugin.js @@ -110,6 +110,23 @@ describe('plugin', function() { expect(gemini.config._browsers.chrome.desiredCapabilities['browserstack.localIdentifier']).to.equal('abc123-foo'); }); + it ('should not use localIdentifier postfix from env when localIdentifier in configuration is not set', function() { + process.env.BS_LOCALIDENTIFIER_POSTFIX = 'foo'; + + var opts = {username: 'foo', accessKey: 'bar'}; + gemini.config._browsers = {'chrome': {desiredCapabilities: {platform: 'Windows'}}}; + + plugin(gemini, opts); + + browserstack.start = function(opts, cb) { + cb(null, {}); + }; + + gemini['startRunner']() + + expect(gemini.config._browsers.chrome.desiredCapabilities['browserstack.localIdentifier']).to.be.undefined; + }); + function init() { plugin(gemini, {username: 'foo', accessKey: 'bar'}); };