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): allResources and allResourcesProperties methods #22007

Merged
merged 11 commits into from
Nov 2, 2022

Conversation

dontirun
Copy link
Contributor

Closes #21269


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

@gitpod-io
Copy link

gitpod-io bot commented Sep 12, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team September 12, 2022 18:32
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Sep 12, 2022
@dontirun
Copy link
Contributor Author

I don't think that I need to write an integration test for this PR, but please let me know if I do

Naumel
Naumel previously requested changes Sep 13, 2022
Copy link
Contributor

@Naumel Naumel left a comment

Choose a reason for hiding this comment

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

Hello,

Thank you for your engagement and submitting a review.

I would like to prod a bit more in the reasoning that is behind your thinking that integ tests should not be part of this review: mind adding the insight?

Comment on lines 20 to 21
if (result.match) {
if (result.mismatches) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How can a result both match and mismatch (naming might be decreasing the ease of reading)?

Why are there no tests for the new functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took another look at this and decided to take mismatches out of the MatchSuccess. I agree it's confusing and after testing the functionality I realized I wasn't getting the information that I wanted in the error output.

I reworked the functionality for easier readability and better messaging


```ts
template.allResources('Foo::Bar', {
Properties: { Foo: 'Bar' },
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark about disambiguating stands for this example.

if (closestResult === undefined || closestResult.failCount > result.failCount) {
closestResult = result;
}
}
},
);
if (Object.keys(matching).length > 0) {
return { match: true, matches: matching };
return { match: true, matches: matching, analyzedCount: count, mismatches: closestResult };
} else {
return { match: false, closestResult, analyzedCount: count };
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add testing for the change around count.

@dontirun
Copy link
Contributor Author

Hello,

Thank you for your engagement and submitting a review.

I would like to prod a bit more in the reasoning that is behind your thinking that integ tests should not be part of this review: mind adding the insight?

Unit tests are important here since we're changing functionality.

I don't think Integration tests make sense since we aren't changing anything related to CloudFormation resources/asset deployment.

@mergify mergify bot dismissed Naumel’s stale review September 13, 2022 14:17

Pull request has been modified.

Comment on lines +4 to +5
export type MatchSuccess = { match: true, matches: { [key: string]: any }, analyzed: { [key: string]: any }, analyzedCount: number };
export type MatchFailure = { match: false, closestResult?: MatchResult, analyzed: { [key: string]: any }, analyzedCount: number };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know we can technically remove analyzedCount here, but I kept it since it's being used in other places and convenient to use.

If we want I can remove this field and update the other places to use Object.keys(analyzed).length

@dontirun dontirun requested a review from Naumel September 16, 2022 12:15
@Naumel
Copy link
Contributor

Naumel commented Sep 16, 2022

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Sep 16, 2022

update

✅ Branch has been successfully updated

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

@dontirun
Copy link
Contributor Author

dontirun commented Oct 6, 2022

@Naumel Is this good to go, or are there other changes needed?

@joel-aws
Copy link
Contributor

As the submitter of issue #21269 (that this PR would close), I am really looking forward to seeing this merged!

@Naumel , are there any updates on the review?

Thanks!

@mergify mergify bot dismissed github-actions[bot]’s stale review October 19, 2022 21:39

Pull request has been modified.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@TheRealAmazonKendra TheRealAmazonKendra added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Nov 1, 2022
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 1, 2022 15:19

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

@mergify
Copy link
Contributor

mergify bot commented Nov 1, 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).

@kaizencc
Copy link
Contributor

kaizencc commented Nov 1, 2022

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Nov 1, 2022

refresh

✅ Pull request refreshed

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review November 1, 2022 15:33

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify
Copy link
Contributor

mergify bot commented Nov 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).

@mergify mergify bot merged commit 2430537 into aws:main Nov 2, 2022
@dontirun dontirun deleted the feat-match-all-resources branch November 2, 2022 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. 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.

(assertions): match properties against *all* resources of a given type
6 participants