diff --git a/packages/@aws-cdk/aws-codebuild/package.json b/packages/@aws-cdk/aws-codebuild/package.json index 6bde99b6e2c63..0f16ed23d8b1d 100644 --- a/packages/@aws-cdk/aws-codebuild/package.json +++ b/packages/@aws-cdk/aws-codebuild/package.json @@ -83,7 +83,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert-internal": "0.0.0", + "@aws-cdk/assertions": "0.0.0", "@aws-cdk/aws-sns": "0.0.0", "@aws-cdk/aws-sqs": "0.0.0", "@aws-cdk/cdk-build-tools": "0.0.0", diff --git a/packages/@aws-cdk/aws-codebuild/test/codebuild.test.ts b/packages/@aws-cdk/aws-codebuild/test/codebuild.test.ts index 1cc66df6b236f..5a058625649c3 100644 --- a/packages/@aws-cdk/aws-codebuild/test/codebuild.test.ts +++ b/packages/@aws-cdk/aws-codebuild/test/codebuild.test.ts @@ -1,5 +1,4 @@ -import { ABSENT, SynthUtils } from '@aws-cdk/assert-internal'; -import '@aws-cdk/assert-internal/jest'; +import { Match, Template } from '@aws-cdk/assertions'; import * as codecommit from '@aws-cdk/aws-codecommit'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as kms from '@aws-cdk/aws-kms'; @@ -17,7 +16,7 @@ describe('default properties', () => { new codebuild.PipelineProject(stack, 'MyProject'); - expect(stack).toMatchTemplate({ + Template.fromStack(stack).templateMatches({ 'Resources': { 'MyProjectRole9BBE5233': { 'Type': 'AWS::IAM::Role', @@ -177,7 +176,7 @@ describe('default properties', () => { source, }); - expect(stack).toMatchTemplate({ + Template.fromStack(stack).templateMatches({ 'Resources': { 'MyRepoF4F48043': { 'Type': 'AWS::CodeCommit::Repository', @@ -361,7 +360,7 @@ describe('default properties', () => { }, }); - expect(stack).toMatchTemplate({ + Template.fromStack(stack).templateMatches({ 'Resources': { 'MyBucketF68F3FF0': { 'Type': 'AWS::S3::Bucket', @@ -572,7 +571,7 @@ describe('default properties', () => { }), }); - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { Type: 'GITHUB', Location: 'https://github.com/testowner/testrepo.git', @@ -584,7 +583,7 @@ describe('default properties', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Triggers: { Webhook: true, FilterGroups: [ @@ -620,7 +619,7 @@ describe('default properties', () => { }), }); - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { Type: 'GITHUB_ENTERPRISE', InsecureSsl: true, @@ -630,7 +629,7 @@ describe('default properties', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Triggers: { Webhook: true, FilterGroups: [ @@ -672,7 +671,7 @@ describe('default properties', () => { }), }); - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { Type: 'BITBUCKET', Location: 'https://bitbucket.org/testowner/testrepo.git', @@ -681,7 +680,7 @@ describe('default properties', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Triggers: { Webhook: true, FilterGroups: [ @@ -710,7 +709,7 @@ describe('default properties', () => { }), }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Triggers: { Webhook: true, BuildType: 'BUILD_BATCH', @@ -725,7 +724,7 @@ describe('default properties', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Role', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { AssumeRolePolicyDocument: { Statement: [ { @@ -740,7 +739,7 @@ describe('default properties', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { Statement: [ { @@ -809,7 +808,7 @@ describe('default properties', () => { securityGroups: [securityGroup], }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'VpcConfig': { 'SecurityGroupIds': [ { @@ -900,7 +899,7 @@ describe('default properties', () => { new codebuild.PipelineProject(stack, 'MyProject'); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { EncryptionKey: 'alias/aws/s3', }); }); @@ -915,7 +914,7 @@ describe('default properties', () => { grantReportGroupPermissions: false, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { 'Statement': [ {}, // CloudWatch logs @@ -960,7 +959,7 @@ test('using timeout and path in S3 artifacts sets it correctly', () => { timeout: cdk.Duration.minutes(123), }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Artifacts': { 'Path': 'some/path', 'Name': 'some_name', @@ -999,7 +998,7 @@ describe('secondary sources', () => { identifier: 'id', })); - expect(() => SynthUtils.synthesize(stack)).toThrow(/secondary sources/); + expect(() => Template.fromStack(stack)).toThrow(/secondary sources/); }); test('added with an identifer after the Project has been created are rendered in the template', () => { @@ -1018,7 +1017,7 @@ describe('secondary sources', () => { identifier: 'source1', })); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'SecondarySources': [ { 'SourceIdentifier': 'source1', @@ -1047,7 +1046,7 @@ describe('secondary source versions', () => { version: 'someversion', })); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'SecondarySources': [ { 'SourceIdentifier': 'source1', @@ -1079,7 +1078,7 @@ describe('secondary source versions', () => { identifier: 'source1', })); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'SecondarySources': [ { 'SourceIdentifier': 'source1', @@ -1105,7 +1104,7 @@ describe('fileSystemLocations', () => { })], }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'FileSystemLocations': [ { 'Identifier': 'myidentifier2', @@ -1132,7 +1131,7 @@ describe('fileSystemLocations', () => { mountOptions: 'opts', })); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'FileSystemLocations': [ { 'Identifier': 'myidentifier3', @@ -1177,7 +1176,7 @@ describe('secondary artifacts', () => { identifier: 'id', })); - expect(() => SynthUtils.synthesize(stack)).toThrow(/secondary artifacts/); + expect(() => Template.fromStack(stack)).toThrow(/secondary artifacts/); }); test('added with an identifier after the Project has been created are rendered in the template', () => { @@ -1197,7 +1196,7 @@ describe('secondary artifacts', () => { identifier: 'artifact1', })); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'SecondaryArtifacts': [ { 'ArtifactIdentifier': 'artifact1', @@ -1225,7 +1224,7 @@ describe('secondary artifacts', () => { encryption: false, })); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'SecondaryArtifacts': [ { 'ArtifactIdentifier': 'artifact1', @@ -1243,7 +1242,7 @@ describe('artifacts', () => { new codebuild.PipelineProject(stack, 'MyProject'); - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Source': { 'Type': 'CODEPIPELINE', }, @@ -1283,9 +1282,9 @@ describe('artifacts', () => { }), }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Artifacts': { - 'Name': ABSENT, + 'Name': Match.absent(), 'ArtifactIdentifier': 'artifact1', 'OverrideArtifactName': true, }, @@ -1308,11 +1307,11 @@ describe('artifacts', () => { }), }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Artifacts': { 'ArtifactIdentifier': 'artifact1', 'Name': 'specificname', - 'OverrideArtifactName': ABSENT, + 'OverrideArtifactName': Match.absent(), }, }); }); @@ -1334,7 +1333,7 @@ test('events', () => { project.onStateChange('OnStateChange', { target: { bind: () => ({ arn: 'ARN', id: 'ID' }) } }); project.onBuildStarted('OnBuildStarted', { target: { bind: () => ({ arn: 'ARN', id: 'ID' }) } }); - expect(stack).toHaveResource('AWS::Events::Rule', { + Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', { 'EventPattern': { 'source': [ 'aws.codebuild', @@ -1356,7 +1355,7 @@ test('events', () => { 'State': 'ENABLED', }); - expect(stack).toHaveResource('AWS::Events::Rule', { + Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', { 'EventPattern': { 'source': [ 'aws.codebuild', @@ -1378,7 +1377,7 @@ test('events', () => { 'State': 'ENABLED', }); - expect(stack).toHaveResource('AWS::Events::Rule', { + Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', { 'EventPattern': { 'source': [ 'aws.codebuild', @@ -1397,7 +1396,7 @@ test('events', () => { 'State': 'ENABLED', }); - expect(stack).toHaveResource('AWS::Events::Rule', { + Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', { 'EventPattern': { 'source': [ 'aws.codebuild', @@ -1416,7 +1415,7 @@ test('events', () => { 'State': 'ENABLED', }); - expect(stack).toHaveResource('AWS::Events::Rule', { + Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', { 'EventPattern': { 'source': [ 'aws.codebuild', @@ -1455,7 +1454,7 @@ test('environment variables can be overridden at the project level', () => { }, }); - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Source': { 'Type': 'CODEPIPELINE', }, @@ -1554,7 +1553,7 @@ test('fromCodebuildImage', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'Image': 'aws/codebuild/standard:4.0', }, @@ -1571,7 +1570,7 @@ describe('Windows2019 image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'Type': 'WINDOWS_SERVER_2019_CONTAINER', 'ComputeType': 'BUILD_GENERAL1_MEDIUM', @@ -1591,7 +1590,7 @@ describe('ARM image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'Type': 'ARM_CONTAINER', 'ComputeType': 'BUILD_GENERAL1_LARGE', @@ -1608,7 +1607,7 @@ describe('ARM image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'Type': 'ARM_CONTAINER', 'ComputeType': 'BUILD_GENERAL1_SMALL', @@ -1638,7 +1637,7 @@ describe('ARM image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'Type': 'ARM_CONTAINER', 'ComputeType': 'BUILD_GENERAL1_LARGE', @@ -1867,7 +1866,7 @@ test('enableBatchBuilds()', () => { throw new Error('Expecting return value with role'); } - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { BuildBatchConfig: { ServiceRole: { 'Fn::GetAtt': [ @@ -1878,7 +1877,7 @@ test('enableBatchBuilds()', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Role', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { AssumeRolePolicyDocument: { Statement: [ { @@ -1893,7 +1892,7 @@ test('enableBatchBuilds()', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { Statement: [ { diff --git a/packages/@aws-cdk/aws-codebuild/test/linux-gpu-build-image.test.ts b/packages/@aws-cdk/aws-codebuild/test/linux-gpu-build-image.test.ts index d3b0d44dde984..106836acdac21 100644 --- a/packages/@aws-cdk/aws-codebuild/test/linux-gpu-build-image.test.ts +++ b/packages/@aws-cdk/aws-codebuild/test/linux-gpu-build-image.test.ts @@ -1,5 +1,4 @@ -import { arrayWith, objectLike } from '@aws-cdk/assert-internal'; -import '@aws-cdk/assert-internal/jest'; +import { Match, Template } from '@aws-cdk/assertions'; import * as ecr from '@aws-cdk/aws-ecr'; import * as cdk from '@aws-cdk/core'; import * as codebuild from '../lib'; @@ -22,7 +21,7 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Environment: { ComputeType: 'BUILD_GENERAL1_LARGE', Image: { @@ -37,9 +36,9 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { - Statement: arrayWith(objectLike({ + Statement: Match.arrayWith([Match.objectLike({ Action: [ 'ecr:BatchCheckLayerAvailability', 'ecr:GetDownloadUrlForLayer', @@ -54,7 +53,7 @@ describe('Linux GPU build image', () => { ':123456789012:repository/my-repo', ]], }, - })), + })]), }, }); }); @@ -78,7 +77,7 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Environment: { ComputeType: 'BUILD_GENERAL1_LARGE', Image: { @@ -96,9 +95,9 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { - Statement: arrayWith(objectLike({ + Statement: Match.arrayWith([Match.objectLike({ Action: [ 'ecr:BatchCheckLayerAvailability', 'ecr:GetDownloadUrlForLayer', @@ -116,7 +115,7 @@ describe('Linux GPU build image', () => { { Ref: 'myrepo5DFA62E5' }, ]], }, - })), + })]), }, }); }); @@ -138,7 +137,7 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Environment: { ComputeType: 'BUILD_GENERAL1_LARGE', Image: { @@ -154,9 +153,9 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { - Statement: arrayWith(objectLike({ + Statement: Match.arrayWith([Match.objectLike({ Action: [ 'ecr:BatchCheckLayerAvailability', 'ecr:GetDownloadUrlForLayer', @@ -173,7 +172,7 @@ describe('Linux GPU build image', () => { ':repository/test-repo', ]], }, - })), + })]), }, }); }); @@ -195,7 +194,7 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Environment: { ComputeType: 'BUILD_GENERAL1_LARGE', Image: { @@ -210,9 +209,9 @@ describe('Linux GPU build image', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { - Statement: arrayWith(objectLike({ + Statement: Match.arrayWith([Match.objectLike({ Action: [ 'ecr:BatchCheckLayerAvailability', 'ecr:GetDownloadUrlForLayer', @@ -227,7 +226,7 @@ describe('Linux GPU build image', () => { ':585695036304:repository/foo/bar/foo/fooo', ]], }, - })), + })]), }, }); }); diff --git a/packages/@aws-cdk/aws-codebuild/test/notification-rule.test.ts b/packages/@aws-cdk/aws-codebuild/test/notification-rule.test.ts index 45d6a65d76ce4..e0dc908185427 100644 --- a/packages/@aws-cdk/aws-codebuild/test/notification-rule.test.ts +++ b/packages/@aws-cdk/aws-codebuild/test/notification-rule.test.ts @@ -1,4 +1,4 @@ -import '@aws-cdk/assert-internal/jest'; +import { Template } from '@aws-cdk/assertions'; import * as sns from '@aws-cdk/aws-sns'; import * as cdk from '@aws-cdk/core'; import * as codebuild from '../lib'; @@ -24,7 +24,7 @@ test('notifications rule', () => { project.notifyOnBuildFailed('NotifyOnBuildFailed', target); - expect(stack).toHaveResource('AWS::CodeStarNotifications::NotificationRule', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeStarNotifications::NotificationRule', { Name: 'MyCodebuildProjectNotifyOnBuildSucceeded77719592', DetailType: 'FULL', EventTypeIds: [ @@ -46,7 +46,7 @@ test('notifications rule', () => { ], }); - expect(stack).toHaveResource('AWS::CodeStarNotifications::NotificationRule', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeStarNotifications::NotificationRule', { Name: 'MyCodebuildProjectNotifyOnBuildFailedF680E310', DetailType: 'FULL', EventTypeIds: [ diff --git a/packages/@aws-cdk/aws-codebuild/test/project.test.ts b/packages/@aws-cdk/aws-codebuild/test/project.test.ts index bf93885378ac5..5c7a17d7eb40d 100644 --- a/packages/@aws-cdk/aws-codebuild/test/project.test.ts +++ b/packages/@aws-cdk/aws-codebuild/test/project.test.ts @@ -1,5 +1,4 @@ -import { ABSENT, objectLike, ResourcePart, arrayWith } from '@aws-cdk/assert-internal'; -import '@aws-cdk/assert-internal/jest'; +import { Match, Template } from '@aws-cdk/assertions'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as logs from '@aws-cdk/aws-logs'; @@ -24,7 +23,7 @@ test('can use filename as buildspec', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { BuildSpec: 'hello.yml', }, @@ -41,7 +40,7 @@ test('can use buildspec literal', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { BuildSpec: '{\n "phases": [\n "say hi"\n ]\n}', }, @@ -67,7 +66,7 @@ test('can use yamlbuildspec literal', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { BuildSpec: 'text: text\ndecimal: 10\nlist:\n - say hi\nobj:\n text: text\n decimal: 10\n list:\n - say hi\n', }, @@ -110,7 +109,7 @@ describe('GitHub source', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { Type: 'GITHUB', Location: 'https://github.com/testowner/testrepo.git', @@ -134,7 +133,7 @@ describe('GitHub source', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { SourceVersion: 'testbranch', }); }); @@ -153,7 +152,7 @@ describe('GitHub source', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Source: { ReportBuildStatus: false, }, @@ -174,7 +173,7 @@ describe('GitHub source', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Triggers: { Webhook: true, }, @@ -207,7 +206,7 @@ describe('GitHub source', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::SourceCredential', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::SourceCredential', { 'ServerType': 'GITHUB', 'AuthType': 'PERSONAL_ACCESS_TOKEN', 'Token': 'my-access-token', @@ -229,7 +228,7 @@ describe('GitHub Enterprise source', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { SourceVersion: 'testbranch', }); }); @@ -244,7 +243,7 @@ describe('GitHub Enterprise source', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::SourceCredential', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::SourceCredential', { 'ServerType': 'GITHUB_ENTERPRISE', 'AuthType': 'PERSONAL_ACCESS_TOKEN', 'Token': 'my-access-token', @@ -267,7 +266,7 @@ describe('BitBucket source', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { SourceVersion: 'testbranch', }); }); @@ -283,7 +282,7 @@ describe('BitBucket source', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::SourceCredential', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::SourceCredential', { 'ServerType': 'BITBUCKET', 'AuthType': 'BASIC_AUTH', 'Username': 'my-username', @@ -303,10 +302,10 @@ describe('caching', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Cache: { Type: 'NO_CACHE', - Location: ABSENT, + Location: Match.absent(), }, }); }); @@ -327,7 +326,7 @@ describe('caching', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Cache: { Type: 'S3', Location: { @@ -361,7 +360,7 @@ describe('caching', () => { }); // THEN - expect(stack).toHaveResource('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { SourceVersion: 's3version', }); }); @@ -381,7 +380,7 @@ describe('caching', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Cache: { Type: 'LOCAL', Modes: [ @@ -406,10 +405,10 @@ describe('caching', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { Cache: { Type: 'NO_CACHE', - Location: ABSENT, + Location: Match.absent(), }, }); }); @@ -434,18 +433,18 @@ test('if a role is shared between projects in a VPC, the VPC Policy is only atta // - 1 is for `ec2:CreateNetworkInterfacePermission`, deduplicated as they're part of a single policy // - 1 is for `ec2:CreateNetworkInterface`, this is the separate Policy we're deduplicating // We would have found 3 if the deduplication didn't work. - expect(stack).toCountResources('AWS::IAM::Policy', 2); + Template.fromStack(stack).resourceCountIs('AWS::IAM::Policy', 2); // THEN - both Projects have a DependsOn on the same policy - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResource('AWS::CodeBuild::Project', { Properties: { Name: 'P1' }, DependsOn: ['Project1PolicyDocumentF9761562'], - }, ResourcePart.CompleteDefinition); + }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResource('AWS::CodeBuild::Project', { Properties: { Name: 'P1' }, DependsOn: ['Project1PolicyDocumentF9761562'], - }, ResourcePart.CompleteDefinition); + }); }); test('can use an imported Role for a Project within a VPC', () => { @@ -462,7 +461,7 @@ test('can use an imported Role for a Project within a VPC', () => { vpc, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { // no need to do any assertions }); }); @@ -484,15 +483,15 @@ test('can use an imported Role with mutable = false for a Project within a VPC', vpc, }); - expect(stack).toCountResources('AWS::IAM::Policy', 0); + Template.fromStack(stack).resourceCountIs('AWS::IAM::Policy', 0); // Check that the CodeBuild project does not have a DependsOn - expect(stack).toHaveResource('AWS::CodeBuild::Project', (res: any) => { + Template.fromStack(stack).hasResource('AWS::CodeBuild::Project', (res: any) => { if (res.DependsOn && res.DependsOn.length > 0) { throw new Error(`CodeBuild project should have no DependsOn, but got: ${JSON.stringify(res, undefined, 2)}`); } return true; - }, ResourcePart.CompleteDefinition); + }); }); test('can use an ImmutableRole for a Project within a VPC', () => { @@ -512,15 +511,15 @@ test('can use an ImmutableRole for a Project within a VPC', () => { vpc, }); - expect(stack).toCountResources('AWS::IAM::Policy', 0); + Template.fromStack(stack).resourceCountIs('AWS::IAM::Policy', 0); // Check that the CodeBuild project does not have a DependsOn - expect(stack).toHaveResource('AWS::CodeBuild::Project', (res: any) => { + Template.fromStack(stack).hasResource('AWS::CodeBuild::Project', (res: any) => { if (res.DependsOn && res.DependsOn.length > 0) { throw new Error(`CodeBuild project should have no DependsOn, but got: ${JSON.stringify(res, undefined, 2)}`); } return true; - }, ResourcePart.CompleteDefinition); + }); }); test('metric method generates a valid CloudWatch metric', () => { @@ -557,7 +556,7 @@ describe('CodeBuild test reports group', () => { }); reportGroup.grantWrite(project); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { 'Statement': [ {}, @@ -598,8 +597,8 @@ describe('Environment', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - Environment: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: Match.objectLike({ RegistryCredential: { CredentialProvider: 'SECRETS_MANAGER', Credential: { 'Ref': 'SecretA720EF05' }, @@ -625,8 +624,8 @@ describe('Environment', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - Environment: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: Match.objectLike({ RegistryCredential: { CredentialProvider: 'SECRETS_MANAGER', Credential: 'MySecretName', @@ -655,8 +654,8 @@ describe('Environment', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - LogsConfig: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + LogsConfig: Match.objectLike({ CloudWatchLogs: { GroupName: 'MyLogGroupName', Status: 'ENABLED', @@ -684,8 +683,8 @@ describe('Environment', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - LogsConfig: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + LogsConfig: Match.objectLike({ CloudWatchLogs: { Status: 'DISABLED', }, @@ -713,8 +712,8 @@ describe('Environment', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - LogsConfig: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + LogsConfig: Match.objectLike({ S3Logs: { Location: 'mybucketname/my-logs', Status: 'ENABLED', @@ -746,8 +745,8 @@ describe('Environment', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - LogsConfig: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + LogsConfig: Match.objectLike({ CloudWatchLogs: { GroupName: 'MyLogGroupName', Status: 'ENABLED', @@ -780,8 +779,8 @@ describe('Environment', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - Environment: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: Match.objectLike({ Certificate: { 'Fn::Join': ['', [ 'arn:', @@ -818,8 +817,8 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { - Environment: objectLike({ + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: Match.objectLike({ EnvironmentVariables: [{ Name: 'ENV_VAR1', Type: 'PARAMETER_STORE', @@ -855,9 +854,9 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith(objectLike({ + 'Statement': Match.arrayWith([Match.objectLike({ 'Action': 'ssm:GetParameters', 'Effect': 'Allow', 'Resource': [{ @@ -900,7 +899,7 @@ describe('EnvironmentVariables', () => { ], ], }], - })), + })]), }, }); }); @@ -928,14 +927,14 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).not.toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', Match.not({ 'PolicyDocument': { - 'Statement': arrayWith(objectLike({ + 'Statement': Match.arrayWith([Match.objectLike({ 'Action': 'ssm:GetParameters', 'Effect': 'Allow', - })), + })]), }, - }); + })); }); }); @@ -955,7 +954,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -968,9 +967,9 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { @@ -984,7 +983,7 @@ describe('EnvironmentVariables', () => { ':secret:my-secret-??????', ]], }, - }), + }]), }, }); }); @@ -1004,7 +1003,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1017,9 +1016,9 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { @@ -1033,7 +1032,7 @@ describe('EnvironmentVariables', () => { ':secret:my-secret-??????', ]], }, - }), + }]), }, }); }); @@ -1053,7 +1052,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1066,26 +1065,26 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': 'arn:aws:secretsmanager:us-west-2:123456789012:secret:my-secret-123456*', - }), + }]), }, }); // THEN - expect(stack).not.toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', Match.not({ 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'kms:Decrypt', 'Effect': 'Allow', 'Resource': 'arn:aws:kms:us-west-2:123456789012:key/*', - }), + }]), }, - }); + })); }); test('can be provided as a verbatim partial secret ARN', () => { @@ -1103,7 +1102,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1116,26 +1115,26 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': 'arn:aws:secretsmanager:us-west-2:123456789012:secret:mysecret*', - }), + }]), }, }); // THEN - expect(stack).not.toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', Match.not({ 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'kms:Decrypt', 'Effect': 'Allow', 'Resource': 'arn:aws:kms:us-west-2:123456789012:key/*', - }), + }]), }, - }); + })); }); test("when provided as a verbatim partial secret ARN from another account, adds permission to decrypt keys in the Secret's account", () => { @@ -1156,13 +1155,13 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'kms:Decrypt', 'Effect': 'Allow', 'Resource': 'arn:aws:kms:us-west-2:901234567890:key/*', - }), + }]), }, }); }); @@ -1189,13 +1188,13 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'kms:Decrypt', 'Effect': 'Allow', 'Resource': 'arn:aws:kms:us-west-2:901234567890:key/*', - }), + }]), }, }); }); @@ -1216,7 +1215,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1229,13 +1228,13 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { 'Ref': 'SecretA720EF05' }, - }), + }]), }, }); }); @@ -1260,7 +1259,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1278,13 +1277,13 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { 'Ref': 'SecretA720EF05' }, - }), + }]), }, }); }); @@ -1305,7 +1304,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1323,13 +1322,13 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { 'Ref': 'SecretA720EF05' }, - }), + }]), }, }); }); @@ -1350,7 +1349,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1363,9 +1362,9 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { @@ -1379,7 +1378,7 @@ describe('EnvironmentVariables', () => { ':secret:mysecret-??????', ]], }, - }), + }]), }, }); }); @@ -1401,7 +1400,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1414,13 +1413,13 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': 'arn:aws:secretsmanager:us-west-2:123456789012:secret:mysecret*', - }), + }]), }, }); }); @@ -1442,7 +1441,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1455,13 +1454,13 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': 'arn:aws:secretsmanager:us-west-2:123456789012:secret:mysecret-123456*', - }), + }]), }, }); }); @@ -1488,7 +1487,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1508,9 +1507,9 @@ describe('EnvironmentVariables', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { @@ -1522,13 +1521,13 @@ describe('EnvironmentVariables', () => { ':012345678912:secret:secret-name-??????', ]], }, - }), + }]), }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'kms:Decrypt', 'Effect': 'Allow', 'Resource': { @@ -1540,7 +1539,7 @@ describe('EnvironmentVariables', () => { ':012345678912:key/*', ]], }, - }), + }]), }, }); }); @@ -1567,7 +1566,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1587,9 +1586,9 @@ describe('EnvironmentVariables', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': { @@ -1601,13 +1600,13 @@ describe('EnvironmentVariables', () => { ':012345678912:secret:secret-name*', ]], }, - }), + }]), }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'kms:Decrypt', 'Effect': 'Allow', 'Resource': { @@ -1619,7 +1618,7 @@ describe('EnvironmentVariables', () => { ':012345678912:key/*', ]], }, - }), + }]), }, }); }); @@ -1644,7 +1643,7 @@ describe('EnvironmentVariables', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { 'Environment': { 'EnvironmentVariables': [ { @@ -1656,23 +1655,23 @@ describe('EnvironmentVariables', () => { }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'secretsmanager:GetSecretValue', 'Effect': 'Allow', 'Resource': `${secretArn}*`, - }), + }]), }, }); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { 'PolicyDocument': { - 'Statement': arrayWith({ + 'Statement': Match.arrayWith([{ 'Action': 'kms:Decrypt', 'Effect': 'Allow', 'Resource': 'arn:aws:kms:us-west-2:901234567890:key/*', - }), + }]), }, }); }); @@ -1744,7 +1743,7 @@ describe('Timeouts', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { QueuedTimeoutInMinutes: 30, }); }); @@ -1763,7 +1762,7 @@ describe('Timeouts', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { TimeoutInMinutes: 30, }); }); @@ -1784,7 +1783,7 @@ describe('Maximum concurrency', () => { }); // THEN - expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { ConcurrentBuildLimit: 1, }); }); diff --git a/packages/@aws-cdk/aws-codebuild/test/report-group.test.ts b/packages/@aws-cdk/aws-codebuild/test/report-group.test.ts index 4459ef4672f0c..6e653d891f3fb 100644 --- a/packages/@aws-cdk/aws-codebuild/test/report-group.test.ts +++ b/packages/@aws-cdk/aws-codebuild/test/report-group.test.ts @@ -1,5 +1,4 @@ -import { ABSENT, ResourcePart } from '@aws-cdk/assert-internal'; -import '@aws-cdk/assert-internal/jest'; +import { Match, Template } from '@aws-cdk/assertions'; import * as iam from '@aws-cdk/aws-iam'; import * as kms from '@aws-cdk/aws-kms'; import * as s3 from '@aws-cdk/aws-s3'; @@ -15,11 +14,11 @@ describe('Test Reports Groups', () => { new codebuild.ReportGroup(stack, 'ReportGroup'); - expect(stack).toHaveResourceLike('AWS::CodeBuild::ReportGroup', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::ReportGroup', { "Type": "TEST", "ExportConfig": { "ExportConfigType": "NO_EXPORT", - "S3Destination": ABSENT, + "S3Destination": Match.absent(), }, }); }); @@ -31,7 +30,7 @@ describe('Test Reports Groups', () => { reportGroupName: 'my-report-group', }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::ReportGroup', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::ReportGroup', { "Name": 'my-report-group', }); }); @@ -51,7 +50,7 @@ describe('Test Reports Groups', () => { })); expect(reportGroup.reportGroupName).toEqual('my-report-group'); - expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { "PolicyDocument": { "Statement": [ { @@ -80,15 +79,15 @@ describe('Test Reports Groups', () => { exportBucket: s3.Bucket.fromBucketName(stack, 'Bucket', 'my-bucket'), }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::ReportGroup', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::ReportGroup', { "Type": "TEST", "ExportConfig": { "ExportConfigType": "S3", "S3Destination": { "Bucket": "my-bucket", - "EncryptionKey": ABSENT, - "EncryptionDisabled": ABSENT, - "Packaging": ABSENT, + "EncryptionKey": Match.absent(), + "EncryptionDisabled": Match.absent(), + "Packaging": Match.absent(), }, }, }); @@ -106,7 +105,7 @@ describe('Test Reports Groups', () => { zipExport: true, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::ReportGroup', { + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::ReportGroup', { "Type": "TEST", "ExportConfig": { "ExportConfigType": "S3", @@ -125,10 +124,10 @@ describe('Test Reports Groups', () => { new codebuild.ReportGroup(stack, 'ReportGroup'); - expect(stack).toHaveResourceLike('AWS::CodeBuild::ReportGroup', { + Template.fromStack(stack).hasResource('AWS::CodeBuild::ReportGroup', { "DeletionPolicy": "Retain", "UpdateReplacePolicy": "Retain", - }, ResourcePart.CompleteDefinition); + }); }); test('can be created with RemovalPolicy.DESTROY', () => { @@ -138,9 +137,9 @@ describe('Test Reports Groups', () => { removalPolicy: cdk.RemovalPolicy.DESTROY, }); - expect(stack).toHaveResourceLike('AWS::CodeBuild::ReportGroup', { + Template.fromStack(stack).hasResource('AWS::CodeBuild::ReportGroup', { "DeletionPolicy": "Delete", "UpdateReplacePolicy": "Delete", - }, ResourcePart.CompleteDefinition); + }); }); }); diff --git a/packages/@aws-cdk/aws-codebuild/test/untrusted-code-boundary.test.ts b/packages/@aws-cdk/aws-codebuild/test/untrusted-code-boundary.test.ts index 89933d11a7ab8..af1f4fdfb328f 100644 --- a/packages/@aws-cdk/aws-codebuild/test/untrusted-code-boundary.test.ts +++ b/packages/@aws-cdk/aws-codebuild/test/untrusted-code-boundary.test.ts @@ -1,5 +1,4 @@ -import { arrayWith } from '@aws-cdk/assert-internal'; -import '@aws-cdk/assert-internal/jest'; +import { Match, Template } from '@aws-cdk/assertions'; import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; import * as codebuild from '../lib'; @@ -15,7 +14,7 @@ test('can attach permissions boundary to Project', () => { iam.PermissionsBoundary.of(project).apply(new codebuild.UntrustedCodeBoundaryPolicy(stack, 'Boundary')); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::Role', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { PermissionsBoundary: { Ref: 'BoundaryEA298153' }, }); }); @@ -38,13 +37,13 @@ test('can add additional statements Boundary', () => { })); // THEN - expect(stack).toHaveResourceLike('AWS::IAM::ManagedPolicy', { + Template.fromStack(stack).hasResourceProperties('AWS::IAM::ManagedPolicy', { PolicyDocument: { - Statement: arrayWith({ + Statement: Match.arrayWith([{ Effect: 'Allow', Action: 'a:a', Resource: 'b', - }), + }]), }, }); -}); \ No newline at end of file +});