Skip to content

Commit

Permalink
replace BbPromise with native Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed May 12, 2021
1 parent acba8ca commit f354536
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 5 additions & 4 deletions deploy/lib/setIamPolicy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';

const BbPromise = require('bluebird');
const ServerlessError = require('serverless/lib/classes/Error').ServerlessError;

module.exports = {
setIamPolicy() {
return BbPromise.bind(this).then(this.getFunctions).then(this.setPolicies);
return Promise.resolve()
.then(() => this.getFunctions())
.then(() => this.setPolicies());
},

getFunctions() {
Expand All @@ -29,7 +30,7 @@ module.exports = {
// If there are no IAM policies configured with any function, there is nothing to
// do here.
if (!policies || !Object.keys(policies).length) {
return BbPromise.resolve();
return Promise.resolve();
}
this.serverless.cli.log('Setting IAM policies...');

Expand Down Expand Up @@ -67,6 +68,6 @@ module.exports = {
}
});

return BbPromise.all(promises);
return Promise.all(promises);
},
};
11 changes: 5 additions & 6 deletions deploy/lib/setIamPolicy.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const sinon = require('sinon');
const BbPromise = require('bluebird');

const GoogleProvider = require('../../provider/googleProvider');
const GoogleDeploy = require('../googleDeploy');
Expand Down Expand Up @@ -39,8 +38,8 @@ describe('SetIamPolicy', () => {
let setPoliciesStub;

beforeEach(() => {
getFunctionsStub = sinon.stub(googleDeploy, 'getFunctions').returns(BbPromise.resolve());
setPoliciesStub = sinon.stub(googleDeploy, 'setPolicies').returns(BbPromise.resolve());
getFunctionsStub = sinon.stub(googleDeploy, 'getFunctions').returns(Promise.resolve());
setPoliciesStub = sinon.stub(googleDeploy, 'setPolicies').returns(Promise.resolve());
});

afterEach(() => {
Expand All @@ -58,7 +57,7 @@ describe('SetIamPolicy', () => {

describe('#getFunctions', () => {
it('should return "undefined" if no functions are found', () => {
requestStub.returns(BbPromise.resolve([]));
requestStub.returns(Promise.resolve([]));

return googleDeploy.getFunctions().then((foundFunctions) => {
expect(foundFunctions).toEqual(undefined);
Expand All @@ -81,7 +80,7 @@ describe('SetIamPolicy', () => {
const response = {
functions: [{ name: 'cloud-function-1' }, { name: 'cloud-function-2' }],
};
requestStub.returns(BbPromise.resolve(response));
requestStub.returns(Promise.resolve(response));

return googleDeploy.getFunctions().then((foundFunctions) => {
expect(foundFunctions).toEqual([
Expand Down Expand Up @@ -160,7 +159,7 @@ describe('SetIamPolicy', () => {
googleDeploy.serverless.service.provider.functionIamBindings = {
'cloud-function-2': [{ role: 'roles/cloudfunctions.invoker', members: ['allUsers'] }],
};
requestStub.returns(BbPromise.resolve());
requestStub.returns(Promise.resolve());

return googleDeploy.setPolicies(foundFunctions).then(() => {
expect(consoleLogStub.calledOnce).toEqual(true);
Expand Down

0 comments on commit f354536

Please sign in to comment.