Skip to content

(assertions): Annotations should support hasNoXxx() APIs #18874

@fitzoh

Description

@fitzoh

Description

Add has_no_error, has_no_warning, and has_no_info methods to the Annotations assertions toolkit.

Use Case

I'm testing some EC2 constructs and lettings users pass in block volumes, adding errors if any volumes are unencrypted.

The test for something that produces an error is easy:

Annotations.from_stack(stack).has_error("*", "unencrypted volume /dev/sda1")

The test for a value that doesn't produce an error is awkward:

    errors = Annotations.from_stack(stack).find_error(
        "*", Match.string_like_regexp(".*")
    )
    assert not errors

I would like to easily assert that there are no errors in the stack

Proposed Solution

Add a has_no_error method next to the has_error and find_error methods (as well as info and warning variants).

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/assertionsRelated to the @aws-cdk/assertv2 packageeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.good first issueRelated to contributions. See CONTRIBUTING.mdp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions