From 9db9f0c3257f33a63c7a22b993ca261068046d8a Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Mon, 9 Sep 2019 16:22:58 +0700 Subject: [PATCH 1/4] add tests for orchestrator --- orchestrator/mocks/EventSDK.go | 27 +++++ orchestrator/mocks/ExecutionSDK.go | 77 ++++++++++++++ orchestrator/mocks/ProcessSDK.go | 35 +++++++ orchestrator/orchestrator.go | 17 +-- orchestrator/orchestrator_test.go | 159 +++++++++++++++++++++++++++++ orchestrator/type.go | 40 ++++++++ scripts/build-mocks.sh | 3 + 7 files changed, 342 insertions(+), 16 deletions(-) create mode 100644 orchestrator/mocks/EventSDK.go create mode 100644 orchestrator/mocks/ExecutionSDK.go create mode 100644 orchestrator/mocks/ProcessSDK.go create mode 100644 orchestrator/orchestrator_test.go create mode 100644 orchestrator/type.go diff --git a/orchestrator/mocks/EventSDK.go b/orchestrator/mocks/EventSDK.go new file mode 100644 index 000000000..888406ca4 --- /dev/null +++ b/orchestrator/mocks/EventSDK.go @@ -0,0 +1,27 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import eventsdk "github.com/mesg-foundation/engine/sdk/event" +import mock "github.com/stretchr/testify/mock" + +// EventSDK is an autogenerated mock type for the EventSDK type +type EventSDK struct { + mock.Mock +} + +// GetStream provides a mock function with given fields: f +func (_m *EventSDK) GetStream(f *eventsdk.Filter) *eventsdk.Listener { + ret := _m.Called(f) + + var r0 *eventsdk.Listener + if rf, ok := ret.Get(0).(func(*eventsdk.Filter) *eventsdk.Listener); ok { + r0 = rf(f) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*eventsdk.Listener) + } + } + + return r0 +} diff --git a/orchestrator/mocks/ExecutionSDK.go b/orchestrator/mocks/ExecutionSDK.go new file mode 100644 index 000000000..4bb665a61 --- /dev/null +++ b/orchestrator/mocks/ExecutionSDK.go @@ -0,0 +1,77 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import execution "github.com/mesg-foundation/engine/execution" +import executionsdk "github.com/mesg-foundation/engine/sdk/execution" +import hash "github.com/mesg-foundation/engine/hash" +import mock "github.com/stretchr/testify/mock" + +import types "github.com/gogo/protobuf/types" + +// ExecutionSDK is an autogenerated mock type for the ExecutionSDK type +type ExecutionSDK struct { + mock.Mock +} + +// Execute provides a mock function with given fields: processHash, instanceHash, eventHash, parentHash, stepID, taskKey, inputData, tags +func (_m *ExecutionSDK) Execute(processHash hash.Hash, instanceHash hash.Hash, eventHash hash.Hash, parentHash hash.Hash, stepID string, taskKey string, inputData *types.Struct, tags []string) (hash.Hash, error) { + ret := _m.Called(processHash, instanceHash, eventHash, parentHash, stepID, taskKey, inputData, tags) + + var r0 hash.Hash + if rf, ok := ret.Get(0).(func(hash.Hash, hash.Hash, hash.Hash, hash.Hash, string, string, *types.Struct, []string) hash.Hash); ok { + r0 = rf(processHash, instanceHash, eventHash, parentHash, stepID, taskKey, inputData, tags) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(hash.Hash) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(hash.Hash, hash.Hash, hash.Hash, hash.Hash, string, string, *types.Struct, []string) error); ok { + r1 = rf(processHash, instanceHash, eventHash, parentHash, stepID, taskKey, inputData, tags) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Get provides a mock function with given fields: _a0 +func (_m *ExecutionSDK) Get(_a0 hash.Hash) (*execution.Execution, error) { + ret := _m.Called(_a0) + + var r0 *execution.Execution + if rf, ok := ret.Get(0).(func(hash.Hash) *execution.Execution); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*execution.Execution) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(hash.Hash) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetStream provides a mock function with given fields: f +func (_m *ExecutionSDK) GetStream(f *executionsdk.Filter) *executionsdk.Listener { + ret := _m.Called(f) + + var r0 *executionsdk.Listener + if rf, ok := ret.Get(0).(func(*executionsdk.Filter) *executionsdk.Listener); ok { + r0 = rf(f) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*executionsdk.Listener) + } + } + + return r0 +} diff --git a/orchestrator/mocks/ProcessSDK.go b/orchestrator/mocks/ProcessSDK.go new file mode 100644 index 000000000..aa15b5a72 --- /dev/null +++ b/orchestrator/mocks/ProcessSDK.go @@ -0,0 +1,35 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +import process "github.com/mesg-foundation/engine/process" + +// ProcessSDK is an autogenerated mock type for the ProcessSDK type +type ProcessSDK struct { + mock.Mock +} + +// List provides a mock function with given fields: +func (_m *ProcessSDK) List() ([]*process.Process, error) { + ret := _m.Called() + + var r0 []*process.Process + if rf, ok := ret.Get(0).(func() []*process.Process); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*process.Process) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/orchestrator/orchestrator.go b/orchestrator/orchestrator.go index f0e0d410f..7096a54e0 100644 --- a/orchestrator/orchestrator.go +++ b/orchestrator/orchestrator.go @@ -8,27 +8,12 @@ import ( "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" "github.com/mesg-foundation/engine/protobuf/types" - eventsdk "github.com/mesg-foundation/engine/sdk/event" executionsdk "github.com/mesg-foundation/engine/sdk/execution" - processesdk "github.com/mesg-foundation/engine/sdk/process" "github.com/sirupsen/logrus" ) -// Orchestrator manages the executions based on the definition of the processes -type Orchestrator struct { - event *eventsdk.Event - eventStream *eventsdk.Listener - - execution *executionsdk.Execution - executionStream *executionsdk.Listener - - process *processesdk.Process - - ErrC chan error -} - // New creates a new Process instance -func New(event *eventsdk.Event, execution *executionsdk.Execution, process *processesdk.Process) *Orchestrator { +func New(event EventSDK, execution ExecutionSDK, process ProcessSDK) *Orchestrator { return &Orchestrator{ event: event, execution: execution, diff --git a/orchestrator/orchestrator_test.go b/orchestrator/orchestrator_test.go new file mode 100644 index 000000000..a89708f95 --- /dev/null +++ b/orchestrator/orchestrator_test.go @@ -0,0 +1,159 @@ +package orchestrator + +import ( + "testing" + + "github.com/mesg-foundation/engine/event" + "github.com/mesg-foundation/engine/execution" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/orchestrator/mocks" + "github.com/mesg-foundation/engine/process" + eventsdk "github.com/mesg-foundation/engine/sdk/event" + executionsdk "github.com/mesg-foundation/engine/sdk/execution" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func TestFilter(t *testing.T) { + o := New(&mocks.EventSDK{}, &mocks.ExecutionSDK{}, &mocks.ProcessSDK{}) + p := process.Process{ + Hash: hash.Int(1), + Nodes: []*process.Process_Node{ + &process.Process_Node{Type: &process.Process_Node_Event_{Event: &process.Process_Node_Event{ + Key: "1", + InstanceHash: hash.Int(1), + EventKey: "1", + }}}, + &process.Process_Node{Type: &process.Process_Node_Task_{Task: &process.Process_Node_Task{ + InstanceHash: hash.Int(2), + Key: "2", + TaskKey: "2", + }}}, + &process.Process_Node{Type: &process.Process_Node_Task_{Task: &process.Process_Node_Task{ + InstanceHash: hash.Int(3), + Key: "3", + TaskKey: "3", + }}}, + }, + Edges: []*process.Process_Edge{ + {Src: "1", Dst: "2"}, + {Src: "2", Dst: "3"}, + }, + } + var tests = []struct { + filter func(wf *process.Process, node *process.Process_Node) (bool, error) + p *process.Process + n *process.Process_Node + res bool + err error + }{ + { + filter: o.eventFilter(&event.Event{InstanceHash: hash.Int(1), Key: "1"}), + n: p.Nodes[0], + res: true, + err: nil, + }, + { + filter: o.eventFilter(&event.Event{InstanceHash: hash.Int(1), Key: "2"}), + n: p.Nodes[0], + res: false, + err: nil, + }, + { + filter: o.eventFilter(&event.Event{InstanceHash: hash.Int(2), Key: "1"}), + n: p.Nodes[0], + res: false, + err: nil, + }, + { + filter: o.eventFilter(&event.Event{InstanceHash: hash.Int(2), Key: "1"}), + n: p.Nodes[1], + res: false, + err: nil, + }, + { + filter: o.resultFilter(&execution.Execution{InstanceHash: hash.Int(1), TaskKey: "1"}), + n: &process.Process_Node{Type: &process.Process_Node_Result_{Result: &process.Process_Node_Result{ + InstanceHash: hash.Int(1), + TaskKey: "1", + }}}, + res: true, + err: nil, + }, + { + filter: o.resultFilter(&execution.Execution{InstanceHash: hash.Int(1), TaskKey: "1"}), + n: &process.Process_Node{Type: &process.Process_Node_Result_{Result: &process.Process_Node_Result{ + InstanceHash: hash.Int(1), + TaskKey: "2", + }}}, + res: false, + err: nil, + }, + { + filter: o.resultFilter(&execution.Execution{InstanceHash: hash.Int(1), TaskKey: "1"}), + n: &process.Process_Node{Type: &process.Process_Node_Result_{Result: &process.Process_Node_Result{ + InstanceHash: hash.Int(2), + TaskKey: "1", + }}}, + res: false, + err: nil, + }, + { + filter: o.resultFilter(&execution.Execution{InstanceHash: hash.Int(1), TaskKey: "1"}), + n: p.Nodes[0], + res: false, + err: nil, + }, + { + filter: o.dependencyFilter(&execution.Execution{InstanceHash: hash.Int(3), TaskKey: "2", ProcessHash: hash.Int(1), StepID: "2"}), + p: &p, + n: p.Nodes[2], + res: true, + err: nil, + }, + { + filter: o.dependencyFilter(&execution.Execution{InstanceHash: hash.Int(3), TaskKey: "2", ProcessHash: hash.Int(2), StepID: "2"}), + p: &p, + n: p.Nodes[2], + res: false, + err: nil, + }, + { + filter: o.dependencyFilter(&execution.Execution{InstanceHash: hash.Int(3), TaskKey: "2", ProcessHash: hash.Int(1), StepID: "1"}), + p: &p, + n: p.Nodes[2], + res: false, + err: nil, + }, + { + filter: o.dependencyFilter(&execution.Execution{InstanceHash: hash.Int(3), TaskKey: "2", ProcessHash: hash.Int(1), StepID: "2"}), + p: &p, + n: p.Nodes[0], + res: false, + err: nil, + }, + } + for _, test := range tests { + ok, err := test.filter(test.p, test.n) + if test.err != nil { + require.Equal(t, test.err, err) + } else { + require.Equal(t, ok, test.res) + } + } +} + +func TestStart(t *testing.T) { + event := &mocks.EventSDK{} + exec := &mocks.ExecutionSDK{} + process := &mocks.ProcessSDK{} + o := New(event, exec, process) + eventListener := &eventsdk.Listener{} + execListener := &executionsdk.Listener{} + event.On("GetStream", mock.Anything).Return(eventListener) + exec.On("GetStream", mock.Anything).Return(execListener) + err := o.Start() + eventListener.Close() + execListener.Close() + require.NoError(t, err) +} diff --git a/orchestrator/type.go b/orchestrator/type.go new file mode 100644 index 000000000..946be5bbf --- /dev/null +++ b/orchestrator/type.go @@ -0,0 +1,40 @@ +package orchestrator + +import ( + "github.com/gogo/protobuf/types" + "github.com/mesg-foundation/engine/execution" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/process" + eventsdk "github.com/mesg-foundation/engine/sdk/event" + executionsdk "github.com/mesg-foundation/engine/sdk/execution" +) + +// ExecutionSDK execution interface needed for the orchestrator +type ExecutionSDK interface { + GetStream(f *executionsdk.Filter) *executionsdk.Listener + Get(hash hash.Hash) (*execution.Execution, error) + Execute(processHash, instanceHash, eventHash, parentHash hash.Hash, stepID string, taskKey string, inputData *types.Struct, tags []string) (executionHash hash.Hash, err error) +} + +// EventSDK event interface needed for the orchestrator +type EventSDK interface { + GetStream(f *eventsdk.Filter) *eventsdk.Listener +} + +// ProcessSDK process interface needed for the orchestrator +type ProcessSDK interface { + List() ([]*process.Process, error) +} + +// Orchestrator manages the executions based on the definition of the processes +type Orchestrator struct { + event EventSDK + eventStream *eventsdk.Listener + + execution ExecutionSDK + executionStream *executionsdk.Listener + + process ProcessSDK + + ErrC chan error +} diff --git a/scripts/build-mocks.sh b/scripts/build-mocks.sh index 839c43f5a..b6aea56d1 100755 --- a/scripts/build-mocks.sh +++ b/scripts/build-mocks.sh @@ -6,3 +6,6 @@ source $(dirname $0)/require-mesg-tools.sh # generate mocks mockery -name Container -dir ./container -output ./container/mocks mockery -name CommonAPIClient -dir ./internal/mocks -output ./utils/docker/mocks +mockery -name ExecutionSDK -dir ./orchestrator -output ./orchestrator/mocks +mockery -name EventSDK -dir ./orchestrator -output ./orchestrator/mocks +mockery -name ProcessSDK -dir ./orchestrator -output ./orchestrator/mocks \ No newline at end of file From c41f77631f8ec299e06518ea3488970420017046 Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Wed, 11 Sep 2019 22:21:51 +0700 Subject: [PATCH 2/4] fix types --- orchestrator/mocks/ExecutionSDK.go | 2 +- orchestrator/type.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/orchestrator/mocks/ExecutionSDK.go b/orchestrator/mocks/ExecutionSDK.go index 4bb665a61..de37e64d9 100644 --- a/orchestrator/mocks/ExecutionSDK.go +++ b/orchestrator/mocks/ExecutionSDK.go @@ -7,7 +7,7 @@ import executionsdk "github.com/mesg-foundation/engine/sdk/execution" import hash "github.com/mesg-foundation/engine/hash" import mock "github.com/stretchr/testify/mock" -import types "github.com/gogo/protobuf/types" +import types "github.com/mesg-foundation/engine/protobuf/types" // ExecutionSDK is an autogenerated mock type for the ExecutionSDK type type ExecutionSDK struct { diff --git a/orchestrator/type.go b/orchestrator/type.go index 946be5bbf..94c6bc788 100644 --- a/orchestrator/type.go +++ b/orchestrator/type.go @@ -1,10 +1,10 @@ package orchestrator import ( - "github.com/gogo/protobuf/types" "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" + "github.com/mesg-foundation/engine/protobuf/types" eventsdk "github.com/mesg-foundation/engine/sdk/event" executionsdk "github.com/mesg-foundation/engine/sdk/execution" ) From 1a4bb596742448293cd8756050bf91d40dbb4bc6 Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Wed, 11 Sep 2019 22:22:17 +0700 Subject: [PATCH 3/4] add tests to process task and resolve inputs --- orchestrator/orchestrator_test.go | 148 +++++++++++++++++++++++++++--- 1 file changed, 134 insertions(+), 14 deletions(-) diff --git a/orchestrator/orchestrator_test.go b/orchestrator/orchestrator_test.go index a89708f95..eef58472f 100644 --- a/orchestrator/orchestrator_test.go +++ b/orchestrator/orchestrator_test.go @@ -1,6 +1,7 @@ package orchestrator import ( + "fmt" "testing" "github.com/mesg-foundation/engine/event" @@ -8,8 +9,7 @@ import ( "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/orchestrator/mocks" "github.com/mesg-foundation/engine/process" - eventsdk "github.com/mesg-foundation/engine/sdk/event" - executionsdk "github.com/mesg-foundation/engine/sdk/execution" + "github.com/mesg-foundation/engine/protobuf/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -143,17 +143,137 @@ func TestFilter(t *testing.T) { } } -func TestStart(t *testing.T) { - event := &mocks.EventSDK{} - exec := &mocks.ExecutionSDK{} - process := &mocks.ProcessSDK{} - o := New(event, exec, process) - eventListener := &eventsdk.Listener{} - execListener := &executionsdk.Listener{} - event.On("GetStream", mock.Anything).Return(eventListener) - exec.On("GetStream", mock.Anything).Return(execListener) - err := o.Start() - eventListener.Close() - execListener.Close() +func TestFindNode(t *testing.T) { + o := New(&mocks.EventSDK{}, &mocks.ExecutionSDK{}, &mocks.ProcessSDK{}) + data := &process.Process{ + Hash: hash.Int(1), + Nodes: []*process.Process_Node{ + &process.Process_Node{ + Type: &process.Process_Node_Event_{ + Event: &process.Process_Node_Event{ + Key: "1", + }, + }, + }, + }, + } + require.Len(t, o.findNodes(data, func(p *process.Process, n *process.Process_Node) (bool, error) { + return true, nil + }), 1) + require.Len(t, o.findNodes(data, func(p *process.Process, n *process.Process_Node) (bool, error) { + return n.GetEvent().Key == "1", nil + }), 1) + require.Len(t, o.findNodes(data, func(p *process.Process, n *process.Process_Node) (bool, error) { + return n.GetEvent().Key == "2", nil + }), 0) +} + +// func TestProcessMap(t *testing.T) { +// e := &mocks.ExecutionSDK{} +// o := New(&mocks.EventSDK{}, e, &mocks.ProcessSDK{}) +// exec := &execution.Execution{ +// ProcessHash: hash.Int(1), +// StepID: "1", +// ParentHash: hash.Int(2), +// Outputs: &types.Struct{ +// Fields: map[string]*types.Value{ +// "xxx": &types.Value{ +// Kind: &types.Value_StringValue{StringValue: "str"}, +// }, +// }, +// }, +// } +// o.processMap(&process.Process_Node_Map{ +// Outputs: []*process.Process_Node_Map_Output{}, +// }, ) +// } + +func TestResolveInput(t *testing.T) { + e := &mocks.ExecutionSDK{} + o := New(&mocks.EventSDK{}, e, &mocks.ProcessSDK{}) + exec := &execution.Execution{ + ProcessHash: hash.Int(2), + StepID: "2", + ParentHash: hash.Int(3), + Outputs: &types.Struct{ + Fields: map[string]*types.Value{ + "xxx": &types.Value{ + Kind: &types.Value_StringValue{StringValue: "str"}, + }, + }, + }, + } + // Different processes + _, err := o.resolveInput(hash.Int(1), exec, "2", "xxx") + require.Error(t, err) + // Different steps, should return the value of the data + val, err := o.resolveInput(hash.Int(2), exec, "2", "xxx") + require.NoError(t, err) + require.Equal(t, val, exec.Outputs.Fields["xxx"]) + // Invalid execution parent hash + e.On("Get", mock.Anything).Once().Return(nil, fmt.Errorf("err")) + _, err = o.resolveInput(hash.Int(2), exec, "-", "xxx") + require.Error(t, err) + // Output from a previous exec + execMock := &execution.Execution{ + StepID: "3", + ProcessHash: hash.Int(2), + Outputs: &types.Struct{ + Fields: map[string]*types.Value{ + "yyy": &types.Value{ + Kind: &types.Value_StringValue{StringValue: "str2"}, + }, + }, + }, + } + e.On("Get", mock.Anything).Once().Return(execMock, nil) + val, err = o.resolveInput(hash.Int(2), exec, "3", "yyy") require.NoError(t, err) + require.Equal(t, val, execMock.Outputs.Fields["yyy"]) } + +func TestProcessTask(t *testing.T) { + e := &mocks.ExecutionSDK{} + e.On("Execute", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Once().Return(nil, nil) + o := New(&mocks.EventSDK{}, e, &mocks.ProcessSDK{}) + err := o.processTask(&process.Process_Node_Task{ + InstanceHash: hash.Int(1), + Key: "-", + TaskKey: "-", + }, &process.Process{ + Hash: hash.Int(2), + }, &execution.Execution{ + Hash: hash.Int(3), + }, nil, &types.Struct{ + Fields: map[string]*types.Value{}, + }) + require.NoError(t, err) + e.On("Execute", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Once().Return(nil, fmt.Errorf("error")) + err = o.processTask(&process.Process_Node_Task{ + InstanceHash: hash.Int(1), + Key: "-", + TaskKey: "-", + }, &process.Process{ + Hash: hash.Int(2), + }, nil, &event.Event{ + Hash: hash.Int(3), + }, &types.Struct{ + Fields: map[string]*types.Value{}, + }) + require.Error(t, err) +} + +// func TestStart(t *testing.T) { +// event := &mocks.EventSDK{} +// exec := &mocks.ExecutionSDK{} +// process := &mocks.ProcessSDK{} +// o := New(event, exec, process) +// eventListener := &eventsdk.Listener{} +// execListener := &executionsdk.Listener{} +// event.On("GetStream", mock.Anything).Return(eventListener) +// exec.On("GetStream", mock.Anything).Return(execListener) +// err := o.Start() +// eventListener.Close() +// execListener.Close() +// require.NoError(t, err) +// } From 3f6fae33ded73ad7580d228fd2bae7c745c0b21f Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Wed, 11 Sep 2019 22:24:06 +0700 Subject: [PATCH 4/4] gofmt --- orchestrator/orchestrator_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/orchestrator/orchestrator_test.go b/orchestrator/orchestrator_test.go index eef58472f..ea2fd3969 100644 --- a/orchestrator/orchestrator_test.go +++ b/orchestrator/orchestrator_test.go @@ -19,17 +19,17 @@ func TestFilter(t *testing.T) { p := process.Process{ Hash: hash.Int(1), Nodes: []*process.Process_Node{ - &process.Process_Node{Type: &process.Process_Node_Event_{Event: &process.Process_Node_Event{ + {Type: &process.Process_Node_Event_{Event: &process.Process_Node_Event{ Key: "1", InstanceHash: hash.Int(1), EventKey: "1", }}}, - &process.Process_Node{Type: &process.Process_Node_Task_{Task: &process.Process_Node_Task{ + {Type: &process.Process_Node_Task_{Task: &process.Process_Node_Task{ InstanceHash: hash.Int(2), Key: "2", TaskKey: "2", }}}, - &process.Process_Node{Type: &process.Process_Node_Task_{Task: &process.Process_Node_Task{ + {Type: &process.Process_Node_Task_{Task: &process.Process_Node_Task{ InstanceHash: hash.Int(3), Key: "3", TaskKey: "3", @@ -148,7 +148,7 @@ func TestFindNode(t *testing.T) { data := &process.Process{ Hash: hash.Int(1), Nodes: []*process.Process_Node{ - &process.Process_Node{ + { Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ Key: "1", @@ -197,7 +197,7 @@ func TestResolveInput(t *testing.T) { ParentHash: hash.Int(3), Outputs: &types.Struct{ Fields: map[string]*types.Value{ - "xxx": &types.Value{ + "xxx": { Kind: &types.Value_StringValue{StringValue: "str"}, }, }, @@ -220,7 +220,7 @@ func TestResolveInput(t *testing.T) { ProcessHash: hash.Int(2), Outputs: &types.Struct{ Fields: map[string]*types.Value{ - "yyy": &types.Value{ + "yyy": { Kind: &types.Value_StringValue{StringValue: "str2"}, }, },