From d4cb2b6684f09dc67ea1de43edbb3adad8a394f6 Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 18 Jan 2019 06:19:43 +0900 Subject: [PATCH] Add tests. --- .../aws/deploy/lib/checkForChanges.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/plugins/aws/deploy/lib/checkForChanges.test.js b/lib/plugins/aws/deploy/lib/checkForChanges.test.js index 5345f397b..d5542c18d 100644 --- a/lib/plugins/aws/deploy/lib/checkForChanges.test.js +++ b/lib/plugins/aws/deploy/lib/checkForChanges.test.js @@ -135,6 +135,23 @@ describe('checkForChanges', () => { }); }); + it('should translate error if rejected due to missing bucket', () => { + listObjectsV2Stub + .rejects(new serverless.classes.Error('The specified bucket does not exist')); + + return expect(awsDeploy.getMostRecentObjects()).to.be.rejectedWith([ + `The serverless deployment bucket "${awsDeploy.bucketName}" does not exist.`, + 'Create it manually if you want to reuse the CloudFormation stack "my-service-dev",', + 'or delete the stack then run "sls deploy".', + ].join(' ')); + }); + + it('should throw original error if rejected not due to missing bucket', () => { + listObjectsV2Stub + .rejects(new serverless.classes.Error('Other reason')); + return expect(awsDeploy.getMostRecentObjects()).to.be.rejectedWith('Other reason'); + }); + it('should resolve if result array is empty', () => { const serviceObjects = { Contents: [],