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 the hasNoXXX methods. #19330

Merged
merged 12 commits into from
Mar 15, 2022

Conversation

joe-king-sh
Copy link
Contributor

@joe-king-sh joe-king-sh commented Mar 10, 2022

This PR adds hasNoError, hasNoWarning, and hasNoInfo methods to the Annotations assertions toolkit.

Fixes #18874


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 Mar 10, 2022

@github-actions github-actions bot added the @aws-cdk/assertions Related to the @aws-cdk/assertv2 package label Mar 10, 2022
@joe-king-sh joe-king-sh marked this pull request as ready for review March 10, 2022 16:17
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this @joe-king-sh! Can you add a line or two about these APIs in the README?

@mergify mergify bot dismissed kaizencc’s stale review March 11, 2022 00:15

Pull request has been modified.

@joe-king-sh
Copy link
Contributor Author

@kaizen3031593
I added descriptions of hasNoXXX APIs.
If I have to go into more detail, please let me know.

Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Looks great @joe-king-sh! A few minor nits, along with changing the error message to be more descriptive.

return;
}

return `Stack has ${Object.keys(result.matches).length} messages.`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return `Stack has ${Object.keys(result.matches).length} messages.`;
return `Expected no matches, but stack has ${Object.keys(result.matches).length} messages.`;

Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to the above change, I think we should also be returning the matched messages in the error message.

It's possible someone looks for annotations.hasNoError('/Default/Fred', Match.anyValue()) and they should be able to know what error message they are getting.

});

test('no match', () => {
expect(() => annotations.hasNoInfo('/Default/Qux', 'this is an info')).toThrowError(/Stack has 1 messages./);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(() => annotations.hasNoInfo('/Default/Qux', 'this is an info')).toThrowError(/Stack has 1 messages./);
expect(() => annotations.hasNoInfo('/Default/Qux', 'this is an info'))
.toThrowError(/Stack has 1 messages./);

Comment on lines 553 to 555
- `hasError()`, `findError()` and `hasNoError()`
- `hasWarning()`,`findWarning()` and `hasNoWarning()`
- `hasInfo()`, `findInfo()` and `hasNoInfo()`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `hasError()`, `findError()` and `hasNoError()`
- `hasWarning()`,`findWarning()` and `hasNoWarning()`
- `hasInfo()`, `findInfo()` and `hasNoInfo()`
- `hasError()`, `hasNoError()`, and `findError()`
- `hasWarning()`, `hasNoWarning()`, and `findWarning()`
- `hasInfo()`, `hasNoInfo()`, and `findInfo()`

@mergify mergify bot dismissed kaizencc’s stale review March 12, 2022 06:09

Pull request has been modified.

@joe-king-sh
Copy link
Contributor Author

@kaizen3031593
Thank you for your review comments.
I have reflected it and would appreciate a recheck.

kaizencc
kaizencc previously approved these changes Mar 14, 2022
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Looks great @joe-king-sh! I just added a bit of formatting to the error message.

@mergify mergify bot dismissed kaizencc’s stale review March 14, 2022 19:41

Pull request has been modified.

kaizencc
kaizencc previously approved these changes Mar 14, 2022
@mergify mergify bot dismissed kaizencc’s stale review March 14, 2022 22:37

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 287b114
  • 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 Mar 15, 2022

Thank you for contributing! Your pull request will be updated from master 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 6bdc9eb into aws:master Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/assertions Related to the @aws-cdk/assertv2 package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(assertions): Annotations should support hasNoXxx() APIs
3 participants