Merge pull request #1921 from serverless/fix-no-deploy-errors-when-stack-not-created

Fix noDeploy errors when stack is not created
This commit is contained in:
Philipp Muens 2016-08-22 15:37:37 +02:00 committed by GitHub
commit fedc5369b4
2 changed files with 50 additions and 22 deletions

View File

@ -16,14 +16,20 @@ class AwsInfo {
this.hooks = {
'info:info': () => BbPromise.bind(this)
.then(this.validate)
.then(this.gather)
.then(this.display),
.then(this.validate)
.then(this.gather)
.then(this.display),
'deploy:deploy': () => BbPromise.bind(this)
.then(this.validate)
.then(this.gather)
.then(this.display),
.then(() => {
if (this.options.noDeploy) {
return BbPromise.resolve();
}
return BbPromise.bind(this)
.then(this.validate)
.then(this.gather)
.then(this.display);
}),
};
}
@ -38,8 +44,7 @@ class AwsInfo {
region: this.options.region,
};
// Get info from CLF Outputs
// Get info from CloudFormation Outputs
return this.sdk.request('CloudFormation',
'describeStacks',
{ StackName: stackName },

View File

@ -69,22 +69,45 @@ describe('AwsInfo', () => {
});
});
it('should run promise chain in order for deploy hook', () => {
const validateStub = sinon
.stub(awsInfo, 'validate').returns(BbPromise.resolve());
const gatherStub = sinon
.stub(awsInfo, 'gather').returns(BbPromise.resolve());
const displayStub = sinon
.stub(awsInfo, 'display').returns(BbPromise.resolve());
describe('when running "deploy:deploy" hook', () => {
it('should run promise chain in order if no deploy is not set', () => {
const validateStub = sinon
.stub(awsInfo, 'validate').returns(BbPromise.resolve());
const gatherStub = sinon
.stub(awsInfo, 'gather').returns(BbPromise.resolve());
const displayStub = sinon
.stub(awsInfo, 'display').returns(BbPromise.resolve());
return awsInfo.hooks['deploy:deploy']().then(() => {
expect(validateStub.calledOnce).to.be.equal(true);
expect(gatherStub.calledAfter(validateStub)).to.be.equal(true);
expect(displayStub.calledAfter(gatherStub)).to.be.equal(true);
return awsInfo.hooks['deploy:deploy']().then(() => {
expect(validateStub.calledOnce).to.be.equal(true);
expect(gatherStub.calledAfter(validateStub)).to.be.equal(true);
expect(displayStub.calledAfter(gatherStub)).to.be.equal(true);
awsInfo.validate.restore();
awsInfo.gather.restore();
awsInfo.display.restore();
awsInfo.validate.restore();
awsInfo.gather.restore();
awsInfo.display.restore();
});
});
it('should resolve if no deploy', () => {
awsInfo.options.noDeploy = true;
const validateStub = sinon
.stub(awsInfo, 'validate').returns(BbPromise.resolve());
const gatherStub = sinon
.stub(awsInfo, 'gather').returns(BbPromise.resolve());
const displayStub = sinon
.stub(awsInfo, 'display').returns(BbPromise.resolve());
return awsInfo.hooks['deploy:deploy']().then(() => {
expect(validateStub.calledOnce).to.be.equal(false);
expect(gatherStub.calledOnce).to.be.equal(false);
expect(displayStub.calledOnce).to.be.equal(false);
awsInfo.validate.restore();
awsInfo.gather.restore();
awsInfo.display.restore();
});
});
});
});