-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(assertions): add function for verifying the number of matching resource properties #21707
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
feat(assertions): add function for verifying the number of matching resource properties #21707
Conversation
This PR adds the `Template.resourcePropertiesCountIs()` method for counting the number of resources of a specified type whose `Properties` section matches given properties.
|
||
// special case to exclude AbsentMatch because adding an empty Properties object will affect its evaluation. | ||
if (!Matcher.isMatcher(props) || !(props instanceof AbsentMatch)) { | ||
// amended needs to be a deep copy to avoid modifying the template. | ||
amended = JSON.parse(JSON.stringify(template)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bonus little optimization that I noticed while in the code. Unconditionally stringifying and parsing a template will negatively impact performance; those are not cheap operations.
Regarding the PR Linter failure. It is failing due to this PR not adding integ tests. There are no integ tests in the assertions module; it's a testing module, not a constructs module. I see no point in adding integ tests of some sort to that module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure that your PR title confirms to the conventional commit standard (fix, feat, chore) and that it is written in a style that will reflect correctly in the change log (See Contributing Guide, Pull Requests)
Pull request has been modified.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This PR adds the
Template.resourcePropertiesCountIs()
method for counting the number of resources of a specified type whoseProperties
section matches given properties.Implements: #21706
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license