File tree Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,21 @@ type Action struct {
41
41
Condition string `json:"condition,omitempty"`
42
42
}
43
43
44
+ type actionForUnmarshal Action
45
+
46
+ // UnmarshalJSON ...
47
+ func (a * Action ) UnmarshalJSON (data []byte ) error {
48
+ v := actionForUnmarshal {
49
+ ActionDataFilter : ActionDataFilter {UseResults : true },
50
+ }
51
+ err := json .Unmarshal (data , & v )
52
+ if err != nil {
53
+ return err
54
+ }
55
+ * a = Action (v )
56
+ return nil
57
+ }
58
+
44
59
// FunctionRef ...
45
60
type FunctionRef struct {
46
61
// Name of the referenced function
Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ import (
19
19
"path/filepath"
20
20
"testing"
21
21
22
- "github.com/serverlessworkflow/sdk-go/v2/model"
23
22
"github.com/stretchr/testify/assert"
23
+
24
+ "github.com/serverlessworkflow/sdk-go/v2/model"
24
25
)
25
26
26
27
func TestBasicValidation (t * testing.T ) {
@@ -63,6 +64,14 @@ func TestFromFile(t *testing.T) {
63
64
assert .IsType (t , & model.OperationState {}, w .States [0 ])
64
65
assert .Equal (t , "greetingFunction" , w .States [0 ].(* model.OperationState ).Actions [0 ].FunctionRef .RefName )
65
66
},
67
+ }, {
68
+ "./testdata/workflows/actiondata-defaultvalue.yaml" ,
69
+ func (t * testing.T , w * model.Workflow ) {
70
+ assert .Equal (t , "greeting" , w .ID )
71
+ assert .IsType (t , & model.OperationState {}, w .States [0 ].(* model.OperationState ))
72
+ assert .Equal (t , true , w .States [0 ].(* model.OperationState ).Actions [0 ].ActionDataFilter .UseResults )
73
+ assert .Equal (t , "greeting" , w .States [0 ].(* model.OperationState ).Actions [0 ].Name )
74
+ },
66
75
}, {
67
76
"./testdata/workflows/greetings.sw.yaml" ,
68
77
func (t * testing.T , w * model.Workflow ) {
Original file line number Diff line number Diff line change
1
+ # Copyright 2020 The Serverless Workflow Specification Authors
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ id : greeting
16
+ version : ' 1.0'
17
+ name : Greeting Workflow
18
+ description : Greet Someone
19
+ specVersion : " 0.8"
20
+ start :
21
+ stateName : Greet
22
+ functions :
23
+ - name : greetingFunction
24
+ operation : file://myapis/greetingapis.json#greeting
25
+ states :
26
+ - id : greetingId
27
+ name : Greet
28
+ type : operation
29
+ actions :
30
+ - name : greeting
31
+ functionRef :
32
+ refName : greetingFunction
33
+ end :
34
+ terminate : true
You can’t perform that action at this time.
0 commit comments