Skip to content

Commit

Permalink
add test for existing topic subscription with filter policy
Browse files Browse the repository at this point in the history
  • Loading branch information
laardee committed Aug 19, 2018
1 parent f40f2ab commit 1a7ab6d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/plugins/aws/package/compile/events/sns/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,39 @@ describe('AwsCompileSNSEvents', () => {
.provider.compiledCloudFormationTemplate.Resources.FirstLambdaPermissionBarSNS.Type
).to.equal('AWS::Lambda::Permission');
});

it('should create SNS topic when arn, topicName, and filterPolicy are given as object', () => {
awsCompileSNSEvents.serverless.service.functions = {
first: {
events: [
{
sns: {
topicName: 'bar',
arn: 'arn:aws:sns:region:accountid:bar',
filterPolicy: {
pet: ['dog', 'cat'],
},
},
},
],
},
};

awsCompileSNSEvents.compileSNSEvents();

expect(Object.keys(awsCompileSNSEvents.serverless.service
.provider.compiledCloudFormationTemplate.Resources)
).to.have.length(2);
expect(awsCompileSNSEvents.serverless.service
.provider.compiledCloudFormationTemplate.Resources.FirstSnsSubscriptionBar.Type
).to.equal('AWS::SNS::Subscription');
expect(awsCompileSNSEvents.serverless.service
.provider.compiledCloudFormationTemplate
.Resources.FirstSnsSubscriptionBar.Properties.FilterPolicy
).to.eql({ pet: ['dog', 'cat'] });
expect(awsCompileSNSEvents.serverless.service
.provider.compiledCloudFormationTemplate.Resources.FirstLambdaPermissionBarSNS.Type
).to.equal('AWS::Lambda::Permission');
});
});
});

0 comments on commit 1a7ab6d

Please sign in to comment.