@@ -21,7 +21,65 @@ describe('#compileStateMachines', () => {
21
21
serverlessStepFunctions = new ServerlessStepFunctions ( serverless ) ;
22
22
} ) ;
23
23
24
- it ( 'should create corresponding resources when definition property is given' , ( ) => {
24
+ it ( 'should create corresponding resources when definition and name property is given' , ( ) => {
25
+ serverless . service . stepFunctions = {
26
+ stateMachines : {
27
+ myStateMachine1 : {
28
+ name : 'stateMachineBeta1' ,
29
+ definition : 'definition1' ,
30
+ } ,
31
+ myStateMachine2 : {
32
+ name : 'stateMachineBeta2' ,
33
+ definition : 'definition2' ,
34
+ } ,
35
+ } ,
36
+ } ;
37
+
38
+ serverlessStepFunctions . compileStateMachines ( ) ;
39
+
40
+ expect ( serverlessStepFunctions . serverless . service
41
+ . provider . compiledCloudFormationTemplate . Resources
42
+ . StateMachineBeta1 . Type
43
+ ) . to . equal ( 'AWS::StepFunctions::StateMachine' ) ;
44
+ expect ( serverlessStepFunctions . serverless . service
45
+ . provider . compiledCloudFormationTemplate . Resources
46
+ . StateMachineBeta2 . Type
47
+ ) . to . equal ( 'AWS::StepFunctions::StateMachine' ) ;
48
+ expect ( serverlessStepFunctions . serverless . service
49
+ . provider . compiledCloudFormationTemplate . Resources
50
+ . StateMachineBeta1 . Properties . DefinitionString
51
+ ) . to . equal ( '"definition1"' ) ;
52
+ expect ( serverlessStepFunctions . serverless . service
53
+ . provider . compiledCloudFormationTemplate . Resources
54
+ . StateMachineBeta2 . Properties . DefinitionString
55
+ ) . to . equal ( '"definition2"' ) ;
56
+ expect ( serverlessStepFunctions . serverless . service
57
+ . provider . compiledCloudFormationTemplate . Resources
58
+ . StateMachineBeta1 . Properties . RoleArn [ 'Fn::GetAtt' ] [ 0 ]
59
+ ) . to . equal ( 'IamRoleStateMachineExecution' ) ;
60
+ expect ( serverlessStepFunctions . serverless . service
61
+ . provider . compiledCloudFormationTemplate . Resources
62
+ . StateMachineBeta2 . Properties . RoleArn [ 'Fn::GetAtt' ] [ 0 ]
63
+ ) . to . equal ( 'IamRoleStateMachineExecution' ) ;
64
+ expect ( serverlessStepFunctions . serverless . service
65
+ . provider . compiledCloudFormationTemplate . Resources
66
+ . StateMachineBeta1 . DependsOn
67
+ ) . to . equal ( 'IamRoleStateMachineExecution' ) ;
68
+ expect ( serverlessStepFunctions . serverless . service
69
+ . provider . compiledCloudFormationTemplate . Resources
70
+ . StateMachineBeta2 . DependsOn
71
+ ) . to . equal ( 'IamRoleStateMachineExecution' ) ;
72
+ expect ( serverlessStepFunctions . serverless . service
73
+ . provider . compiledCloudFormationTemplate . Outputs
74
+ . StateMachineBeta1Arn . Value . Ref
75
+ ) . to . equal ( 'StateMachineBeta1' ) ;
76
+ expect ( serverlessStepFunctions . serverless . service
77
+ . provider . compiledCloudFormationTemplate . Outputs
78
+ . StateMachineBeta2Arn . Value . Ref
79
+ ) . to . equal ( 'StateMachineBeta2' ) ;
80
+ } ) ;
81
+
82
+ it ( 'should create corresponding resources when definition property is given and no name' , ( ) => {
25
83
serverless . service . stepFunctions = {
26
84
stateMachines : {
27
85
myStateMachine1 : {
@@ -129,10 +187,12 @@ describe('#compileStateMachines', () => {
129
187
serverless . service . stepFunctions = {
130
188
stateMachines : {
131
189
myStateMachine1 : {
190
+ name : 'stateMachineBeta1' ,
132
191
definition : 'definition1' ,
133
192
role : 'arn:aws:role1' ,
134
193
} ,
135
194
myStateMachine2 : {
195
+ name : 'stateMachineBeta2' ,
136
196
definition : 'definition2' ,
137
197
role : 'arn:aws:role2' ,
138
198
} ,
@@ -142,36 +202,36 @@ describe('#compileStateMachines', () => {
142
202
serverlessStepFunctions . compileStateMachines ( ) ;
143
203
expect ( serverlessStepFunctions . serverless . service
144
204
. provider . compiledCloudFormationTemplate . Resources
145
- . MyStateMachine1StepFunctionsStateMachine . Type
205
+ . StateMachineBeta1 . Type
146
206
) . to . equal ( 'AWS::StepFunctions::StateMachine' ) ;
147
207
expect ( serverlessStepFunctions . serverless . service
148
208
. provider . compiledCloudFormationTemplate . Resources
149
- . MyStateMachine2StepFunctionsStateMachine . Type
209
+ . StateMachineBeta2 . Type
150
210
) . to . equal ( 'AWS::StepFunctions::StateMachine' ) ;
151
211
expect ( serverlessStepFunctions . serverless . service
152
212
. provider . compiledCloudFormationTemplate . Resources
153
- . MyStateMachine1StepFunctionsStateMachine . Properties . DefinitionString
213
+ . StateMachineBeta1 . Properties . DefinitionString
154
214
) . to . equal ( '"definition1"' ) ;
155
215
expect ( serverlessStepFunctions . serverless . service
156
216
. provider . compiledCloudFormationTemplate . Resources
157
- . MyStateMachine2StepFunctionsStateMachine . Properties . DefinitionString
217
+ . StateMachineBeta2 . Properties . DefinitionString
158
218
) . to . equal ( '"definition2"' ) ;
159
219
expect ( serverlessStepFunctions . serverless . service
160
220
. provider . compiledCloudFormationTemplate . Resources
161
- . MyStateMachine1StepFunctionsStateMachine . Properties . RoleArn
221
+ . StateMachineBeta1 . Properties . RoleArn
162
222
) . to . equal ( 'arn:aws:role1' ) ;
163
223
expect ( serverlessStepFunctions . serverless . service
164
224
. provider . compiledCloudFormationTemplate . Resources
165
- . MyStateMachine2StepFunctionsStateMachine . Properties . RoleArn
225
+ . StateMachineBeta2 . Properties . RoleArn
166
226
) . to . equal ( 'arn:aws:role2' ) ;
167
227
expect ( serverlessStepFunctions . serverless . service
168
228
. provider . compiledCloudFormationTemplate . Outputs
169
- . MyStateMachine1StepFunctionsStateMachineArn . Value . Ref
170
- ) . to . equal ( 'MyStateMachine1StepFunctionsStateMachine ' ) ;
229
+ . StateMachineBeta1Arn . Value . Ref
230
+ ) . to . equal ( 'StateMachineBeta1 ' ) ;
171
231
expect ( serverlessStepFunctions . serverless . service
172
232
. provider . compiledCloudFormationTemplate . Outputs
173
- . MyStateMachine2StepFunctionsStateMachineArn . Value . Ref
174
- ) . to . equal ( 'MyStateMachine2StepFunctionsStateMachine ' ) ;
233
+ . StateMachineBeta2Arn . Value . Ref
234
+ ) . to . equal ( 'StateMachineBeta2 ' ) ;
175
235
} ) ;
176
236
177
237
it ( 'should throw error when definition property is not given' , ( ) => {
@@ -188,9 +248,11 @@ describe('#compileStateMachines', () => {
188
248
serverless . service . stepFunctions = {
189
249
stateMachines : {
190
250
myStateMachine1 : {
251
+ name : 'stateMachineBeta1' ,
191
252
definition : 'definition1\n' ,
192
253
} ,
193
254
myStateMachine2 : {
255
+ name : 'stateMachineBeta2' ,
194
256
definition : 'definition2\n' ,
195
257
} ,
196
258
} ,
@@ -199,19 +261,19 @@ describe('#compileStateMachines', () => {
199
261
serverlessStepFunctions . compileStateMachines ( ) ;
200
262
expect ( serverlessStepFunctions . serverless . service
201
263
. provider . compiledCloudFormationTemplate . Resources
202
- . MyStateMachine1StepFunctionsStateMachine . Type
264
+ . StateMachineBeta1 . Type
203
265
) . to . equal ( 'AWS::StepFunctions::StateMachine' ) ;
204
266
expect ( serverlessStepFunctions . serverless . service
205
267
. provider . compiledCloudFormationTemplate . Resources
206
- . MyStateMachine2StepFunctionsStateMachine . Type
268
+ . StateMachineBeta2 . Type
207
269
) . to . equal ( 'AWS::StepFunctions::StateMachine' ) ;
208
270
expect ( serverlessStepFunctions . serverless . service
209
271
. provider . compiledCloudFormationTemplate . Resources
210
- . MyStateMachine1StepFunctionsStateMachine . Properties . DefinitionString
272
+ . StateMachineBeta1 . Properties . DefinitionString
211
273
) . to . equal ( '"definition1"' ) ;
212
274
expect ( serverlessStepFunctions . serverless . service
213
275
. provider . compiledCloudFormationTemplate . Resources
214
- . MyStateMachine2StepFunctionsStateMachine . Properties . DefinitionString
276
+ . StateMachineBeta2 . Properties . DefinitionString
215
277
) . to . equal ( '"definition2"' ) ;
216
278
} ) ;
217
279
@@ -221,6 +283,7 @@ describe('#compileStateMachines', () => {
221
283
myStateMachine1 : {
222
284
definition : 'definition1' ,
223
285
role : 'srn:aws:role1' ,
286
+ name : 'stateMachineBeta1' ,
224
287
} ,
225
288
} ,
226
289
} ;
@@ -231,6 +294,7 @@ describe('#compileStateMachines', () => {
231
294
serverless . service . stepFunctions = {
232
295
stateMachines : {
233
296
myStateMachine1 : {
297
+ name : 'stateMachineBeta1' ,
234
298
definition : 'definition1' ,
235
299
role : { 'arn:aws:role1' : 'ss' } ,
236
300
} ,
@@ -241,6 +305,7 @@ describe('#compileStateMachines', () => {
241
305
serverless . service . stepFunctions = {
242
306
stateMachines : {
243
307
myStateMachine1 : {
308
+ name : 'stateMachineBeta2' ,
244
309
definition : 'definition1' ,
245
310
role : [ 'arn:aws:role1' ] ,
246
311
} ,
0 commit comments