Skip to content

Commit

Permalink
chore: migrate kaizen3031593's modules to assertions (#18205)
Browse files Browse the repository at this point in the history
- [x] elasticsearch
- [x] lambda-layer-node-proxy-agent
- [x] ecr-assets
- [x] opensearchservice
- [x] chatbot
- [x] lambda-layer-kubectl
- [x] appmesh
- [x] lambda
- [x] lambda-destinations

----

*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 Jan 20, 2022
1 parent c0f62a5 commit 7c1795e
Show file tree
Hide file tree
Showing 41 changed files with 618 additions and 870 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appmesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert-internal": "0.0.0",
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/cdk-integ-tools": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
Expand Down
85 changes: 26 additions & 59 deletions packages/@aws-cdk/aws-appmesh/test/gateway-route.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@aws-cdk/assert-internal/jest';
import { ABSENT } from '@aws-cdk/assert-internal';
import { Match, Template } from '@aws-cdk/assertions';
import * as cdk from '@aws-cdk/core';
import * as appmesh from '../lib';

Expand Down Expand Up @@ -50,9 +49,9 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
MeshOwner: ABSENT,
MeshOwner: Match.absent(),
Spec: {
HttpRoute: {
Action: {
Expand All @@ -70,7 +69,7 @@ describe('gateway route', () => {
},
},
});
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http2-route',
Spec: {
Http2Route: {
Expand All @@ -89,7 +88,7 @@ describe('gateway route', () => {
},
},
});
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-grpc-route',
Spec: {
GrpcRoute: {
Expand Down Expand Up @@ -163,11 +162,9 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
MeshOwner: meshEnv.account,
});


});
});

Expand Down Expand Up @@ -214,7 +211,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand All @@ -229,7 +226,7 @@ describe('gateway route', () => {
},
});

expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-grpc-route',
Spec: {
GrpcRoute: {
Expand All @@ -243,8 +240,6 @@ describe('gateway route', () => {
},
},
});


});
});

Expand Down Expand Up @@ -279,10 +274,8 @@ describe('gateway route', () => {
}),
gatewayRouteName: 'gateway-http2-route',
});


// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http2-route',
Spec: {
Http2Route: {
Expand All @@ -296,8 +289,6 @@ describe('gateway route', () => {
},
},
});


});
});

Expand Down Expand Up @@ -355,7 +346,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand All @@ -370,7 +361,7 @@ describe('gateway route', () => {
},
});

expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http2-route',
Spec: {
Http2Route: {
Expand All @@ -385,18 +376,16 @@ describe('gateway route', () => {
},
});

expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http2-route-1',
Spec: {
Http2Route: {
Action: {
Rewrite: ABSENT,
Rewrite: Match.absent(),
},
},
},
});


});

test("should throw an error if the prefix match does not start and end with '/'", () => {
Expand Down Expand Up @@ -429,8 +418,6 @@ describe('gateway route', () => {
gatewayRouteName: 'gateway-http-route',
});
}).toThrow(/Prefix path for the match must start with \'\/\', got: test\//);


expect(() => {
virtualGateway.addGatewayRoute('gateway-http2-route', {
routeSpec: appmesh.GatewayRouteSpec.http2({
Expand All @@ -442,8 +429,6 @@ describe('gateway route', () => {
gatewayRouteName: 'gateway-http2-route',
});
}).toThrow(/When prefix path for the rewrite is specified, prefix path for the match must end with \'\/\', got: \/test/);


});

test("should throw an error if the custom prefix does not start and end with '/'", () => {
Expand Down Expand Up @@ -488,8 +473,6 @@ describe('gateway route', () => {
gatewayRouteName: 'gateway-http2-route',
});
}).toThrow(/Prefix path for the rewrite must start and end with \'\/\', got: \/rewrittenUri/);


});
});

Expand Down Expand Up @@ -535,7 +518,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand All @@ -545,13 +528,13 @@ describe('gateway route', () => {
},
},
Action: {
Rewrite: ABSENT,
Rewrite: Match.absent(),
},
},
},
});

expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-grpc-route',
Spec: {
GrpcRoute: {
Expand All @@ -563,8 +546,6 @@ describe('gateway route', () => {
},
},
});


});
});

