mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Add regression tests
This commit is contained in:
parent
bb0ea88b95
commit
cf3df0e512
@ -327,7 +327,7 @@ describe('AwsCompileSNSEvents', () => {
|
||||
}).to.throw(Error);
|
||||
});
|
||||
|
||||
it('should create SNS topic when arn and topicName are given as object properties', () => {
|
||||
it('should create SNS topic when both arn and topicName are given as object properties', () => {
|
||||
awsCompileSNSEvents.serverless.service.functions = {
|
||||
first: {
|
||||
events: [
|
||||
@ -358,6 +358,74 @@ describe('AwsCompileSNSEvents', () => {
|
||||
).to.equal('AWS::Lambda::Permission');
|
||||
});
|
||||
|
||||
it('should create two SNS topic subsriptions for ARNs with the same topic name in two regions when different topicName parameters are specified', () => {
|
||||
awsCompileSNSEvents.serverless.service.functions = {
|
||||
first: {
|
||||
events: [
|
||||
{
|
||||
sns: {
|
||||
topicName: 'first',
|
||||
arn: 'arn:aws:sns:region-1:accountid:bar',
|
||||
},
|
||||
},
|
||||
{
|
||||
sns: {
|
||||
topicName: 'second',
|
||||
arn: 'arn:aws:sns:region-2:accountid:bar',
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
awsCompileSNSEvents.compileSNSEvents();
|
||||
|
||||
expect(
|
||||
Object.keys(
|
||||
awsCompileSNSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
|
||||
)
|
||||
).to.have.length(4);
|
||||
expect(
|
||||
awsCompileSNSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstSnsSubscriptionFirst.Type
|
||||
).to.equal('AWS::SNS::Subscription');
|
||||
expect(
|
||||
awsCompileSNSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstSnsSubscriptionSecond.Type
|
||||
).to.equal('AWS::SNS::Subscription');
|
||||
});
|
||||
|
||||
it('should override SNS topic subsription CF resource name when arn and topicName are given as object properties', () => {
|
||||
awsCompileSNSEvents.serverless.service.functions = {
|
||||
first: {
|
||||
events: [
|
||||
{
|
||||
sns: {
|
||||
topicName: 'foo',
|
||||
arn: 'arn:aws:sns:region:accountid:bar',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
awsCompileSNSEvents.compileSNSEvents();
|
||||
|
||||
expect(
|
||||
Object.keys(
|
||||
awsCompileSNSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
|
||||
)
|
||||
).to.have.length(2);
|
||||
expect(
|
||||
awsCompileSNSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstSnsSubscriptionFoo.Type
|
||||
).to.equal('AWS::SNS::Subscription');
|
||||
expect(
|
||||
awsCompileSNSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstLambdaPermissionFooSNS.Type
|
||||
).to.equal('AWS::Lambda::Permission');
|
||||
});
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
it('should create SNS topic when arn object and topicName are given as object properties', () => {
|
||||
awsCompileSNSEvents.serverless.service.functions = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user