-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(assertions): absentProperty()
and not()
matchers are incompatible with hasResourceProperties
#16626
Comments
Related: #16653. If that PR is accepted, the workaround for this issue would become: Template.fromStack(stack).hasResourceProperties('AWS::IAM::User', Match.absentProperty()); With this in mind, is it reasonable to say that |
This is not the correct solution for this issue. As stated in the docs, Template.fromStack(stack).hasResourceProperties('AWS::IAM::User', {
UserName: Match.absentProperty(),
}); must automatically pass for both -
and
This is because the API is called hasResourceProperties(). |
There are a couple of ways to approach this issue -
|
Reading your comments, I agree that we should do something about this bug :). And I'll look further into the two approaches you've outlined in the second comment. However - #16653 is not trying to fix this bug. Rather, I think that
|
Ah, my bad! I thought they were related. |
…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*
|
…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*
…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*
Given a template that has a resource with no Properties (just
Type
)The following assertion should pass but throws the error
Template has 1 resources with type AWS::IAM::User, but none match as expected
.Similarly, the assertion -
The workaround is to do -
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: