diff --git a/index.js b/index.js index 9355eb2..88a6916 100644 --- a/index.js +++ b/index.js @@ -156,17 +156,17 @@ class ScmRouter extends Scm { /** * Returns whether auto deploy key generation is enabled on or not - * @method _autoDeployKeyGenerationEnabled + * @method autoDeployKeyGenerationEnabled * @param {Object} config Configuration * @param {String} config.scmContext Name of scm context - * @return {Promise} Resolves when operation completed without failure + * @return {Boolean} Resolves when operation completed without failure */ - _autoDeployKeyGenerationEnabled(config) { - return this.chooseScm(config).then(scm => scm.autoDeployKeyGenerationEnabled(config)); + autoDeployKeyGenerationEnabled(config) { + return this.scms[config.scmContext].autoDeployKeyGenerationEnabled(); } /** - * Parse the url for a repo for the specific source control + * Generate and add the public deploy key to the specific scm * @method _addDeployKey * @param {Object} config Configuration * @param {String} config.scmContext Name of scm context diff --git a/test/index.test.js b/test/index.test.js index dc63389..26873be 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -65,6 +65,7 @@ describe('index test', () => { mock.canHandleWebhook = sinon.stub().resolves(true); mock.getScmContexts = sinon.stub().returns([`${plugin}.context`]); mock.getDisplayName = sinon.stub().returns(plugin); + mock.autoDeployKeyGenerationEnabled = sinon.stub().returns(plugin); return mock; }; @@ -582,25 +583,6 @@ describe('index test', () => { }); }); - describe('_autoDeployKeyGenerationEnabled', () => { - const config = { scmContext: 'example.context' }; - - it('call origin autoDeployKeyGenerationEnabled', () => { - const scmGithub = scm.scms['github.context']; - const exampleScm = scm.scms['example.context']; - const scmGitlab = scm.scms['gitlab.context']; - - return scm._autoDeployKeyGenerationEnabled(config) - .then((result) => { - assert.strictEqual(result, 'example'); - assert.notCalled(scmGithub.autoDeployKeyGenerationEnabled); - assert.notCalled(scmGitlab.autoDeployKeyGenerationEnabled); - assert.calledOnce(exampleScm.autoDeployKeyGenerationEnabled); - assert.calledWith(exampleScm.autoDeployKeyGenerationEnabled, config); - }); - }); - }); - describe('_parseUrl', () => { const config = { scmContext: 'example.context' }; @@ -1003,6 +985,22 @@ describe('index test', () => { }); }); + describe('autoDeployKeyGenerationEnabled', () => { + const config = { scmContext: 'example.context' }; + + it('call origin autoDeployKeyGenerationEnabled', () => { + const scmGithub = scm.scms['github.context']; + const exampleScm = scm.scms['example.context']; + const scmGitlab = scm.scms['gitlab.context']; + const result = scm.autoDeployKeyGenerationEnabled(config); + + assert.strictEqual(result, 'example'); + assert.notCalled(scmGithub.autoDeployKeyGenerationEnabled); + assert.notCalled(scmGitlab.autoDeployKeyGenerationEnabled); + assert.calledOnce(exampleScm.autoDeployKeyGenerationEnabled); + }); + }); + describe('_getBranchList', () => { const config = { scmContext: 'example.context' };