As a newcomer to CDK, I have the requirement to set up SQS infrastructure during deployment. The following code snippet is working fine in the environment:
export class TestStage extends cdk.Stage {
constructor(scope: cdk.Construct, id: string, props: TestProps) {
super(scope, id);
const stgStack = new cdk.Stack(this, 'TestStage', {
description: 'This test environment.',
});
let list: string[] = data.sqs;
list.forEach(queueName => {
let sqsId = 'CreateSQS_' + queueName;
const queue = new TestPattern(stgStack, sqsId, queueName);
console.log(sqsQueue);
});
}
}
Now I need to write unit tests to ensure that the newly created SQS queues are added to the stage correctly before executing the code in the environment. Here's the unit test code where I want to verify if the SQS is added to the stage or not, but I'm unsure how to do it:
test('Test Stage ', () => {
const app = new App();
let testStage = new TestStage (app, 'test-stage', {
desc: "test"
});
const testSqsStage = new Stack(testStage, 'TestStack');
const template = Template.fromStack(testSqsStage);
console.log(testSqsStage);
});
Can someone assist me with this?