Add provider-level inheritance test

This commit is contained in:
Rafal Wilinski 2017-09-14 18:06:24 +02:00
parent 7ce86483ab
commit df145c45c8

View File

@ -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()', () => {