@@ -31,7 +31,6 @@ func TestBasicValidation(t *testing.T) {
31
31
if ! file .IsDir () {
32
32
workflow , err := FromFile (filepath .Join (rootPath , file .Name ()))
33
33
if assert .NoError (t , err , "Test File %s" , file .Name ()) {
34
- assert .NotEmpty (t , workflow .Name , "Test File %s" , file .Name ())
35
34
assert .NotEmpty (t , workflow .ID , "Test File %s" , file .Name ())
36
35
assert .NotEmpty (t , workflow .States , "Test File %s" , file .Name ())
37
36
}
@@ -54,18 +53,21 @@ func TestCustomValidators(t *testing.T) {
54
53
func TestFromFile (t * testing.T ) {
55
54
files := map [string ]func (* testing.T , * model.Workflow ){
56
55
"./testdata/workflows/greetings.sw.json" : func (t * testing.T , w * model.Workflow ) {
56
+ assert .Equal (t , "Greeting Workflow" , w .Name )
57
57
assert .Equal (t , "greeting" , w .ID )
58
58
assert .IsType (t , & model.OperationState {}, w .States [0 ])
59
59
assert .Equal (t , "greetingFunction" , w .States [0 ].(* model.OperationState ).Actions [0 ].FunctionRef .RefName )
60
60
},
61
61
"./testdata/workflows/greetings.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
62
+ assert .Equal (t , "Greeting Workflow" , w .Name )
62
63
assert .IsType (t , & model.OperationState {}, w .States [0 ])
63
64
assert .Equal (t , "greeting" , w .ID )
64
65
assert .NotEmpty (t , w .States [0 ].(* model.OperationState ).Actions )
65
66
assert .NotNil (t , w .States [0 ].(* model.OperationState ).Actions [0 ].FunctionRef )
66
67
assert .Equal (t , "greetingFunction" , w .States [0 ].(* model.OperationState ).Actions [0 ].FunctionRef .RefName )
67
68
},
68
- "./testdata/workflows/greetings-custom-function.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
69
+ "./testdata/workflows/greetings-v08-spec.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
70
+ assert .Empty (t , w .Name )
69
71
assert .IsType (t , & model.OperationState {}, w .States [0 ])
70
72
assert .Equal (t , "custom.greeting" , w .ID )
71
73
assert .NotEmpty (t , w .States [0 ].(* model.OperationState ).Actions )
@@ -77,6 +79,7 @@ func TestFromFile(t *testing.T) {
77
79
assert .Equal (t , "greetingCustomFunction" , w .States [0 ].(* model.OperationState ).Actions [0 ].Name )
78
80
},
79
81
"./testdata/workflows/eventbaseddataandswitch.sw.json" : func (t * testing.T , w * model.Workflow ) {
82
+ assert .Equal (t , "Event Based Switch Transitions" , w .Name )
80
83
assert .Equal (t , "Start" , w .States [0 ].GetName ())
81
84
assert .Equal (t , "CheckVisaStatus" , w .States [1 ].GetName ())
82
85
assert .IsType (t , & model.DataBasedSwitchState {}, w .States [0 ])
@@ -87,6 +90,7 @@ func TestFromFile(t *testing.T) {
87
90
assert .Equal (t , "${ .applicants | .age < 18 }" , operationState .Actions [0 ].Condition )
88
91
},
89
92
"./testdata/workflows/eventbasedgreeting.sw.json" : func (t * testing.T , w * model.Workflow ) {
93
+ assert .Equal (t , "Event Based Greeting Workflow" , w .Name )
90
94
assert .Equal (t , "GreetingEvent" , w .Events [0 ].Name )
91
95
assert .IsType (t , & model.EventState {}, w .States [0 ])
92
96
eventState := w .States [0 ].(* model.EventState )
@@ -96,6 +100,7 @@ func TestFromFile(t *testing.T) {
96
100
assert .Equal (t , true , eventState .Exclusive )
97
101
},
98
102
"./testdata/workflows/eventbasedgreetingexclusive.sw.json" : func (t * testing.T , w * model.Workflow ) {
103
+ assert .Equal (t , "Event Based Greeting Workflow" , w .Name )
99
104
assert .Equal (t , "GreetingEvent" , w .Events [0 ].Name )
100
105
assert .Equal (t , "GreetingEvent2" , w .Events [1 ].Name )
101
106
assert .IsType (t , & model.EventState {}, w .States [0 ])
@@ -107,6 +112,7 @@ func TestFromFile(t *testing.T) {
107
112
assert .Equal (t , true , eventState .Exclusive )
108
113
},
109
114
"./testdata/workflows/eventbasedgreetingnonexclusive.sw.json" : func (t * testing.T , w * model.Workflow ) {
115
+ assert .Equal (t , "Event Based Greeting Workflow" , w .Name )
110
116
assert .Equal (t , "GreetingEvent" , w .Events [0 ].Name )
111
117
assert .Equal (t , "GreetingEvent2" , w .Events [1 ].Name )
112
118
assert .IsType (t , & model.EventState {}, w .States [0 ])
@@ -118,6 +124,7 @@ func TestFromFile(t *testing.T) {
118
124
assert .Equal (t , false , eventState .Exclusive )
119
125
},
120
126
"./testdata/workflows/eventbasedgreeting.sw.p.json" : func (t * testing.T , w * model.Workflow ) {
127
+ assert .Equal (t , "Event Based Greeting Workflow" , w .Name )
121
128
assert .Equal (t , "GreetingEvent" , w .Events [0 ].Name )
122
129
assert .IsType (t , & model.EventState {}, w .States [0 ])
123
130
eventState := w .States [0 ].(* model.EventState )
@@ -126,6 +133,7 @@ func TestFromFile(t *testing.T) {
126
133
assert .Equal (t , "GreetingEvent" , eventState .OnEvents [0 ].EventRefs [0 ])
127
134
},
128
135
"./testdata/workflows/eventbasedswitch.sw.json" : func (t * testing.T , w * model.Workflow ) {
136
+ assert .Equal (t , "Event Based Switch Transitions" , w .Name )
129
137
assert .IsType (t , & model.EventBasedSwitchState {}, w .States [0 ])
130
138
eventState := w .States [0 ].(* model.EventBasedSwitchState )
131
139
assert .NotNil (t , eventState )
@@ -134,6 +142,7 @@ func TestFromFile(t *testing.T) {
134
142
assert .IsType (t , & model.TransitionEventCondition {}, eventState .EventConditions [0 ])
135
143
},
136
144
"./testdata/workflows/applicationrequest.json" : func (t * testing.T , w * model.Workflow ) {
145
+ assert .Equal (t , "Applicant Request Decision Workflow" , w .Name )
137
146
assert .IsType (t , & model.DataBasedSwitchState {}, w .States [0 ])
138
147
eventState := w .States [0 ].(* model.DataBasedSwitchState )
139
148
assert .NotNil (t , eventState )
@@ -155,6 +164,7 @@ func TestFromFile(t *testing.T) {
155
164
assert .Equal (t , "test_token" , bearerProperties )
156
165
},
157
166
"./testdata/workflows/applicationrequest.multiauth.json" : func (t * testing.T , w * model.Workflow ) {
167
+ assert .Equal (t , "Applicant Request Decision Workflow" , w .Name )
158
168
assert .IsType (t , & model.DataBasedSwitchState {}, w .States [0 ])
159
169
eventState := w .States [0 ].(* model.DataBasedSwitchState )
160
170
assert .NotNil (t , eventState )
@@ -179,9 +189,9 @@ func TestFromFile(t *testing.T) {
179
189
basicProperties := w .Auth .Defs [1 ].Properties .(* model.BasicAuthProperties )
180
190
assert .Equal (t , "test_user" , basicProperties .Username )
181
191
assert .Equal (t , "test_pwd" , basicProperties .Password )
182
-
183
192
},
184
193
"./testdata/workflows/applicationrequest.rp.json" : func (t * testing.T , w * model.Workflow ) {
194
+ assert .Equal (t , "Applicant Request Decision Workflow" , w .Name )
185
195
assert .IsType (t , & model.DataBasedSwitchState {}, w .States [0 ])
186
196
eventState := w .States [0 ].(* model.DataBasedSwitchState )
187
197
assert .NotNil (t , eventState )
@@ -198,6 +208,7 @@ func TestFromFile(t *testing.T) {
198
208
assert .Equal (t , "TimeoutRetryStrategy" , w .Retries [0 ].Name )
199
209
},
200
210
"./testdata/workflows/checkinbox.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
211
+ assert .Equal (t , "Check Inbox Workflow" , w .Name )
201
212
assert .IsType (t , & model.OperationState {}, w .States [0 ])
202
213
operationState := w .States [0 ].(* model.OperationState )
203
214
assert .NotNil (t , operationState )
@@ -206,6 +217,7 @@ func TestFromFile(t *testing.T) {
206
217
},
207
218
// validates: https://github.com/serverlessworkflow/specification/pull/175/
208
219
"./testdata/workflows/provisionorders.sw.json" : func (t * testing.T , w * model.Workflow ) {
220
+ assert .Equal (t , "Provision Orders" , w .Name )
209
221
assert .IsType (t , & model.OperationState {}, w .States [0 ])
210
222
operationState := w .States [0 ].(* model.OperationState )
211
223
assert .NotNil (t , operationState )
@@ -217,12 +229,16 @@ func TestFromFile(t *testing.T) {
217
229
assert .Equal (t , "MissingItem" , operationState .OnErrors [1 ].Transition .NextState )
218
230
assert .Equal (t , "Missing order quantity" , operationState .OnErrors [2 ].ErrorRef )
219
231
assert .Equal (t , "MissingQuantity" , operationState .OnErrors [2 ].Transition .NextState )
220
- }, "./testdata/workflows/checkinbox.cron-test.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
232
+ },
233
+ "./testdata/workflows/checkinbox.cron-test.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
234
+ assert .Equal (t , "Check Inbox Workflow" , w .Name )
221
235
assert .Equal (t , "0 0/15 * * * ?" , w .Start .Schedule .Cron .Expression )
222
236
assert .Equal (t , "checkInboxFunction" , w .States [0 ].(* model.OperationState ).Actions [0 ].FunctionRef .RefName )
223
237
assert .Equal (t , "SendTextForHighPriority" , w .States [0 ].GetTransition ().NextState )
224
238
assert .False (t , w .States [1 ].GetEnd ().Terminate )
225
- }, "./testdata/workflows/applicationrequest-issue16.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
239
+ },
240
+ "./testdata/workflows/applicationrequest-issue16.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
241
+ assert .Equal (t , "Applicant Request Decision Workflow" , w .Name )
226
242
assert .IsType (t , & model.DataBasedSwitchState {}, w .States [0 ])
227
243
dataBaseSwitchState := w .States [0 ].(* model.DataBasedSwitchState )
228
244
assert .NotNil (t , dataBaseSwitchState )
@@ -231,6 +247,7 @@ func TestFromFile(t *testing.T) {
231
247
},
232
248
// validates: https://github.com/serverlessworkflow/sdk-go/issues/36
233
249
"./testdata/workflows/patientonboarding.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
250
+ assert .Equal (t , "Patient Onboarding Workflow" , w .Name )
234
251
assert .IsType (t , & model.EventState {}, w .States [0 ])
235
252
eventState := w .States [0 ].(* model.EventState )
236
253
assert .NotNil (t , eventState )
@@ -240,26 +257,32 @@ func TestFromFile(t *testing.T) {
240
257
assert .Equal (t , float32 (1.1 ), w .Retries [0 ].Multiplier .FloatVal )
241
258
},
242
259
"./testdata/workflows/greetings-secret.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
260
+ assert .Equal (t , "Greeting Workflow" , w .Name )
243
261
assert .Len (t , w .Secrets , 1 )
244
262
},
245
263
"./testdata/workflows/greetings-secret-file.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
264
+ assert .Equal (t , "Greeting Workflow" , w .Name )
246
265
assert .Len (t , w .Secrets , 3 )
247
266
},
248
267
"./testdata/workflows/greetings-constants-file.sw.yaml" : func (t * testing.T , w * model.Workflow ) {
268
+ assert .Equal (t , "Greeting Workflow" , w .Name )
249
269
assert .NotEmpty (t , w .Constants )
250
270
assert .NotEmpty (t , w .Constants .Data ["Translations" ])
251
271
},
252
272
"./testdata/workflows/roomreadings.timeouts.sw.json" : func (t * testing.T , w * model.Workflow ) {
273
+ assert .Equal (t , "Room Temp and Humidity Workflow" , w .Name )
253
274
assert .NotNil (t , w .Timeouts )
254
275
assert .Equal (t , "PT1H" , w .Timeouts .WorkflowExecTimeout .Duration )
255
276
assert .Equal (t , "GenerateReport" , w .Timeouts .WorkflowExecTimeout .RunBefore )
256
277
},
257
278
"./testdata/workflows/roomreadings.timeouts.file.sw.json" : func (t * testing.T , w * model.Workflow ) {
279
+ assert .Equal (t , "Room Temp and Humidity Workflow" , w .Name )
258
280
assert .NotNil (t , w .Timeouts )
259
281
assert .Equal (t , "PT1H" , w .Timeouts .WorkflowExecTimeout .Duration )
260
282
assert .Equal (t , "GenerateReport" , w .Timeouts .WorkflowExecTimeout .RunBefore )
261
283
},
262
284
"./testdata/workflows/purchaseorderworkflow.sw.json" : func (t * testing.T , w * model.Workflow ) {
285
+ assert .Equal (t , "Purchase Order Workflow" , w .Name )
263
286
assert .NotNil (t , w .Timeouts )
264
287
assert .Equal (t , "PT30D" , w .Timeouts .WorkflowExecTimeout .Duration )
265
288
assert .Equal (t , "CancelOrder" , w .Timeouts .WorkflowExecTimeout .RunBefore )
0 commit comments