Skip to content

Commit

Permalink
removed redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
comcalvi committed Feb 1, 2022
1 parent acc0142 commit 38b5723
Showing 1 changed file with 0 additions and 113 deletions.
113 changes: 0 additions & 113 deletions packages/aws-cdk/test/api/cloudformation-deployments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,119 +844,6 @@ test('readCurrentTemplateWithNestedStacks() succesfully ignores stacks without m
});
});

test('readCurrentTemplateWithNestedStacks() does not erase the AWS::CloudFormation::Stack resource properties', async () => {
// GIVEN
const cfnStack = instanceMockFrom((CloudFormationStack as any));
CloudFormationStack.lookup = jest.fn().mockImplementation((_cfn: CloudFormation, stackName: string) => {
if (stackName === 'Root') {
(cfnStack as any).template = jest.fn().mockReturnValue({
Resources: {
WithProperties: {
Type: 'AWS::CloudFormation::Stack',
Properties: {
TemplateURL: 'https://www.magic-url.com',
TimeoutInMinutes: 5,
},
Metadata: {
'aws:asset:path': 'one-resource-stack.nested.template.json',
},
},
},
});

} else {
(cfnStack as any).template = jest.fn().mockReturnValue({
Resources: {
SomeResource: {
Type: 'AWS::Something',
Properties: {
Property: 'old-value',
},
},
},
});
}

return cfnStack;
});

const rootStack = testStack({
stackName: 'Root',
template: {
Resources: {
WithProperties: {
Type: 'AWS::CloudFormation::Stack',
Properties: {
TemplateURL: 'https://www.magic-url.com',
TimeoutInMinutes: 5,
},
Metadata: {
'aws:asset:path': 'one-resource-stack.nested.template.json',
},
},
},
},
});

pushStackResourceSummaries('Root', stackSummaryOf('WithProperties', 'AWS::CloudFormation::Stack',
'arn:aws:cloudformation:bermuda-triangle-1337:123456789012:stack/one-resource-stack/abcd',
));

// WHEN
const deployedTemplate = await deployments.readCurrentTemplateWithNestedStacks(rootStack);

// THEN
expect(deployedTemplate).toEqual({
Resources: {
WithProperties: {
Type: 'AWS::CloudFormation::Stack',
Properties: {
TimeoutInMinutes: 5,
TemplateURL: 'https://www.magic-url.com',
NestedTemplate: {
Resources: {
SomeResource: {
Type: 'AWS::Something',
Properties: {
Property: 'old-value',
},
},
},
},
},
Metadata: {
'aws:asset:path': 'one-resource-stack.nested.template.json',
},
},
},
});

expect(rootStack.template).toEqual({
Resources: {
WithProperties: {
Type: 'AWS::CloudFormation::Stack',
Properties: {
TemplateURL: 'https://www.magic-url.com',
TimeoutInMinutes: 5,
NestedTemplate: {
Resources: {
SomeResource: {
Type: 'AWS::Something',
Properties: {
Property: 'new-value',
},
},
},
},
},
Metadata: {
'aws:asset:path': 'one-resource-stack.nested.template.json',
},
},
},
});
});

function pushStackResourceSummaries(stackName: string, ...items: CloudFormation.StackResourceSummary[]) {
if (!currentCfnStackResources[stackName]) {
currentCfnStackResources[stackName] = [];
Expand Down

0 comments on commit 38b5723

Please sign in to comment.