diff --git a/lib/plugins/aws/deploy/lib/setBucketName.js b/lib/plugins/aws/deploy/lib/setBucketName.js index 5cc97b5c7..858407d75 100644 --- a/lib/plugins/aws/deploy/lib/setBucketName.js +++ b/lib/plugins/aws/deploy/lib/setBucketName.js @@ -1,7 +1,13 @@ 'use strict'; +const BbPromise = require('bluebird'); + module.exports = { setBucketName() { + if (this.options.noDeploy) { + return BbPromise.resolve(); + } + return this.sdk.getServerlessDeploymentBucketName(this.options.stage, this.options.region) .then((bucketName) => { this.bucketName = bucketName; diff --git a/lib/plugins/aws/deploy/tests/setBucketName.js b/lib/plugins/aws/deploy/tests/setBucketName.js index af780529f..c7249bd50 100644 --- a/lib/plugins/aws/deploy/tests/setBucketName.js +++ b/lib/plugins/aws/deploy/tests/setBucketName.js @@ -9,6 +9,7 @@ const BbPromise = require('bluebird'); describe('#setBucketName()', () => { let serverless; let awsDeploy; + let getServerlessDeploymentBucketNameStub; beforeEach(() => { serverless = new Serverless(); @@ -17,19 +18,28 @@ describe('#setBucketName()', () => { region: 'us-east-1', }; awsDeploy = new AwsDeploy(serverless, options); - }); - it('should store the name of the Serverless deployment bucket in the "this" variable', () => { - const getServerlessDeploymentBucketNameStub = sinon + getServerlessDeploymentBucketNameStub = sinon .stub(awsDeploy.sdk, 'getServerlessDeploymentBucketName') .returns(BbPromise.resolve('bucket-name')); + }); - return awsDeploy.setBucketName().then(() => { + it('should store the name of the Serverless deployment bucket', () => awsDeploy + .setBucketName().then(() => { expect(awsDeploy.bucketName).to.equal('bucket-name'); expect(getServerlessDeploymentBucketNameStub.calledOnce).to.be.equal(true); expect(getServerlessDeploymentBucketNameStub .calledWith(awsDeploy.options.stage, awsDeploy.options.region)); awsDeploy.sdk.getServerlessDeploymentBucketName.restore(); + }) + ); + + it('should resolve if no deploy', () => { + awsDeploy.options.noDeploy = true; + + return awsDeploy.setBucketName().then(() => { + expect(getServerlessDeploymentBucketNameStub.calledOnce).to.be.equal(false); + awsDeploy.sdk.getServerlessDeploymentBucketName.restore(); }); }); });