Skip to content

(assertions): support multiple messages by logicalId in Annotations #18840

@yamatatsu

Description

@yamatatsu

Description

Annotations in @aws-cdk/assertions cannot has multiple messages by logicalId because Messages is following type:

export type Messages = {
  [logicalId: string]: SynthesisMessage;
}

But Annotations in @aws-cdk/core can add multiple massages (info, warning and error) to same node because messages is just metadata of Node.

I think it is better that Annotations in @aws-cdk/assertions also handle multiple messages by logicalId.

Use Case

If this feature was implemented, when the aspect add multiple annotations to same node as this comment, users can test it.

Proposed Solution

Modifing type of Messages is needed.

from:

export type Messages = {
  [logicalId: string]: SynthesisMessage;
}

to:

export type Messages = {
  [logicalId: string]: SynthesisMessage[];
}

To do that safely, first I think it is better to try to type section and other private modules with generics <T>.

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/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions