Skip to content

Commit 03d388d

Browse files
authored
chore(fsx): migrate tests to assertions (#18490)
---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent da5a305 commit 03d388d

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

packages/@aws-cdk/aws-fsx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
},
8282
"license": "Apache-2.0",
8383
"devDependencies": {
84-
"@aws-cdk/assert-internal": "0.0.0",
84+
"@aws-cdk/assertions": "0.0.0",
8585
"@aws-cdk/cdk-build-tools": "0.0.0",
8686
"@aws-cdk/cdk-integ-tools": "0.0.0",
8787
"@aws-cdk/cfn2ts": "0.0.0",

packages/@aws-cdk/aws-fsx/test/lustre-file-system.test.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { strictEqual } from 'assert';
2-
import { expect as expectCDK, haveResource, ResourcePart } from '@aws-cdk/assert-internal';
2+
import { Template } from '@aws-cdk/assertions';
33
import { ISubnet, Port, SecurityGroup, Subnet, Vpc } from '@aws-cdk/aws-ec2';
44
import { Key } from '@aws-cdk/aws-kms';
55
import { Aws, Stack, Token } from '@aws-cdk/core';
@@ -35,15 +35,15 @@ describe('FSx for Lustre File System', () => {
3535
vpcSubnet,
3636
});
3737

38-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem'));
39-
expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroup'));
38+
Template.fromStack(stack).hasResource('AWS::FSx::FileSystem', {});
39+
Template.fromStack(stack).hasResource('AWS::EC2::SecurityGroup', {});
4040
strictEqual(
4141
fileSystem.dnsName,
4242
`${fileSystem.fileSystemId}.fsx.${stack.region}.${Aws.URL_SUFFIX}`);
4343

44-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
44+
Template.fromStack(stack).hasResource('AWS::FSx::FileSystem', {
4545
DeletionPolicy: 'Retain',
46-
}, ResourcePart.CompleteDefinition));
46+
});
4747
});
4848

4949
test('file system is created correctly when security group is provided', () => {
@@ -63,8 +63,8 @@ describe('FSx for Lustre File System', () => {
6363
vpcSubnet,
6464
});
6565

66-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem'));
67-
expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroup'));
66+
Template.fromStack(stack).hasResource('AWS::FSx::FileSystem', {});
67+
Template.fromStack(stack).hasResource('AWS::EC2::SecurityGroup', {});
6868
});
6969

7070
test('encrypted file system is created correctly with custom KMS', () => {
@@ -88,11 +88,11 @@ describe('FSx for Lustre File System', () => {
8888
* in generated CDK, hence hardcoding the MD5 hash here for assertion. Assumption is that the path of the Key wont
8989
* change in this UT. Checked the unique id by generating the cloud formation stack.
9090
*/
91-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
91+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
9292
KmsKeyId: {
9393
Ref: 'customKeyFSDDB87C6D',
9494
},
95-
}));
95+
});
9696
});
9797

9898
test('file system is created correctly when weekly maintenance time is provided', () => {
@@ -118,13 +118,13 @@ describe('FSx for Lustre File System', () => {
118118
vpcSubnet,
119119
});
120120

121-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
121+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
122122
LustreConfiguration: {
123123
DeploymentType: 'SCRATCH_2',
124124
WeeklyMaintenanceStartTime: '7:12:34',
125125
},
126-
}));
127-
expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroup'));
126+
});
127+
Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroup', {});
128128
});
129129

130130
describe('when validating props', () => {
@@ -145,13 +145,13 @@ describe('FSx for Lustre File System', () => {
145145
vpcSubnet,
146146
});
147147

148-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
148+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
149149
LustreConfiguration: {
150150
DeploymentType: LustreDeploymentType.SCRATCH_2,
151151
ExportPath: exportPath,
152152
ImportPath: importPath,
153153
},
154-
}));
154+
});
155155
});
156156

157157
test('export and import paths are Tokens', () => {
@@ -172,13 +172,13 @@ describe('FSx for Lustre File System', () => {
172172
vpcSubnet,
173173
});
174174

175-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
175+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
176176
LustreConfiguration: {
177177
DeploymentType: LustreDeploymentType.SCRATCH_2,
178178
ExportPath: exportPathResolved,
179179
ImportPath: importPathResolved,
180180
},
181-
}));
181+
});
182182
});
183183

184184
test('only export path is Token', () => {
@@ -299,12 +299,12 @@ describe('FSx for Lustre File System', () => {
299299
vpcSubnet,
300300
});
301301

302-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
302+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
303303
LustreConfiguration: {
304304
DeploymentType: LustreDeploymentType.SCRATCH_2,
305305
ImportedFileChunkSize: size,
306306
},
307-
}));
307+
});
308308
});
309309

310310
test.each([
@@ -342,12 +342,12 @@ describe('FSx for Lustre File System', () => {
342342
vpcSubnet,
343343
});
344344

345-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
345+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
346346
LustreConfiguration: {
347347
DeploymentType: LustreDeploymentType.SCRATCH_2,
348348
ImportPath: importPath,
349349
},
350-
}));
350+
});
351351
});
352352

353353
test('import path is Token', () => {
@@ -364,12 +364,12 @@ describe('FSx for Lustre File System', () => {
364364
vpcSubnet,
365365
});
366366

367-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
367+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
368368
LustreConfiguration: {
369369
DeploymentType: LustreDeploymentType.SCRATCH_2,
370370
ImportPath: importPathResolved,
371371
},
372-
}));
372+
});
373373
});
374374

375375
test('invalid import path format', () => {
@@ -428,12 +428,12 @@ describe('FSx for Lustre File System', () => {
428428
vpcSubnet,
429429
});
430430

431-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
431+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
432432
LustreConfiguration: {
433433
DeploymentType: LustreDeploymentType.PERSISTENT_1,
434434
PerUnitStorageThroughput: throughput,
435435
},
436-
}));
436+
});
437437
});
438438

439439
test('invalid perUnitStorageThroughput', () => {
@@ -489,12 +489,12 @@ describe('FSx for Lustre File System', () => {
489489
vpcSubnet,
490490
});
491491

492-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
492+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
493493
LustreConfiguration: {
494494
DeploymentType: deploymentType,
495495
},
496496
StorageCapacity: value,
497-
}));
497+
});
498498
});
499499

500500
test.each([
@@ -529,12 +529,12 @@ describe('FSx for Lustre File System', () => {
529529
vpcSubnet,
530530
});
531531

532-
expectCDK(stack).to(haveResource('AWS::FSx::FileSystem', {
532+
Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', {
533533
LustreConfiguration: {
534534
DeploymentType: LustreDeploymentType.SCRATCH_1,
535535
},
536536
StorageCapacity: validValue,
537-
}));
537+
});
538538
});
539539

540540
test.each([1, 3601])('invalid value of %d for storage capacity with SCRATCH_1', (invalidValue: number) => {
@@ -566,8 +566,8 @@ describe('FSx for Lustre File System', () => {
566566

567567
fs.connections.allowToAnyIpv4(Port.tcp(443));
568568

569-
expectCDK(stack).to(haveResource('AWS::EC2::SecurityGroupEgress', {
569+
Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroupEgress', {
570570
GroupId: 'sg-123456789',
571-
}));
571+
});
572572
});
573573
});

0 commit comments

Comments
 (0)