From df145c45c8a786adc9da95bdbf04c1656b2fa3e7 Mon Sep 17 00:00:00 2001 From: Rafal Wilinski Date: Thu, 14 Sep 2017 18:06:24 +0200 Subject: [PATCH] Add provider-level inheritance test --- lib/plugins/aws/deployFunction/index.test.js | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lib/plugins/aws/deployFunction/index.test.js b/lib/plugins/aws/deployFunction/index.test.js index cb6fe0d43..7810e4d96 100644 --- a/lib/plugins/aws/deployFunction/index.test.js +++ b/lib/plugins/aws/deployFunction/index.test.js @@ -135,6 +135,10 @@ describe('AwsDeployFunction', () => { afterEach(() => { awsDeployFunction.provider.request.restore(); + awsDeployFunction.serverless.service.provider.timeout = undefined; + awsDeployFunction.serverless.service.provider.memorySize = undefined; + awsDeployFunction.serverless.service.provider.role = undefined; + awsDeployFunction.serverless.service.provider.vpc = undefined; }); it('should update function\'s configuration', () => { @@ -211,6 +215,44 @@ describe('AwsDeployFunction', () => { )).to.be.equal(true); }); }); + + it('should inherit provider-level config', () => { + options.functionObj = { + name: 'first', + description: 'change', + }; + + awsDeployFunction.serverless.service.provider.timeout = 12; + awsDeployFunction.serverless.service.provider.memorySize = 512; + awsDeployFunction.serverless.service.provider.role = 'role'; + awsDeployFunction.serverless.service.provider.vpc = { + securityGroupIds: [123, 12], + subnetIds: [1234, 12345], + }; + + awsDeployFunction.options = options; + + return awsDeployFunction.updateFunctionConfiguration().then(() => { + expect(updateFunctionConfigurationStub.calledOnce).to.be.equal(true); + expect(updateFunctionConfigurationStub.calledWithExactly( + 'Lambda', + 'updateFunctionConfiguration', + { + FunctionName: 'first', + Description: 'change', + VpcConfig: { + SubnetIds: [1234, 12345], + SecurityGroupIds: [123, 12], + }, + Timeout: 12, + MemorySize: 512, + Role: 'role', + }, + awsDeployFunction.options.stage, + awsDeployFunction.options.region + )).to.be.equal(true); + }); + }); }); describe('#deployFunction()', () => {