Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
badmintoncryer committed Dec 11, 2023
1 parent 91b3ee9 commit 5b6a4c5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,16 @@ it('throws validation errors of the specific queue prop, when setting queue and
});
}).toThrow(new Error('visibilityTimeout can be set only when queue is not set. Specify them in the QueueProps of the queue'));
});

test('throws if image is undefined', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
// WHEN
expect(() => {
new ecsPatterns.QueueProcessingEc2Service(stack, 'Service', {
cluster: new ecs.Cluster(stack, 'Cluster', { vpc }),
memoryLimitMiB: 512,
});
}).toThrow(new Error('image must be specified for EC2 queue processing service'));
});
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,40 @@ test('test Fargate queue worker service construct - with task definition', () =>
TaskRoleArn: { 'Fn::GetAtt': ['TaskDefTaskRole1EDB4A67', 'Arn'] },
});
});

test('test Fargate queue worker service construct - with task definition and image', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', {
memoryLimitMiB: 1024,
cpu: 512,
ephemeralStorageGiB: 30,
});
taskDefinition.addContainer('QueueProcessingContainer', {
image: ecs.ContainerImage.fromRegistry('test'),
});

expect(() => {
new ecsPatterns.QueueProcessingFargateService(stack, 'Service', {
vpc,
taskDefinition,
image: ecs.ContainerImage.fromRegistry('test'),
});
}).toThrow(new Error('You must specify only one of taskDefinition or image'));
});

test('test Fargate queue worker service construct - with no taskDefinition or image', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');

expect(() => {
new ecsPatterns.QueueProcessingFargateService(stack, 'Service', {
vpc,
});
}).toThrow(new Error('You must specify one of: taskDefinition or image'));
});

0 comments on commit 5b6a4c5

Please sign in to comment.