'How to write Junit for CDK stage
I am newbie in cdk. I have requirement to create the SQS infra on deployment. For that following is piece of code and its works fine in env.
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 want to write the unit test for this so that before executing code in env I can make sure things are good. Following is unit test code where I want to verify newly created sqs is added in stage or not. But don't know I can I do that.
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 help me on this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
