mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Add resolving for bucket name retrieval when noDeploy option is set
This commit is contained in:
parent
bcc74df4dd
commit
ede355cc5d
@ -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;
|
||||
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user