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

fix(assertions): hasResourceProperties is incompatible with Match.not and Match.absent #16678

Merged
merged 12 commits into from
Oct 6, 2021
Merged

fix(assertions): hasResourceProperties is incompatible with Match.not and Match.absent #16678

merged 12 commits into from
Oct 6, 2021

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Sep 27, 2021

Fixes #16626.

This PR modifies hasResourceProperties() so that it accounts for the special case where Properties does not exist on the template. The following assertions previously behaved incorrectly when Properties were not in the template and are now fixed:

template.fromStack(stack); // some template with no `Properties`.

// assert that `Properties` does not exist in the template. Returns true.
template.hasResourceProperties('Foo::Bar', Match.absent());

// assert that `baz` is not a `Property` of 'Foo::Bar'. Returns true.
template.hasResourceProperties('Foo::Bar', {
   baz: Match.absent(),
};

// assert that `baz` does not have a value of `qux` in the `Properties` object. Returns true.
template.hasResourceProperties('Foo::Bar', Match.not({baz: 'qux'});

It also moves AbsentMatch into the private folder so that it can be exposed internally as a special case for hasResourceProperties().


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 27, 2021

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 27, 2021
@kaizencc kaizencc requested a review from nija-at October 5, 2021 21:13
@kaizencc kaizencc changed the title fix(assertions): hasResourceProperties is incompatible with Match.not and Match.absentProperty fix(assertions): hasResourceProperties is incompatible with Match.not and Match.absent Oct 6, 2021
@kaizencc kaizencc requested a review from nija-at October 6, 2021 16:25
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

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

PR descriptions get converted into commit messages, so it will be a good idea to update this from what you have now.

Commit messages should usually contain what is being changed and why.

One minor comment below. Approved with 'do-not-merge' label.

packages/@aws-cdk/assertions/lib/match.ts Outdated Show resolved Hide resolved
@nija-at nija-at added the pr/do-not-merge This PR should not be merged at this time. label Oct 6, 2021
@kaizencc kaizencc removed the pr/do-not-merge This PR should not be merged at this time. label Oct 6, 2021
@kaizencc
Copy link
Contributor Author

kaizencc commented Oct 6, 2021

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Oct 6, 2021

Command refresh: success

Pull request refreshed

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: a492e82
  • 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 6f0a507 into aws:master Oct 6, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 6, 2021

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

njlynch pushed a commit that referenced this pull request Oct 11, 2021
…not` and `Match.absent` (#16678)

Fixes #16626.

This PR modifies `hasResourceProperties()` so that it accounts for the special case where `Properties` does not exist on the template. The following assertions previously behaved incorrectly when `Properties` were not in the template and are now fixed:

```ts
template.fromStack(stack); // some template with no `Properties`.

// assert that `Properties` does not exist in the template. Returns true.
template.hasResourceProperties('Foo::Bar', Match.absent());

// assert that `baz` is not a `Property` of 'Foo::Bar'. Returns true.
template.hasResourceProperties('Foo::Bar', {
   baz: Match.absent(),
};

// assert that `baz` does not have a value of `qux` in the `Properties` object. Returns true.
template.hasResourceProperties('Foo::Bar', Match.not({baz: 'qux'});
```

It also moves `AbsentMatch` into the `private` folder so that it can be exposed internally as a special case for `hasResourceProperties()`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@kaizencc kaizencc deleted the assertions-bug-fix branch October 13, 2021 16:39
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…not` and `Match.absent` (aws#16678)

Fixes aws#16626.

This PR modifies `hasResourceProperties()` so that it accounts for the special case where `Properties` does not exist on the template. The following assertions previously behaved incorrectly when `Properties` were not in the template and are now fixed:

```ts
template.fromStack(stack); // some template with no `Properties`.

// assert that `Properties` does not exist in the template. Returns true.
template.hasResourceProperties('Foo::Bar', Match.absent());

// assert that `baz` is not a `Property` of 'Foo::Bar'. Returns true.
template.hasResourceProperties('Foo::Bar', {
   baz: Match.absent(),
};

// assert that `baz` does not have a value of `qux` in the `Properties` object. Returns true.
template.hasResourceProperties('Foo::Bar', Match.not({baz: 'qux'});
```

It also moves `AbsentMatch` into the `private` folder so that it can be exposed internally as a special case for `hasResourceProperties()`.

----

*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
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(assertions): absentProperty() and not() matchers are incompatible with hasResourceProperties
3 participants