Skip to content

Commit

Permalink
fix: spaces in FnSub literals are causing value to not be a literal
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Oct 13, 2022
1 parent 4937c4a commit 1d1f690
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions test/evaluate/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('Cloudformation templates', () => {
'cloudformation/condition-using-mapping.json', // does not look like a template
'cloudformation/find-in-map-for-boolean-property.json', // Expected string or list of strings, got: true
'cloudformation/find-in-map-with-dynamic-mapping.json', // Expected string, got: {"Ref":"Stage"}
'cloudformation/fn-sub-escaping.json', // No resource or parameter with name: ! DoesNotExist
'cloudformation/fn-sub-parsing-edges.json', // TypeError: Cannot read properties of null (reading 'Resources')
'cloudformation/fn-sub-shadow-attribute.json', // No resource or parameter with name: AnotherBucket
'cloudformation/functions-and-conditions.json', // Expected list of length 3, got 2
Expand All @@ -31,7 +30,6 @@ describe('Cloudformation templates', () => {
'cloudformation/parameter-references.json', // Expected string or list of strings, got: {"Name":"AWS::Include","Parameters":{"Location":{"Ref":"MyParam"}}}
'cloudformation/resource-attribute-creation-policy.json', // Expected number, got: {"Ref":"CountParameter"}
'cloudformation/resource-attribute-update-policy.json', // Expected boolean, got: {"Fn::Equals":["true",{"Ref":"WaitOnResourceSignals"}]}
'cloudformation/short-form-fnsub-string.yaml', // No resource or parameter with name: ! AWS::Region
];

testTemplateFixtures(
Expand Down
8 changes: 8 additions & 0 deletions test/parser/sub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ test('parsing and reconstituting are each others inverse', () => {
);
});

test('literal pattern can contain spaces around !', () => {
const parts = analyzeSubPattern('${ ! AWS::Region}-LogBucket');
expect(parts).toEqual([
{ type: 'literal', content: '${ ! AWS::Region}' },
{ type: 'literal', content: '-LogBucket' },
] as SubFragment[]);
});

/**
* Reconstitute a sub-string from a list of patterns
*/
Expand Down

0 comments on commit 1d1f690

Please # to comment.