Skip to content

Commit

Permalink
chore(events-targets): migrate a test to use assertions' annotations …
Browse files Browse the repository at this point in the history
…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*
  • Loading branch information
kaizencc committed Mar 21, 2022
1 parent 0c983ad commit ea777ce
Showing 1 changed file with 3 additions and 7 deletions.
@@ -1,7 +1,7 @@
import { Template } from '@aws-cdk/assertions';
import { Annotations, Template } from '@aws-cdk/assertions';
import * as events from '@aws-cdk/aws-events';
import * as iam from '@aws-cdk/aws-iam';
import { App, Stack } from '@aws-cdk/core';
import { Stack } from '@aws-cdk/core';
import * as targets from '../../lib';

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

// THEN
const assembly = App.of(stack)!.synth().getStackArtifact(stack.stackName);
expect(assembly.messages.length).toBe(1);
const message = assembly.messages[0];
expect(message.entry.type).toBe('aws:cdk:warning');
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');
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');
});

0 comments on commit ea777ce

Please sign in to comment.