Expand Down Expand Up @@ -610,7 +591,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-grpc-route',
Spec: {
GrpcRoute: {
Expand Down Expand Up @@ -681,8 +662,6 @@ describe('gateway route', () => {
},
},
});


});

test('should throw an error if the array length is invalid', () => {
Expand Down Expand Up @@ -742,8 +721,6 @@ describe('gateway route', () => {
gatewayRouteName: 'gateway-grpc-route',
});
}).toThrow(/Number of metadata provided for matching must be between 1 and 10/);


});
});

Expand Down Expand Up @@ -790,7 +767,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand Down Expand Up @@ -861,8 +838,6 @@ describe('gateway route', () => {
},
},
});


});
});

Expand Down Expand Up @@ -898,7 +873,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand All @@ -908,8 +883,6 @@ describe('gateway route', () => {
},
},
});


});
});

Expand Down Expand Up @@ -956,7 +929,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand All @@ -966,13 +939,13 @@ describe('gateway route', () => {
},
},
Action: {
Rewrite: ABSENT,
Rewrite: Match.absent(),
},
},
},
});

expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http2-route',
Spec: {
Http2Route: {
Expand All @@ -984,8 +957,6 @@ describe('gateway route', () => {
},
},
});


});

test('should throw an error if empty string is passed', () => {
Expand Down Expand Up @@ -1019,8 +990,6 @@ describe('gateway route', () => {
gatewayRouteName: 'gateway-http-route',
});
}).toThrow(/Exact Path for the rewrite cannot be empty. Unlike startsWith\(\) method, no automatic rewrite on whole path match/);


});
});

Expand Down Expand Up @@ -1058,7 +1027,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand All @@ -1075,8 +1044,6 @@ describe('gateway route', () => {
},
},
});


});
});
});
Expand Down Expand Up @@ -1112,7 +1079,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
GatewayRouteName: 'gateway-http-route',
Spec: {
HttpRoute: {
Expand Down Expand Up @@ -1157,7 +1124,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
Spec: {
Priority: 100,
},
Expand Down Expand Up @@ -1197,7 +1164,7 @@ describe('gateway route', () => {
});

// THEN
expect(stack).toHaveResourceLike('AWS::AppMesh::GatewayRoute', {
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::GatewayRoute', {
Spec: {
Priority: 500,
},
Expand Down
9 changes: 0 additions & 9 deletions packages/@aws-cdk/aws-appmesh/test/health-check.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as cdk from '@aws-cdk/core';

import * as appmesh from '../lib';

let idCounter = 0;
Expand Down Expand Up @@ -29,8 +28,6 @@ describe('health check', () => {
expect(() => toThrow(max)).not.toThrow();
expect(() => toThrow(min - 1)).toThrow(/interval must be between 5 seconds and 300 seconds/);
expect(() => toThrow(max + 1)).toThrow(/interval must be between 5 seconds and 300 seconds/);


});
test('timeout', () => {
// GIVEN
Expand All @@ -48,8 +45,6 @@ describe('health check', () => {
expect(() => toThrow(max)).not.toThrow();
expect(() => toThrow(min - 1)).toThrow(/timeout must be between 2 seconds and 60 seconds/);
expect(() => toThrow(max + 1)).toThrow(/timeout must be between 2 seconds and 60 seconds/);


});
test('healthyThreshold', () => {
// GIVEN
Expand All @@ -67,8 +62,6 @@ describe('health check', () => {
expect(() => toThrow(max)).not.toThrow();
expect(() => toThrow(min - 1)).toThrow(/healthyThreshold must be between 2 and 10/);
expect(() => toThrow(max + 1)).toThrow(/healthyThreshold must be between 2 and 10/);


});
test('unhealthyThreshold', () => {
// GIVEN
Expand All @@ -86,7 +79,5 @@ describe('health check', () => {
expect(() => toThrow(max)).not.toThrow();
expect(() => toThrow(min - 1)).toThrow(/unhealthyThreshold must be between 2 and 10/);
expect(() => toThrow(max + 1)).toThrow(/unhealthyThreshold must be between 2 and 10/);


});
});
Loading

0 comments on commit 7c1795e

Please sign in to comment.