@@ -73,6 +73,8 @@ func TestFromFile(t *testing.T) {
7373 assert .Equal (t , "greeting" , w .ID )
7474 assert .IsType (t , & model.OperationState {}, w .States [0 ].OperationState )
7575 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 )
7678 },
7779 }, {
7880 "./testdata/workflows/actiondata-defaultvalue.yaml" ,
@@ -82,6 +84,8 @@ func TestFromFile(t *testing.T) {
8284 assert .NotNil (t , w .States [0 ].OperationState )
8385 assert .Equal (t , true , w .States [0 ].OperationState .Actions [0 ].ActionDataFilter .UseResults )
8486 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 )
8589 },
8690 }, {
8791 "./testdata/workflows/greetings.sw.yaml" ,
@@ -93,6 +97,7 @@ func TestFromFile(t *testing.T) {
9397 assert .NotEmpty (t , w .States [0 ].OperationState .Actions )
9498 assert .NotNil (t , w .States [0 ].OperationState .Actions [0 ].FunctionRef )
9599 assert .Equal (t , "greetingFunction" , w .States [0 ].OperationState .Actions [0 ].FunctionRef .RefName )
100+ assert .True (t , w .States [0 ].End .Terminate )
96101 },
97102 }, {
98103 "./testdata/workflows/eventbaseddataandswitch.sw.json" ,
@@ -105,11 +110,16 @@ func TestFromFile(t *testing.T) {
105110 assert .NotNil (t , w .States [1 ])
106111 assert .NotNil (t , w .States [1 ].SwitchState )
107112 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 )
108116 },
109117 }, {
110118 "./testdata/workflows/conditionbasedstate.yaml" , func (t * testing.T , w * model.Workflow ) {
111119 operationState := w .States [0 ].OperationState
112120 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 )
113123 },
114124 }, {
115125 "./testdata/workflows/eventbasedgreeting.sw.json" , func (t * testing.T , w * model.Workflow ) {
@@ -121,6 +131,8 @@ func TestFromFile(t *testing.T) {
121131 assert .NotEmpty (t , eventState .OnEvents )
122132 assert .Equal (t , "GreetingEvent" , eventState .OnEvents [0 ].EventRefs [0 ])
123133 assert .Equal (t , true , eventState .Exclusive )
134+ assert .NotNil (t , w .States [0 ].End )
135+ assert .True (t , w .States [0 ].End .Terminate )
124136 },
125137 }, {
126138 "./testdata/workflows/eventbasedgreetingexclusive.sw.json" , func (t * testing.T , w * model.Workflow ) {
@@ -277,7 +289,9 @@ func TestFromFile(t *testing.T) {
277289 assert .Equal (t , "0 0/15 * * * ?" , w .Start .Schedule .Cron .Expression )
278290 assert .Equal (t , "checkInboxFunction" , w .States [0 ].OperationState .Actions [0 ].FunctionRef .RefName )
279291 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 )
281295 },
282296 }, {
283297 "./testdata/workflows/applicationrequest-issue16.sw.yaml" , func (t * testing.T , w * model.Workflow ) {
@@ -553,7 +567,6 @@ func TestFromFile(t *testing.T) {
553567 file .name , func (t * testing.T ) {
554568 workflow , err := FromFile (file .name )
555569 if assert .NoError (t , err , "Test File %s" , file .name ) {
556-
557570 assert .NotNil (t , workflow , "Test File %s" , file .name )
558571 file .f (t , workflow )
559572 }
@@ -623,17 +636,24 @@ states:
623636 "data": {
624637 "result": "Hello World!"
625638 },
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+ }
628649 ]
629650}
630651` ))
631652 assert .Nil (t , err )
632653 assert .NotNil (t , workflow .Auth )
633654
634- // TODO correctly marshall end: true (fixed by https://github.com/serverlessworkflow/sdk-go/pull/147)
635655 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!\" }}]}" ,
637657 string (b ))
638658
639659 })
@@ -664,7 +684,7 @@ states:
664684 assert .NotNil (t , workflow .Auth )
665685
666686 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!\" }}]}" ,
668688 string (b ))
669689
670690 })
0 commit comments