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

many tests targeting annotations are brittle #19544

Closed
kaizencc opened this issue Mar 24, 2022 · 1 comment · Fixed by #19545
Closed

many tests targeting annotations are brittle #19544

kaizencc opened this issue Mar 24, 2022 · 1 comment · Fixed by #19545
Assignees
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@kaizencc
Copy link
Contributor

What is the problem?

See:

expect(target.node.metadataEntry).toEqual([{
type: 'aws:cdk:warning',
data: 'cron: If you don\'t pass \'minute\', by default the event runs every minute. Pass \'minute: \'*\'\' if that\'s what you intend, or \'minute: 0\' to run once per hour instead.',
trace: undefined,
}]);

And many more places in the CDK. The problem is that they assert on a specific node.metadataentry, but if we ever add a different message to the node metadata, this test will fail.

This happens many times when we add warnings around the CDK, see #19464.

Reproduction Steps

see linked file.

What did you expect to happen?

These tests should be changed to:

Annotations.fromStack(stack).hasWarning('/Path/To/Node', 'warning message');

also:

Annotations.fromStack(stack).hasNoWarning('/Path/To/Node', 'warning message');

This will be more robust as it does not depend on the existence/non-existence of other messages on the node.

What actually happened?

Possible failing tests in the future.

CDK CLI Version

latest

Framework Version

No response

Node.js Version

latest

OS

Mac

Language

Typescript

Language Version

No response

Other information

No response

@kaizencc kaizencc added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 24, 2022
@kaizencc kaizencc self-assigned this Mar 24, 2022
@mergify mergify bot closed this as completed in #19545 Mar 25, 2022
mergify bot pushed a commit that referenced this issue Mar 25, 2022
Does this for everything except the tests in core that are specifically testing `Aspects`. There's less of a chance that those tests are disturbed by adding annotations elsewhere in the CDK.

Closes #19544 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

StevePotter pushed a commit to StevePotter/aws-cdk that referenced this issue Apr 27, 2022
Does this for everything except the tests in core that are specifically testing `Aspects`. There's less of a chance that those tests are disturbed by adding annotations elsewhere in the CDK.

Closes aws#19544 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant