Skip to content

Commit

Permalink
chore(events-targets): update lambda annotation test (aws#19527)
Browse files Browse the repository at this point in the history
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 aws#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*
  • Loading branch information
kaizencc authored and Stephen Potter committed Apr 27, 2022
1 parent d4b0176 commit a251ae8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/@aws-cdk/aws-events-targets/test/lambda/lambda.test.ts
@@ -1,4 +1,4 @@
import { Template } from '@aws-cdk/assertions';
import { Annotations, Template, Match } from '@aws-cdk/assertions';
import * as events from '@aws-cdk/aws-events';
import * as lambda from '@aws-cdk/aws-lambda';
import * as sqs from '@aws-cdk/aws-sqs';
Expand Down Expand Up @@ -321,8 +321,13 @@ test('must display a warning when using a Dead Letter Queue from another account

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

let rule = stack1.node.children.find(child => child instanceof events.Rule);
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\./);
Annotations.fromStack(stack1).hasWarning('/Stack1/Rule', Match.objectLike({
'Fn::Join': Match.arrayWith([
Match.arrayWith([
'Cannot add a resource policy to your dead letter queue associated with rule ',
]),
]),
}));
});


Expand Down

0 comments on commit a251ae8

Please sign in to comment.