Skip to content

Commit 6ed9176

Browse files
authored
chore(events-targets): update lambda annotation test (#19527)
Updating a test that requires metadata to be the first item returned in `node.metadataEntry`. This is not resilient because we could add additional metadata in the future that changes the order of `node.metadatEntry`. Instead, these tests should use assertions. I've found that we do this quite a bit elsewhere in the CDK. Because this test is actively blocking #19464, I'm including this as a separate PR to get it in and will fast-follow with other changes later. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5444850 commit 6ed9176

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Template } from '@aws-cdk/assertions';
1+
import { Annotations, Template, Match } from '@aws-cdk/assertions';
22
import * as events from '@aws-cdk/aws-events';
33
import * as lambda from '@aws-cdk/aws-lambda';
44
import * as sqs from '@aws-cdk/aws-sqs';
@@ -321,8 +321,13 @@ test('must display a warning when using a Dead Letter Queue from another account
321321

322322
Template.fromStack(stack1).resourceCountIs('AWS::SQS::QueuePolicy', 0);
323323

324-
let rule = stack1.node.children.find(child => child instanceof events.Rule);
325-
expect(rule?.node.metadataEntry[0].data).toMatch(/Cannot add a resource policy to your dead letter queue associated with rule .* because the queue is in a different account\. You must add the resource policy manually to the dead letter queue in account 222222222222\./);
324+
Annotations.fromStack(stack1).hasWarning('/Stack1/Rule', Match.objectLike({
325+
'Fn::Join': Match.arrayWith([
326+
Match.arrayWith([
327+
'Cannot add a resource policy to your dead letter queue associated with rule ',
328+
]),
329+
]),
330+
}));
326331
});
327332

328333

0 commit comments

Comments
 (0)