Skip to content

Commit

Permalink
add edge case test
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Mar 8, 2024
1 parent 649dae2 commit 6375b3e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,26 @@ describe('tests', () => {
}).toThrow('Health check interval must be greater than or equal to the timeout; received interval 10, timeout 20.');
});

// for backwards compatibility these can be equal, see discussion in https://github.com/aws/aws-cdk/pull/26031
test('Throws error for health check interval less than timeout', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');
const vpc = new ec2.Vpc(stack, 'Vpc');

new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
vpc,
port: 80,
healthCheck: {
interval: cdk.Duration.seconds(10),
timeout: cdk.Duration.seconds(20),
},
});

expect(() => {
app.synth();
}).toThrow('Health check interval must be greater than or equal to the timeout; received interval 10, timeout 20.');
});

test('imported targetGroup has targetGroupName', () => {
// GIVEN
const app = new cdk.App();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ describe('tests', () => {
}).toThrow('Health check interval must be greater than or equal to the timeout; received interval 10, timeout 20.');
});

// for backwards compatibility these can be equal, see discussion in https://github.com/aws/aws-cdk/pull/26031
test('No error for health check interval == timeout', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');
const vpc = new ec2.Vpc(stack, 'Vpc');

new elbv2.NetworkTargetGroup(stack, 'Group', {
vpc,
port: 80,
healthCheck: {
interval: cdk.Duration.seconds(10),
timeout: cdk.Duration.seconds(10),
},
});

expect(() => {
app.synth();
}).not.toThrow();
});

test('targetGroupName unallowed: more than 32 characters', () => {
// GIVEN
const app = new cdk.App();
Expand Down

0 comments on commit 6375b3e

Please sign in to comment.