Skip to content

Commit ea777ce

Browse files
authored
chore(events-targets): migrate a test to use assertions' annotations class (#19465)
Also removes unnecessary assertion on number of messages, as this breaks when other messages are introduced. See #19464, which introduces a relevant message and breaks this test. Fixing in one other place as well. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0c983ad commit ea777ce

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

packages/@aws-cdk/aws-events-targets/test/aws-api/aws-api.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Template } from '@aws-cdk/assertions';
1+
import { Annotations, Template } from '@aws-cdk/assertions';
22
import * as events from '@aws-cdk/aws-events';
33
import * as iam from '@aws-cdk/aws-iam';
4-
import { App, Stack } from '@aws-cdk/core';
4+
import { Stack } from '@aws-cdk/core';
55
import * as targets from '../../lib';
66

77
test('use AwsApi as an event rule target', () => {
@@ -163,9 +163,5 @@ test('with service not in AWS SDK', () => {
163163
rule.addTarget(awsApi);
164164

165165
// THEN
166-
const assembly = App.of(stack)!.synth().getStackArtifact(stack.stackName);
167-
expect(assembly.messages.length).toBe(1);
168-
const message = assembly.messages[0];
169-
expect(message.entry.type).toBe('aws:cdk:warning');
170-
expect(message.entry.data).toBe('Service no-such-service does not exist in the AWS SDK. Check the list of available services and actions from https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html');
166+
Annotations.fromStack(stack).hasWarning('*', 'Service no-such-service does not exist in the AWS SDK. Check the list of available services and actions from https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html');
171167
});

0 commit comments

Comments
 (0)