mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const expect = require('chai').expect;
|
|
const sinon = require('sinon');
|
|
const AwsDeploy = require('../index');
|
|
const Serverless = require('../../../../Serverless');
|
|
const BbPromise = require('bluebird');
|
|
|
|
describe('#setBucketName()', () => {
|
|
let serverless;
|
|
let awsDeploy;
|
|
let getServerlessDeploymentBucketNameStub;
|
|
|
|
beforeEach(() => {
|
|
serverless = new Serverless();
|
|
const options = {
|
|
stage: 'dev',
|
|
region: 'us-east-1',
|
|
};
|
|
awsDeploy = new AwsDeploy(serverless, options);
|
|
|
|
getServerlessDeploymentBucketNameStub = sinon
|
|
.stub(awsDeploy.sdk, 'getServerlessDeploymentBucketName')
|
|
.returns(BbPromise.resolve('bucket-name'));
|
|
});
|
|
|
|
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();
|
|
});
|
|
});
|
|
});
|