mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Fix functionality / add tests
This commit is contained in:
parent
03cc4d4a48
commit
2a075af805
@ -85,6 +85,9 @@ class AwsCompileSQSEvents {
|
||||
return EventSourceArn['Fn::GetAtt'][0];
|
||||
} else if (EventSourceArn['Fn::ImportValue']) {
|
||||
return EventSourceArn['Fn::ImportValue'];
|
||||
} else if (EventSourceArn['Fn::Join']) {
|
||||
// [0] is the used delimiter, [1] is the array with values
|
||||
return EventSourceArn['Fn::Join'][1].slice(-1).pop();
|
||||
}
|
||||
return EventSourceArn.split(':').pop();
|
||||
}());
|
||||
|
||||
@ -391,18 +391,29 @@ describe('AwsCompileSQSEvents', () => {
|
||||
arn: { 'Fn::ImportValue': 'ForeignQueue' },
|
||||
},
|
||||
},
|
||||
{
|
||||
sqs: {
|
||||
arn: {
|
||||
'Fn::Join': [
|
||||
':', [
|
||||
'arn', 'aws', 'sqs', {
|
||||
Ref: 'AWS::Region',
|
||||
},
|
||||
{
|
||||
Ref: 'AWS::AccountId',
|
||||
},
|
||||
'MyQueue',
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
awsCompileSQSEvents.compileSQSEvents();
|
||||
|
||||
expect(awsCompileSQSEvents.serverless.service
|
||||
.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstEventSourceMappingSQSSomeQueue.Properties.EventSourceArn
|
||||
).to.deep.equal(
|
||||
{ 'Fn::GetAtt': ['SomeQueue', 'Arn'] }
|
||||
);
|
||||
expect(awsCompileSQSEvents.serverless.service
|
||||
.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution
|
||||
.Properties.Policies[0].PolicyDocument.Statement[0]
|
||||
@ -424,18 +435,62 @@ describe('AwsCompileSQSEvents', () => {
|
||||
{
|
||||
'Fn::ImportValue': 'ForeignQueue',
|
||||
},
|
||||
{
|
||||
'Fn::Join': [
|
||||
':',
|
||||
[
|
||||
'arn',
|
||||
'aws',
|
||||
'sqs',
|
||||
{
|
||||
Ref: 'AWS::Region',
|
||||
},
|
||||
{
|
||||
Ref: 'AWS::AccountId',
|
||||
},
|
||||
'MyQueue',
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
expect(awsCompileSQSEvents.serverless.service
|
||||
.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstEventSourceMappingSQSSomeQueue.Properties.EventSourceArn
|
||||
).to.deep.equal(
|
||||
{ 'Fn::GetAtt': ['SomeQueue', 'Arn'] }
|
||||
);
|
||||
expect(awsCompileSQSEvents.serverless.service
|
||||
.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstEventSourceMappingSQSForeignQueue.Properties.EventSourceArn
|
||||
).to.deep.equal(
|
||||
{ 'Fn::ImportValue': 'ForeignQueue' }
|
||||
);
|
||||
expect(awsCompileSQSEvents.serverless.service
|
||||
.provider.compiledCloudFormationTemplate.Resources
|
||||
.FirstEventSourceMappingSQSMyQueue.Properties.EventSourceArn
|
||||
).to.deep.equal(
|
||||
{
|
||||
'Fn::Join': [
|
||||
':',
|
||||
[
|
||||
'arn',
|
||||
'aws',
|
||||
'sqs',
|
||||
{
|
||||
Ref: 'AWS::Region',
|
||||
},
|
||||
{
|
||||
Ref: 'AWS::AccountId',
|
||||
},
|
||||
'MyQueue',
|
||||
],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('fails if keys other than Fn::GetAtt/ImportValue are used for dynamic queue ARN', () => {
|
||||
it('fails if keys other than Fn::GetAtt/ImportValue/Join are used for dynamic ARNs', () => {
|
||||
awsCompileSQSEvents.serverless.service.functions = {
|
||||
first: {
|
||||
events: [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user