Skip to content

Commit 71b7605

Browse files
committed
testinteg-tests-alpha): update tests
1 parent 92a2e3c commit 71b7605

9 files changed

Lines changed: 140 additions & 150 deletions

File tree

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.lambda-api.js.snapshot/asset.0c7aaf76cc1dd0b815cbae58e87758f463c3c89426c018d858acff3d1ec29630.bundle/index.js renamed to packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.lambda-api.js.snapshot/asset.618fc075b4931b5a1dd4d257a0604152ada8eae3cad6807905d6901ec179f677.bundle/index.js

Lines changed: 104 additions & 124 deletions
Large diffs are not rendered by default.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.lambda-api.js.snapshot/lambdaintegrationDefaultTestDeployAssertAC2ED705.assets.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
22
"version": "32.0.0",
33
"files": {
4-
"0c7aaf76cc1dd0b815cbae58e87758f463c3c89426c018d858acff3d1ec29630": {
4+
"618fc075b4931b5a1dd4d257a0604152ada8eae3cad6807905d6901ec179f677": {
55
"source": {
6-
"path": "asset.0c7aaf76cc1dd0b815cbae58e87758f463c3c89426c018d858acff3d1ec29630.bundle",
6+
"path": "asset.618fc075b4931b5a1dd4d257a0604152ada8eae3cad6807905d6901ec179f677.bundle",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "0c7aaf76cc1dd0b815cbae58e87758f463c3c89426c018d858acff3d1ec29630.zip",
12+
"objectKey": "618fc075b4931b5a1dd4d257a0604152ada8eae3cad6807905d6901ec179f677.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"73baddea6b6218c0efd01444a62d4ee70b363fd48282cb0719ff5f6ceedc46b4": {
17+
"97ceceb47d60bd8b1fdf97533201dffd346e8c0830ece372061638cdd56d32fd": {
1818
"source": {
1919
"path": "lambdaintegrationDefaultTestDeployAssertAC2ED705.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "73baddea6b6218c0efd01444a62d4ee70b363fd48282cb0719ff5f6ceedc46b4.json",
25+
"objectKey": "97ceceb47d60bd8b1fdf97533201dffd346e8c0830ece372061638cdd56d32fd.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.lambda-api.js.snapshot/lambdaintegrationDefaultTestDeployAssertAC2ED705.template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
},
3838
"expected": "{\"$ObjectLike\":{\"body\":{\"message\":\"Hello\"}}}",
39-
"salt": "1689319968176"
39+
"salt": "1689327791749"
4040
},
4141
"UpdateReplacePolicy": "Delete",
4242
"DeletionPolicy": "Delete"
@@ -71,7 +71,7 @@
7171
"S3Bucket": {
7272
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
7373
},
74-
"S3Key": "0c7aaf76cc1dd0b815cbae58e87758f463c3c89426c018d858acff3d1ec29630.zip"
74+
"S3Key": "618fc075b4931b5a1dd4d257a0604152ada8eae3cad6807905d6901ec179f677.zip"
7575
},
7676
"Timeout": 120,
7777
"Handler": "index.handler",

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.lambda-api.js.snapshot/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
"validateOnSynth": false,
167167
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
168168
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
169-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/73baddea6b6218c0efd01444a62d4ee70b363fd48282cb0719ff5f6ceedc46b4.json",
169+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/97ceceb47d60bd8b1fdf97533201dffd346e8c0830ece372061638cdd56d32fd.json",
170170
"requiresBootstrapStackVersion": 6,
171171
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
172172
"additionalDependencies": [

packages/@aws-cdk/integ-tests-alpha/lib/assertions/providers/lambda-handler/sdk-v2-to-v3.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/@aws-cdk/integ-tests-alpha/lib/assertions/providers/lambda-handler/sdk.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
import { CustomResourceHandler } from './base';
33
import { AwsApiCallRequest, AwsApiCallResult } from './types';
44
import { decode } from './utils';
5-
import * as sdkV2ToV3 from './sdk-v2-to-v3';
5+
6+
// These functions defined at 'aws-cdk-lib/custom-resources'.
7+
// However, 'aws-cdk-lib/custom-resources' exports the some constructs,
8+
// so when import the package, then bundle size is too large and lambda function is not working.
9+
// To avoid this issue, we using inject of esbuild (https://esbuild.github.io/api/#inject)
10+
declare const getV3ClientPackageName: (clientName: string) => string;
11+
declare const findV3ClientConstructor: (pkg: Object) => new (config: any) => {
12+
send: (command: any) => Promise<any>;
13+
config: any;
14+
};
615

716
/**
817
* Flattens a nested object
@@ -37,7 +46,7 @@ interface V3SdkPkg {
3746
}
3847

3948
function getServicePackage(service: string): V3SdkPkg {
40-
const packageName = sdkV2ToV3.getV3ClientPackageName(service);
49+
const packageName = getV3ClientPackageName(service);
4150
try {
4251
/* eslint-disable-next-line @typescript-eslint/no-require-imports */
4352
const pkg = require(packageName);
@@ -54,7 +63,7 @@ function getServicePackage(service: string): V3SdkPkg {
5463

5564
function getServiceClient(sdkPkg: V3SdkPkg): any {
5665
try {
57-
const ServiceClient = sdkV2ToV3.findV3ClientConstructor(sdkPkg.pkg);
66+
const ServiceClient = findV3ClientConstructor(sdkPkg.pkg);
5867
return new ServiceClient({});
5968
} catch (e) {
6069
console.error(e);

packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/lambda-handler/assertion.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AssertionRequest, AssertionResult, ExpectedResult } from '../../../../lib/assertions';
22
import { Match } from '../../../../lib/assertions/match';
3+
import { getV3ClientPackageName, findV3ClientConstructor } from 'aws-cdk-lib/custom-resources';
34
import { AssertionHandler } from '../../../../lib/assertions/providers/lambda-handler/assertion';
45

56
function assertionHandler() {
@@ -9,8 +10,10 @@ function assertionHandler() {
910
return new AssertionHandler({} as any, context); // as any to ignore all type checks
1011
}
1112

12-
// eslint-disable-next-line @typescript-eslint/no-require-imports
13-
jest.mock('../../../../lib/assertions/providers/lambda-handler/sdk-v2-to-v3', () => require('aws-cdk-lib/custom-resources'));
13+
// @ts-ignore
14+
global.getV3ClientPackageName = getV3ClientPackageName;
15+
// @ts-ignore
16+
global.findV3ClientConstructor = findV3ClientConstructor;
1417
beforeAll(() => {
1518
jest.useFakeTimers();
1619
jest.spyOn(console, 'log').mockImplementation(() => { return true; });

packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/lambda-handler/base.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { CustomResourceHandler } from '../../../../lib/assertions/providers/lamb
55
import { mockClient } from 'aws-sdk-client-mock';
66
import { ListBucketsCommand, ListBucketsOutput, S3Client } from '@aws-sdk/client-s3';
77
import { SFNClient, StartExecutionCommand } from '@aws-sdk/client-sfn';
8+
import { getV3ClientPackageName, findV3ClientConstructor } from 'aws-cdk-lib/custom-resources';
89
import 'aws-sdk-client-mock-jest';
910

1011
interface MyHandlerRequest {
@@ -18,8 +19,11 @@ interface MyHandlerResponse {
1819
interface CloudFormationResponse extends Omit<AWSLambda.CloudFormationCustomResourceResponse, 'Data'> {
1920
readonly Data: any;
2021
}
21-
// eslint-disable-next-line @typescript-eslint/no-require-imports
22-
jest.mock('../../../../lib/assertions/providers/lambda-handler/sdk-v2-to-v3', () => require('aws-cdk-lib/custom-resources'));
22+
23+
// @ts-ignore
24+
global.getV3ClientPackageName = getV3ClientPackageName;
25+
// @ts-ignore
26+
global.findV3ClientConstructor = findV3ClientConstructor;
2327
const s3Mock = mockClient(S3Client);
2428
const sfnMock = mockClient(SFNClient);
2529
describe('CustomResourceHandler', () => {

packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/lambda-handler/sdk.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DescribeInstancesCommand, EC2Client } from '@aws-sdk/client-ec2';
44
import { mockClient } from 'aws-sdk-client-mock';
55
import { AwsApiCallRequest, AwsApiCallResult } from '../../../../lib/assertions';
66
import { AwsApiCallHandler } from '../../../../lib/assertions/providers/lambda-handler/sdk';
7+
import { getV3ClientPackageName, findV3ClientConstructor } from 'aws-cdk-lib/custom-resources';
78
import 'aws-sdk-client-mock-jest';
89

910
function sdkHandler() {
@@ -12,8 +13,10 @@ function sdkHandler() {
1213
};
1314
return new AwsApiCallHandler({} as any, context); // as any to ignore all type checks
1415
}
15-
// eslint-disable-next-line @typescript-eslint/no-require-imports
16-
jest.mock('../../../../lib/assertions/providers/lambda-handler/sdk-v2-to-v3', () => require('aws-cdk-lib/custom-resources'));
16+
// @ts-ignore
17+
global.getV3ClientPackageName = getV3ClientPackageName;
18+
// @ts-ignore
19+
global.findV3ClientConstructor = findV3ClientConstructor;
1720
beforeAll(() => {
1821
jest.useFakeTimers();
1922
jest.spyOn(console, 'log').mockImplementation(() => { return true; });

0 commit comments

Comments
 (0)