Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(assertions): remove unnecessary condition for if statement in Template #32028

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/assertions/lib/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Template {

private constructor(template: { [key: string]: any }, templateParsingOptions: TemplateParsingOptions = {}) {
this.template = template as TemplateType;
if (!templateParsingOptions?.skipCyclicalDependenciesCheck ?? true) {
if (!templateParsingOptions.skipCyclicalDependenciesCheck) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a comment to confirm that skipCyclicalDependenciesCheck is meant to default to false, as is the behavior here.

checkTemplateForCyclicDependencies(this.template);
}
}
Expand Down
23 changes: 22 additions & 1 deletion packages/aws-cdk-lib/assertions/test/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,28 @@ describe('Template', () => {
}).toThrow(/dependency cycle/);
});

test('does not throw when given a template with cyclic dependencies if check is skipped', () => {
test('throws when given a template with cyclic dependencies if skipCyclicalDependenciesCheck is false', () => {
Copy link
Contributor Author

@go-to-k go-to-k Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests for the undefined case already exists above this test.

In the case of true, not.toThrow is used, so I didn't summarize with test.each.

expect(() => {
Template.fromJSON({
Resources: {
Res1: {
Type: 'Foo',
Properties: {
Thing: { Ref: 'Res2' },
},
},
Res2: {
Type: 'Foo',
DependsOn: ['Res1'],
},
},
}, {
skipCyclicalDependenciesCheck: false,
});
}).toThrow(/dependency cycle/);
});

test('does not throw when given a template with cyclic dependencies if skipCyclicalDependenciesCheck is true', () => {
expect(() => {
Template.fromJSON({
Resources: {
Expand Down
Loading