@@ -73,6 +73,8 @@ func TestFromFile(t *testing.T) {
73
73
assert .Equal (t , "greeting" , w .ID )
74
74
assert .IsType (t , & model.OperationState {}, w .States [0 ].OperationState )
75
75
assert .Equal (t , "greetingFunction" , w .States [0 ].OperationState .Actions [0 ].FunctionRef .RefName )
76
+ assert .NotNil (t , w .States [0 ].End )
77
+ assert .True (t , w .States [0 ].End .Terminate )
76
78
},
77
79
}, {
78
80
"./testdata/workflows/actiondata-defaultvalue.yaml" ,
@@ -82,6 +84,8 @@ func TestFromFile(t *testing.T) {
82
84
assert .NotNil (t , w .States [0 ].OperationState )
83
85
assert .Equal (t , true , w .States [0 ].OperationState .Actions [0 ].ActionDataFilter .UseResults )
84
86
assert .Equal (t , "greeting" , w .States [0 ].OperationState .Actions [0 ].Name )
87
+ assert .NotNil (t , w .States [0 ].End )
88
+ assert .True (t , w .States [0 ].End .Terminate )
85
89
},
86
90
}, {
87
91
"./testdata/workflows/greetings.sw.yaml" ,
@@ -93,6 +97,7 @@ func TestFromFile(t *testing.T) {
93
97
assert .NotEmpty (t , w .States [0 ].OperationState .Actions )
94
98
assert .NotNil (t , w .States [0 ].OperationState .Actions [0 ].FunctionRef )
95
99
assert .Equal (t , "greetingFunction" , w .States [0 ].OperationState .Actions [0 ].FunctionRef .RefName )
100
+ assert .True (t , w .States [0 ].End .Terminate )
96
101
},
97
102
}, {
98
103
"./testdata/workflows/eventbaseddataandswitch.sw.json" ,
@@ -105,11 +110,16 @@ func TestFromFile(t *testing.T) {
105
110
assert .NotNil (t , w .States [1 ])
106
111
assert .NotNil (t , w .States [1 ].SwitchState )
107
112
assert .Equal (t , "PT1H" , w .States [1 ].SwitchState .Timeouts .EventTimeout )
113
+ assert .Nil (t , w .States [1 ].End )
114
+ assert .NotNil (t , w .States [2 ].End )
115
+ assert .True (t , w .States [2 ].End .Terminate )
108
116
},
109
117
}, {
110
118
"./testdata/workflows/conditionbasedstate.yaml" , func (t * testing.T , w * model.Workflow ) {
111
119
operationState := w .States [0 ].OperationState
112
120
assert .Equal (t , "${ .applicants | .age < 18 }" , operationState .Actions [0 ].Condition )
121
+ assert .NotNil (t , w .States [0 ].End )
122
+ assert .True (t , w .States [0 ].End .Terminate )
113
123
},
114
124
}, {
115
125
"./testdata/workflows/eventbasedgreeting.sw.json" , func (t * testing.T , w * model.Workflow ) {
@@ -121,6 +131,8 @@ func TestFromFile(t *testing.T) {
121
131
assert .NotEmpty (t , eventState .OnEvents )
122
132
assert .Equal (t , "GreetingEvent" , eventState .OnEvents [0 ].EventRefs [0 ])
123
133
assert .Equal (t , true , eventState .Exclusive )
134
+ assert .NotNil (t , w .States [0 ].End )
135
+ assert .True (t , w .States [0 ].End .Terminate )
124
136
},
125
137
}, {
126
138
"./testdata/workflows/eventbasedgreetingexclusive.sw.json" , func (t * testing.T , w * model.Workflow ) {
@@ -277,7 +289,9 @@ func TestFromFile(t *testing.T) {
277
289
assert .Equal (t , "0 0/15 * * * ?" , w .Start .Schedule .Cron .Expression )
278
290
assert .Equal (t , "checkInboxFunction" , w .States [0 ].OperationState .Actions [0 ].FunctionRef .RefName )
279
291
assert .Equal (t , "SendTextForHighPriority" , w .States [0 ].Transition .NextState )
280
- assert .False (t , w .States [1 ].End .Terminate )
292
+ assert .Nil (t , w .States [0 ].End )
293
+ assert .NotNil (t , w .States [1 ].End )
294
+ assert .True (t , w .States [1 ].End .Terminate )
281
295
},
282
296
}, {
283
297
"./testdata/workflows/applicationrequest-issue16.sw.yaml" , func (t * testing.T , w * model.Workflow ) {
@@ -553,7 +567,6 @@ func TestFromFile(t *testing.T) {
553
567
file .name , func (t * testing.T ) {
554
568
workflow , err := FromFile (file .name )
555
569
if assert .NoError (t , err , "Test File %s" , file .name ) {
556
-
557
570
assert .NotNil (t , workflow , "Test File %s" , file .name )
558
571
file .f (t , workflow )
559
572
}
@@ -623,17 +636,24 @@ states:
623
636
"data": {
624
637
"result": "Hello World!"
625
638
},
626
- "end": true
627
- }
639
+ "transition": "Next Hello State"
640
+ },
641
+ {
642
+ "name": "Next Hello State",
643
+ "type": "inject",
644
+ "data": {
645
+ "result": "Next Hello World!"
646
+ },
647
+ "end": true
648
+ }
628
649
]
629
650
}
630
651
` ))
631
652
assert .Nil (t , err )
632
653
assert .NotNil (t , workflow .Auth )
633
654
634
- // TODO correctly marshall end: true (fixed by https://github.com/serverlessworkflow/sdk-go/pull/147)
635
655
b , _ := json .Marshal (workflow )
636
- assert .Equal (t , "{\" id\" :\" applicantrequest\" ,\" name\" :\" Applicant Request Decision Workflow\" ,\" description\" :\" Determine if applicant request is valid\" ,\" version\" :\" 1.0\" ,\" start\" :{\" stateName\" :\" CheckApplication\" },\" specVersion\" :\" 0.8\" ,\" expressionLang\" :\" jq\" ,\" auth\" :[{\" name\" :\" testAuth\" ,\" scheme\" :\" bearer\" ,\" properties\" :{\" token\" :\" test_token\" }},{\" name\" :\" testAuth2\" ,\" scheme\" :\" basic\" ,\" properties\" :{\" username\" :\" test_user\" ,\" password\" :\" test_pwd\" }}],\" states\" :[{\" name\" :\" Hello State\" ,\" type\" :\" inject\" ,\" end\" :{},\" data\" :{\" result\" :\" Hello World!\" }}]}" ,
656
+ assert .Equal (t , "{\" id\" :\" applicantrequest\" ,\" name\" :\" Applicant Request Decision Workflow\" ,\" description\" :\" Determine if applicant request is valid\" ,\" version\" :\" 1.0\" ,\" start\" :{\" stateName\" :\" CheckApplication\" },\" specVersion\" :\" 0.8\" ,\" expressionLang\" :\" jq\" ,\" auth\" :[{\" name\" :\" testAuth\" ,\" scheme\" :\" bearer\" ,\" properties\" :{\" token\" :\" test_token\" }},{\" name\" :\" testAuth2\" ,\" scheme\" :\" basic\" ,\" properties\" :{\" username\" :\" test_user\" ,\" password\" :\" test_pwd\" }}],\" states\" :[{\" name\" :\" Hello State\" ,\" type\" :\" inject\" ,\" transition \" :{ \" nextState \" : \" Next Hello State \" }, \" data \" :{ \" result \" : \" Hello World! \" }},{ \" name \" : \" Next Hello State \" , \" type \" : \" inject \" , \" end\" :{\" terminate \" :true },\" data\" :{\" result\" :\" Next Hello World!\" }}]}" ,
637
657
string (b ))
638
658
639
659
})
@@ -664,7 +684,7 @@ states:
664
684
assert .NotNil (t , workflow .Auth )
665
685
666
686
b , _ := json .Marshal (workflow )
667
- assert .Equal (t , "{\" id\" :\" applicantrequest\" ,\" name\" :\" Applicant Request Decision Workflow\" ,\" description\" :\" Determine if applicant request is valid\" ,\" version\" :\" 1.0\" ,\" start\" :{\" stateName\" :\" CheckApplication\" },\" specVersion\" :\" 0.8\" ,\" expressionLang\" :\" jq\" ,\" auth\" :[{\" name\" :\" testAuth\" ,\" scheme\" :\" bearer\" ,\" properties\" :{\" token\" :\" test_token\" }},{\" name\" :\" testAuth2\" ,\" scheme\" :\" basic\" ,\" properties\" :{\" username\" :\" test_user\" ,\" password\" :\" test_pwd\" }}],\" states\" :[{\" name\" :\" Hello State\" ,\" type\" :\" inject\" ,\" end\" :{},\" data\" :{\" result\" :\" Hello World!\" }}]}" ,
687
+ assert .Equal (t , "{\" id\" :\" applicantrequest\" ,\" name\" :\" Applicant Request Decision Workflow\" ,\" description\" :\" Determine if applicant request is valid\" ,\" version\" :\" 1.0\" ,\" start\" :{\" stateName\" :\" CheckApplication\" },\" specVersion\" :\" 0.8\" ,\" expressionLang\" :\" jq\" ,\" auth\" :[{\" name\" :\" testAuth\" ,\" scheme\" :\" bearer\" ,\" properties\" :{\" token\" :\" test_token\" }},{\" name\" :\" testAuth2\" ,\" scheme\" :\" basic\" ,\" properties\" :{\" username\" :\" test_user\" ,\" password\" :\" test_pwd\" }}],\" states\" :[{\" name\" :\" Hello State\" ,\" type\" :\" inject\" ,\" end\" :{\" terminate \" :true },\" data\" :{\" result\" :\" Hello World!\" }}]}" ,
668
688
string (b ))
669
689
670
690
})
0 commit comments