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

feat(assertions): add function for verifying the number of matching resource properties #21707

Merged
merged 3 commits into from
Sep 2, 2022

Conversation

ddneilson
Copy link
Contributor

@ddneilson ddneilson commented Aug 22, 2022

This PR adds the Template.resourcePropertiesCountIs() method for counting the number of resources of a specified type whose Properties section matches given properties.

Implements: #21706


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use 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

This PR adds the `Template.resourcePropertiesCountIs()` method
for counting the number of resources of a specified type whose
`Properties` section matches given properties.
@gitpod-io
Copy link

gitpod-io bot commented Aug 22, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team August 22, 2022 14:14
@github-actions github-actions bot added the p2 label Aug 22, 2022

// 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));
Copy link
Contributor Author

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.

@ddneilson
Copy link
Contributor Author

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.

@TheRealAmazonKendra TheRealAmazonKendra added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Sep 1, 2022
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a 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)

@ddneilson ddneilson changed the title feat(assertions): adds Template.resourcePropertiesCountIs() feat(assertions): new Template.resourcePropertiesCountIs() function is available Sep 1, 2022
@ddneilson ddneilson changed the title feat(assertions): new Template.resourcePropertiesCountIs() function is available feat(assertions): new Template.resourcePropertiesCountIs() method is available Sep 1, 2022
@mergify mergify bot dismissed TheRealAmazonKendra’s stale review September 1, 2022 15:59

Pull request has been modified.

@TheRealAmazonKendra TheRealAmazonKendra changed the title feat(assertions): new Template.resourcePropertiesCountIs() method is available feat(assertions): add function for verifying the number of matching resource properties Sep 2, 2022
@mergify
Copy link
Contributor

mergify bot commented Sep 2, 2022

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: a7fd853
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 80cb527 into aws:main Sep 2, 2022
@mergify
Copy link
Contributor

mergify bot commented Sep 2, 2022

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).

@ddneilson ddneilson deleted the ddneilson/resource_properties_count branch February 6, 2023 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants