From 596bb0eb98dcf383018dd6788cd6b131442e361f Mon Sep 17 00:00:00 2001 From: Erik Erikson Date: Thu, 15 Sep 2016 11:52:26 -0700 Subject: [PATCH] Fix the tests to use the updated log group reference TODO: verify the loggroup resource addition --- .../deploy/compile/functions/tests/index.js | 42 ++++--------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/lib/plugins/aws/deploy/compile/functions/tests/index.js b/lib/plugins/aws/deploy/compile/functions/tests/index.js index 4162e5145..c85f1decd 100644 --- a/lib/plugins/aws/deploy/compile/functions/tests/index.js +++ b/lib/plugins/aws/deploy/compile/functions/tests/index.js @@ -129,6 +129,7 @@ describe('AwsCompileFunctions', () => { }); it('should update IamPolicyLambdaExecution with a logging resource for the function', () => { + const normalizedName = `${functionName[0].toUpperCase()}${functionName.substr(1)}LogGroup`; awsCompileFunctions.compileFunctions(); expect(awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate @@ -140,17 +141,7 @@ describe('AwsCompileFunctions', () => { .Resource ).to.deep.equal( [ - { - 'Fn:Join': [ - ':', - [ - 'arn:aws:logs', - { Ref: 'AWS::Region' }, - { Ref: 'AWS::AccountId' }, - `log-group:/aws/lambda/${functionName}*:*:*`, - ], - ], - }, + { 'Fn:Join': [':', [{ 'Fn::GetAtt': [normalizedName, 'Arn'] }, '*', '*']] }, ] ); }); @@ -167,6 +158,11 @@ describe('AwsCompileFunctions', () => { name: 'func1', }, }; + const f = service.functions; + const normalizedNames = [ + `${f.func0.name[0].toUpperCase()}${f.func0.name.substr(1)}LogGroup`, + `${f.func1.name[0].toUpperCase()}${f.func1.name.substr(1)}LogGroup`, + ]; awsCompileFunctions.compileFunctions(); expect(awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate @@ -178,28 +174,8 @@ describe('AwsCompileFunctions', () => { .Resource ).to.deep.equal( [ - { - 'Fn:Join': [ - ':', - [ - 'arn:aws:logs', - { Ref: 'AWS::Region' }, - { Ref: 'AWS::AccountId' }, - `log-group:/aws/lambda/${service.functions.func0.name}*:*:*`, - ], - ], - }, - { - 'Fn:Join': [ - ':', - [ - 'arn:aws:logs', - { Ref: 'AWS::Region' }, - { Ref: 'AWS::AccountId' }, - `log-group:/aws/lambda/${service.functions.func1.name}*:*:*`, - ], - ], - }, + { 'Fn:Join': [':', [{ 'Fn::GetAtt': [normalizedNames[0], 'Arn'] }, '*', '*']] }, + { 'Fn:Join': [':', [{ 'Fn::GetAtt': [normalizedNames[1], 'Arn'] }, '*', '*']] }, ] ); });