1
- import { anything , arrayWith , Capture , objectLike } from '@aws-cdk/assert-internal' ;
2
- import '@aws-cdk/assert-internal/jest' ;
1
+ import { Capture , Match , Template } from '@aws-cdk/assertions' ;
3
2
import * as ccommit from '@aws-cdk/aws-codecommit' ;
4
3
import { CodeCommitTrigger , GitHubTrigger } from '@aws-cdk/aws-codepipeline-actions' ;
5
4
import { AnyPrincipal , Role } from '@aws-cdk/aws-iam' ;
@@ -28,18 +27,18 @@ test('CodeCommit source handles tokenized names correctly', () => {
28
27
input : cdkp . CodePipelineSource . codeCommit ( repo , 'main' ) ,
29
28
} ) ;
30
29
31
- expect ( pipelineStack ) . toHaveResourceLike ( 'AWS::CodePipeline::Pipeline' , {
32
- Stages : arrayWith ( {
30
+ Template . fromStack ( pipelineStack ) . hasResourceProperties ( 'AWS::CodePipeline::Pipeline' , {
31
+ Stages : Match . arrayWith ( [ {
33
32
Name : 'Source' ,
34
33
Actions : [
35
- objectLike ( {
36
- Configuration : objectLike ( {
37
- RepositoryName : { 'Fn::GetAtt' : [ anything ( ) , 'Name' ] } ,
34
+ Match . objectLike ( {
35
+ Configuration : Match . objectLike ( {
36
+ RepositoryName : { 'Fn::GetAtt' : [ Match . anyValue ( ) , 'Name' ] } ,
38
37
} ) ,
39
- Name : { 'Fn::GetAtt' : [ anything ( ) , 'Name' ] } ,
38
+ Name : { 'Fn::GetAtt' : [ Match . anyValue ( ) , 'Name' ] } ,
40
39
} ) ,
41
40
] ,
42
- } ) ,
41
+ } ] ) ,
43
42
} ) ;
44
43
} ) ;
45
44
@@ -58,20 +57,20 @@ test('CodeCommit source honors all valid properties', () => {
58
57
} ) ,
59
58
} ) ;
60
59
61
- expect ( pipelineStack ) . toHaveResourceLike ( 'AWS::CodePipeline::Pipeline' , {
62
- Stages : arrayWith ( {
60
+ Template . fromStack ( pipelineStack ) . hasResourceProperties ( 'AWS::CodePipeline::Pipeline' , {
61
+ Stages : Match . arrayWith ( [ {
63
62
Name : 'Source' ,
64
63
Actions : [
65
- objectLike ( {
66
- Configuration : objectLike ( {
64
+ Match . objectLike ( {
65
+ Configuration : Match . objectLike ( {
67
66
BranchName : 'main' ,
68
67
PollForSourceChanges : true ,
69
68
OutputArtifactFormat : 'CODEBUILD_CLONE_REF' ,
70
69
} ) ,
71
- RoleArn : { 'Fn::GetAtt' : [ anything ( ) , 'Arn' ] } ,
70
+ RoleArn : { 'Fn::GetAtt' : [ Match . anyValue ( ) , 'Arn' ] } ,
72
71
} ) ,
73
72
] ,
74
- } ) ,
73
+ } ] ) ,
75
74
} ) ;
76
75
} ) ;
77
76
@@ -81,19 +80,19 @@ test('S3 source handles tokenized names correctly', () => {
81
80
input : cdkp . CodePipelineSource . s3 ( buckit , 'thefile.zip' ) ,
82
81
} ) ;
83
82
84
- expect ( pipelineStack ) . toHaveResourceLike ( 'AWS::CodePipeline::Pipeline' , {
85
- Stages : arrayWith ( {
83
+ Template . fromStack ( pipelineStack ) . hasResourceProperties ( 'AWS::CodePipeline::Pipeline' , {
84
+ Stages : Match . arrayWith ( [ {
86
85
Name : 'Source' ,
87
86
Actions : [
88
- objectLike ( {
89
- Configuration : objectLike ( {
90
- S3Bucket : { Ref : anything ( ) } ,
87
+ Match . objectLike ( {
88
+ Configuration : Match . objectLike ( {
89
+ S3Bucket : { Ref : Match . anyValue ( ) } ,
91
90
S3ObjectKey : 'thefile.zip' ,
92
91
} ) ,
93
- Name : { Ref : anything ( ) } ,
92
+ Name : { Ref : Match . anyValue ( ) } ,
94
93
} ) ,
95
94
] ,
96
- } ) ,
95
+ } ] ) ,
97
96
} ) ;
98
97
} ) ;
99
98
@@ -105,12 +104,12 @@ test('GitHub source honors all valid properties', () => {
105
104
} ) ,
106
105
} ) ;
107
106
108
- expect ( pipelineStack ) . toHaveResourceLike ( 'AWS::CodePipeline::Pipeline' , {
109
- Stages : arrayWith ( {
107
+ Template . fromStack ( pipelineStack ) . hasResourceProperties ( 'AWS::CodePipeline::Pipeline' , {
108
+ Stages : Match . arrayWith ( [ {
110
109
Name : 'Source' ,
111
110
Actions : [
112
- objectLike ( {
113
- Configuration : objectLike ( {
111
+ Match . objectLike ( {
112
+ Configuration : Match . objectLike ( {
114
113
Owner : 'owner' ,
115
114
Repo : 'repo' ,
116
115
Branch : 'main' ,
@@ -120,7 +119,7 @@ test('GitHub source honors all valid properties', () => {
120
119
Name : 'owner_repo' ,
121
120
} ) ,
122
121
] ,
123
- } ) ,
122
+ } ] ) ,
124
123
} ) ;
125
124
} ) ;
126
125
@@ -145,17 +144,17 @@ test('Dashes in repo names are removed from artifact names', () => {
145
144
input : cdkp . CodePipelineSource . gitHub ( 'owner/my-repo' , 'main' ) ,
146
145
} ) ;
147
146
148
- expect ( pipelineStack ) . toHaveResourceLike ( 'AWS::CodePipeline::Pipeline' , {
149
- Stages : arrayWith ( {
147
+ Template . fromStack ( pipelineStack ) . hasResourceProperties ( 'AWS::CodePipeline::Pipeline' , {
148
+ Stages : Match . arrayWith ( [ {
150
149
Name : 'Source' ,
151
150
Actions : [
152
- objectLike ( {
151
+ Match . objectLike ( {
153
152
OutputArtifacts : [
154
153
{ Name : 'owner_my_repo_Source' } ,
155
154
] ,
156
155
} ) ,
157
156
] ,
158
- } ) ,
157
+ } ] ) ,
159
158
} ) ;
160
159
} ) ;
161
160
@@ -164,19 +163,19 @@ test('artifact names are never longer than 128 characters', () => {
164
163
input : cdkp . CodePipelineSource . gitHub ( 'owner/' + 'my-repo' . repeat ( 100 ) , 'main' ) ,
165
164
} ) ;
166
165
167
- const artifactId = Capture . aString ( ) ;
168
- expect ( pipelineStack ) . toHaveResourceLike ( 'AWS::CodePipeline::Pipeline' , {
169
- Stages : arrayWith ( {
166
+ const artifactId = new Capture ( ) ;
167
+ Template . fromStack ( pipelineStack ) . hasResourceProperties ( 'AWS::CodePipeline::Pipeline' , {
168
+ Stages : Match . arrayWith ( [ {
170
169
Name : 'Source' ,
171
170
Actions : [
172
- objectLike ( {
171
+ Match . objectLike ( {
173
172
OutputArtifacts : [
174
- { Name : artifactId . capture ( ) } ,
173
+ { Name : artifactId } ,
175
174
] ,
176
175
} ) ,
177
176
] ,
178
- } ) ,
177
+ } ] ) ,
179
178
} ) ;
180
179
181
- expect ( artifactId . capturedValue . length ) . toBeLessThanOrEqual ( 128 ) ;
180
+ expect ( artifactId . asString ( ) . length ) . toBeLessThanOrEqual ( 128 ) ;
182
181
} ) ;
0 commit comments