From 9638d1e80bb35fdc263220251ed7d7a1026a0c45 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Tue, 21 Mar 2023 12:37:57 +0100 Subject: [PATCH 1/3] add mocks generation + add Worker and Regsitry mocks --- mocks/.mockery.yaml | 21 +++++++ mocks/Client.go | 78 ++++++++++++++++++++------ mocks/DomainClient.go | 34 ++++++++++-- mocks/HistoryEventIterator.go | 29 ++++++++-- mocks/Registry.go | 68 +++++++++++++++++++++++ mocks/Value.go | 19 ++++++- mocks/Worker.go | 101 ++++++++++++++++++++++++++++++++++ mocks/WorkflowRun.go | 24 +++++++- mocks/mocks.go | 11 ++++ 9 files changed, 354 insertions(+), 31 deletions(-) create mode 100644 mocks/.mockery.yaml create mode 100644 mocks/Registry.go create mode 100644 mocks/Worker.go create mode 100644 mocks/mocks.go diff --git a/mocks/.mockery.yaml b/mocks/.mockery.yaml new file mode 100644 index 000000000..55a4e311b --- /dev/null +++ b/mocks/.mockery.yaml @@ -0,0 +1,21 @@ +output: "." +note: | + Copyright (c) 2017 Uber Technologies, Inc. + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + // + // The above copyright notice and this permission notice shall be included in + // all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + // THE SOFTWARE. diff --git a/mocks/Client.go b/mocks/Client.go index 4463dcac3..c6dacbf1c 100644 --- a/mocks/Client.go +++ b/mocks/Client.go @@ -1,3 +1,5 @@ +// Code generated by mockery v2.23.0. DO NOT EDIT. + // Copyright (c) 2017 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -// Code generated by mockery v2.16.0. DO NOT EDIT. package mocks import ( @@ -89,6 +90,10 @@ func (_m *Client) CountWorkflow(ctx context.Context, request *shared.CountWorkfl ret := _m.Called(ctx, request) var r0 *shared.CountWorkflowExecutionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *shared.CountWorkflowExecutionsRequest) (*shared.CountWorkflowExecutionsResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *shared.CountWorkflowExecutionsRequest) *shared.CountWorkflowExecutionsResponse); ok { r0 = rf(ctx, request) } else { @@ -97,7 +102,6 @@ func (_m *Client) CountWorkflow(ctx context.Context, request *shared.CountWorkfl } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *shared.CountWorkflowExecutionsRequest) error); ok { r1 = rf(ctx, request) } else { @@ -112,6 +116,10 @@ func (_m *Client) DescribeTaskList(ctx context.Context, tasklist string, tasklis ret := _m.Called(ctx, tasklist, tasklistType) var r0 *shared.DescribeTaskListResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, shared.TaskListType) (*shared.DescribeTaskListResponse, error)); ok { + return rf(ctx, tasklist, tasklistType) + } if rf, ok := ret.Get(0).(func(context.Context, string, shared.TaskListType) *shared.DescribeTaskListResponse); ok { r0 = rf(ctx, tasklist, tasklistType) } else { @@ -120,7 +128,6 @@ func (_m *Client) DescribeTaskList(ctx context.Context, tasklist string, tasklis } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, shared.TaskListType) error); ok { r1 = rf(ctx, tasklist, tasklistType) } else { @@ -135,6 +142,10 @@ func (_m *Client) DescribeWorkflowExecution(ctx context.Context, workflowID stri ret := _m.Called(ctx, workflowID, runID) var r0 *shared.DescribeWorkflowExecutionResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*shared.DescribeWorkflowExecutionResponse, error)); ok { + return rf(ctx, workflowID, runID) + } if rf, ok := ret.Get(0).(func(context.Context, string, string) *shared.DescribeWorkflowExecutionResponse); ok { r0 = rf(ctx, workflowID, runID) } else { @@ -143,7 +154,6 @@ func (_m *Client) DescribeWorkflowExecution(ctx context.Context, workflowID stri } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { r1 = rf(ctx, workflowID, runID) } else { @@ -161,6 +171,10 @@ func (_m *Client) ExecuteWorkflow(ctx context.Context, options internal.StartWor ret := _m.Called(_ca...) var r0 internal.WorkflowRun + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, internal.StartWorkflowOptions, interface{}, ...interface{}) (internal.WorkflowRun, error)); ok { + return rf(ctx, options, workflow, args...) + } if rf, ok := ret.Get(0).(func(context.Context, internal.StartWorkflowOptions, interface{}, ...interface{}) internal.WorkflowRun); ok { r0 = rf(ctx, options, workflow, args...) } else { @@ -169,7 +183,6 @@ func (_m *Client) ExecuteWorkflow(ctx context.Context, options internal.StartWor } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, internal.StartWorkflowOptions, interface{}, ...interface{}) error); ok { r1 = rf(ctx, options, workflow, args...) } else { @@ -184,6 +197,10 @@ func (_m *Client) GetSearchAttributes(ctx context.Context) (*shared.GetSearchAtt ret := _m.Called(ctx) var r0 *shared.GetSearchAttributesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*shared.GetSearchAttributesResponse, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) *shared.GetSearchAttributesResponse); ok { r0 = rf(ctx) } else { @@ -192,7 +209,6 @@ func (_m *Client) GetSearchAttributes(ctx context.Context) (*shared.GetSearchAtt } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -239,6 +255,10 @@ func (_m *Client) ListArchivedWorkflow(ctx context.Context, request *shared.List ret := _m.Called(ctx, request) var r0 *shared.ListArchivedWorkflowExecutionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *shared.ListArchivedWorkflowExecutionsRequest) (*shared.ListArchivedWorkflowExecutionsResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *shared.ListArchivedWorkflowExecutionsRequest) *shared.ListArchivedWorkflowExecutionsResponse); ok { r0 = rf(ctx, request) } else { @@ -247,7 +267,6 @@ func (_m *Client) ListArchivedWorkflow(ctx context.Context, request *shared.List } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *shared.ListArchivedWorkflowExecutionsRequest) error); ok { r1 = rf(ctx, request) } else { @@ -262,6 +281,10 @@ func (_m *Client) ListClosedWorkflow(ctx context.Context, request *shared.ListCl ret := _m.Called(ctx, request) var r0 *shared.ListClosedWorkflowExecutionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *shared.ListClosedWorkflowExecutionsRequest) (*shared.ListClosedWorkflowExecutionsResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *shared.ListClosedWorkflowExecutionsRequest) *shared.ListClosedWorkflowExecutionsResponse); ok { r0 = rf(ctx, request) } else { @@ -270,7 +293,6 @@ func (_m *Client) ListClosedWorkflow(ctx context.Context, request *shared.ListCl } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *shared.ListClosedWorkflowExecutionsRequest) error); ok { r1 = rf(ctx, request) } else { @@ -285,6 +307,10 @@ func (_m *Client) ListOpenWorkflow(ctx context.Context, request *shared.ListOpen ret := _m.Called(ctx, request) var r0 *shared.ListOpenWorkflowExecutionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *shared.ListOpenWorkflowExecutionsRequest) (*shared.ListOpenWorkflowExecutionsResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *shared.ListOpenWorkflowExecutionsRequest) *shared.ListOpenWorkflowExecutionsResponse); ok { r0 = rf(ctx, request) } else { @@ -293,7 +319,6 @@ func (_m *Client) ListOpenWorkflow(ctx context.Context, request *shared.ListOpen } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *shared.ListOpenWorkflowExecutionsRequest) error); ok { r1 = rf(ctx, request) } else { @@ -308,6 +333,10 @@ func (_m *Client) ListWorkflow(ctx context.Context, request *shared.ListWorkflow ret := _m.Called(ctx, request) var r0 *shared.ListWorkflowExecutionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *shared.ListWorkflowExecutionsRequest) (*shared.ListWorkflowExecutionsResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *shared.ListWorkflowExecutionsRequest) *shared.ListWorkflowExecutionsResponse); ok { r0 = rf(ctx, request) } else { @@ -316,7 +345,6 @@ func (_m *Client) ListWorkflow(ctx context.Context, request *shared.ListWorkflow } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *shared.ListWorkflowExecutionsRequest) error); ok { r1 = rf(ctx, request) } else { @@ -334,6 +362,10 @@ func (_m *Client) QueryWorkflow(ctx context.Context, workflowID string, runID st ret := _m.Called(_ca...) var r0 internal.Value + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, ...interface{}) (internal.Value, error)); ok { + return rf(ctx, workflowID, runID, queryType, args...) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, string, ...interface{}) internal.Value); ok { r0 = rf(ctx, workflowID, runID, queryType, args...) } else { @@ -342,7 +374,6 @@ func (_m *Client) QueryWorkflow(ctx context.Context, workflowID string, runID st } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, string, string, ...interface{}) error); ok { r1 = rf(ctx, workflowID, runID, queryType, args...) } else { @@ -357,6 +388,10 @@ func (_m *Client) QueryWorkflowWithOptions(ctx context.Context, request *interna ret := _m.Called(ctx, request) var r0 *internal.QueryWorkflowWithOptionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *internal.QueryWorkflowWithOptionsRequest) (*internal.QueryWorkflowWithOptionsResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *internal.QueryWorkflowWithOptionsRequest) *internal.QueryWorkflowWithOptionsResponse); ok { r0 = rf(ctx, request) } else { @@ -365,7 +400,6 @@ func (_m *Client) QueryWorkflowWithOptions(ctx context.Context, request *interna } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *internal.QueryWorkflowWithOptionsRequest) error); ok { r1 = rf(ctx, request) } else { @@ -428,6 +462,10 @@ func (_m *Client) ResetWorkflow(ctx context.Context, request *shared.ResetWorkfl ret := _m.Called(ctx, request) var r0 *shared.ResetWorkflowExecutionResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *shared.ResetWorkflowExecutionRequest) (*shared.ResetWorkflowExecutionResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *shared.ResetWorkflowExecutionRequest) *shared.ResetWorkflowExecutionResponse); ok { r0 = rf(ctx, request) } else { @@ -436,7 +474,6 @@ func (_m *Client) ResetWorkflow(ctx context.Context, request *shared.ResetWorkfl } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *shared.ResetWorkflowExecutionRequest) error); ok { r1 = rf(ctx, request) } else { @@ -451,6 +488,10 @@ func (_m *Client) ScanWorkflow(ctx context.Context, request *shared.ListWorkflow ret := _m.Called(ctx, request) var r0 *shared.ListWorkflowExecutionsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *shared.ListWorkflowExecutionsRequest) (*shared.ListWorkflowExecutionsResponse, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *shared.ListWorkflowExecutionsRequest) *shared.ListWorkflowExecutionsResponse); ok { r0 = rf(ctx, request) } else { @@ -459,7 +500,6 @@ func (_m *Client) ScanWorkflow(ctx context.Context, request *shared.ListWorkflow } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *shared.ListWorkflowExecutionsRequest) error); ok { r1 = rf(ctx, request) } else { @@ -477,6 +517,10 @@ func (_m *Client) SignalWithStartWorkflow(ctx context.Context, workflowID string ret := _m.Called(_ca...) var r0 *internal.WorkflowExecution + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, interface{}, internal.StartWorkflowOptions, interface{}, ...interface{}) (*internal.WorkflowExecution, error)); ok { + return rf(ctx, workflowID, signalName, signalArg, options, workflowFunc, workflowArgs...) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, interface{}, internal.StartWorkflowOptions, interface{}, ...interface{}) *internal.WorkflowExecution); ok { r0 = rf(ctx, workflowID, signalName, signalArg, options, workflowFunc, workflowArgs...) } else { @@ -485,7 +529,6 @@ func (_m *Client) SignalWithStartWorkflow(ctx context.Context, workflowID string } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, string, interface{}, internal.StartWorkflowOptions, interface{}, ...interface{}) error); ok { r1 = rf(ctx, workflowID, signalName, signalArg, options, workflowFunc, workflowArgs...) } else { @@ -517,6 +560,10 @@ func (_m *Client) StartWorkflow(ctx context.Context, options internal.StartWorkf ret := _m.Called(_ca...) var r0 *internal.WorkflowExecution + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, internal.StartWorkflowOptions, interface{}, ...interface{}) (*internal.WorkflowExecution, error)); ok { + return rf(ctx, options, workflowFunc, args...) + } if rf, ok := ret.Get(0).(func(context.Context, internal.StartWorkflowOptions, interface{}, ...interface{}) *internal.WorkflowExecution); ok { r0 = rf(ctx, options, workflowFunc, args...) } else { @@ -525,7 +572,6 @@ func (_m *Client) StartWorkflow(ctx context.Context, options internal.StartWorkf } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, internal.StartWorkflowOptions, interface{}, ...interface{}) error); ok { r1 = rf(ctx, options, workflowFunc, args...) } else { diff --git a/mocks/DomainClient.go b/mocks/DomainClient.go index b993594fa..e54e9d880 100644 --- a/mocks/DomainClient.go +++ b/mocks/DomainClient.go @@ -1,3 +1,5 @@ +// Code generated by mockery v2.23.0. DO NOT EDIT. + // Copyright (c) 2017 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,12 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -// Code generated by mockery v1.0.0 package mocks -import context "context" -import mock "github.com/stretchr/testify/mock" -import shared "go.uber.org/cadence/.gen/go/shared" +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + shared "go.uber.org/cadence/.gen/go/shared" +) // DomainClient is an autogenerated mock type for the DomainClient type type DomainClient struct { @@ -35,6 +39,10 @@ func (_m *DomainClient) Describe(ctx context.Context, name string) (*shared.Desc ret := _m.Called(ctx, name) var r0 *shared.DescribeDomainResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*shared.DescribeDomainResponse, error)); ok { + return rf(ctx, name) + } if rf, ok := ret.Get(0).(func(context.Context, string) *shared.DescribeDomainResponse); ok { r0 = rf(ctx, name) } else { @@ -43,7 +51,6 @@ func (_m *DomainClient) Describe(ctx context.Context, name string) (*shared.Desc } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { r1 = rf(ctx, name) } else { @@ -69,7 +76,7 @@ func (_m *DomainClient) Register(ctx context.Context, request *shared.RegisterDo // Update provides a mock function with given fields: ctx, request func (_m *DomainClient) Update(ctx context.Context, request *shared.UpdateDomainRequest) error { - ret := _m.Called(ctx) + ret := _m.Called(ctx, request) var r0 error if rf, ok := ret.Get(0).(func(context.Context, *shared.UpdateDomainRequest) error); ok { @@ -80,3 +87,18 @@ func (_m *DomainClient) Update(ctx context.Context, request *shared.UpdateDomain return r0 } + +type mockConstructorTestingTNewDomainClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewDomainClient creates a new instance of DomainClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewDomainClient(t mockConstructorTestingTNewDomainClient) *DomainClient { + mock := &DomainClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/HistoryEventIterator.go b/mocks/HistoryEventIterator.go index e9af182a9..73698710e 100644 --- a/mocks/HistoryEventIterator.go +++ b/mocks/HistoryEventIterator.go @@ -1,3 +1,5 @@ +// Code generated by mockery v2.23.0. DO NOT EDIT. + // Copyright (c) 2017 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,11 +20,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import mock "github.com/stretchr/testify/mock" -import shared "go.uber.org/cadence/.gen/go/shared" +import ( + mock "github.com/stretchr/testify/mock" + shared "go.uber.org/cadence/.gen/go/shared" +) // HistoryEventIterator is an autogenerated mock type for the HistoryEventIterator type type HistoryEventIterator struct { @@ -48,6 +51,10 @@ func (_m *HistoryEventIterator) Next() (*shared.HistoryEvent, error) { ret := _m.Called() var r0 *shared.HistoryEvent + var r1 error + if rf, ok := ret.Get(0).(func() (*shared.HistoryEvent, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() *shared.HistoryEvent); ok { r0 = rf() } else { @@ -56,7 +63,6 @@ func (_m *HistoryEventIterator) Next() (*shared.HistoryEvent, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -65,3 +71,18 @@ func (_m *HistoryEventIterator) Next() (*shared.HistoryEvent, error) { return r0, r1 } + +type mockConstructorTestingTNewHistoryEventIterator interface { + mock.TestingT + Cleanup(func()) +} + +// NewHistoryEventIterator creates a new instance of HistoryEventIterator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewHistoryEventIterator(t mockConstructorTestingTNewHistoryEventIterator) *HistoryEventIterator { + mock := &HistoryEventIterator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/Registry.go b/mocks/Registry.go new file mode 100644 index 000000000..ae70f8921 --- /dev/null +++ b/mocks/Registry.go @@ -0,0 +1,68 @@ +// Code generated by mockery v2.23.0. DO NOT EDIT. + +// Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + internal "go.uber.org/cadence/internal" +) + +// Registry is an autogenerated mock type for the Registry type +type Registry struct { + mock.Mock +} + +// RegisterActivity provides a mock function with given fields: a +func (_m *Registry) RegisterActivity(a interface{}) { + _m.Called(a) +} + +// RegisterActivityWithOptions provides a mock function with given fields: a, options +func (_m *Registry) RegisterActivityWithOptions(a interface{}, options internal.RegisterActivityOptions) { + _m.Called(a, options) +} + +// RegisterWorkflow provides a mock function with given fields: w +func (_m *Registry) RegisterWorkflow(w interface{}) { + _m.Called(w) +} + +// RegisterWorkflowWithOptions provides a mock function with given fields: w, options +func (_m *Registry) RegisterWorkflowWithOptions(w interface{}, options internal.RegisterWorkflowOptions) { + _m.Called(w, options) +} + +type mockConstructorTestingTNewRegistry interface { + mock.TestingT + Cleanup(func()) +} + +// NewRegistry creates a new instance of Registry. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewRegistry(t mockConstructorTestingTNewRegistry) *Registry { + mock := &Registry{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/Value.go b/mocks/Value.go index 0e3a75672..032c1df97 100644 --- a/mocks/Value.go +++ b/mocks/Value.go @@ -1,3 +1,5 @@ +// Code generated by mockery v2.23.0. DO NOT EDIT. + // Copyright (c) 2017 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,8 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -// Code generated by mockery v1.0.0. DO NOT EDIT. - package mocks import mock "github.com/stretchr/testify/mock" @@ -56,3 +56,18 @@ func (_m *Value) HasValue() bool { return r0 } + +type mockConstructorTestingTNewValue interface { + mock.TestingT + Cleanup(func()) +} + +// NewValue creates a new instance of Value. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewValue(t mockConstructorTestingTNewValue) *Value { + mock := &Value{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/Worker.go b/mocks/Worker.go new file mode 100644 index 000000000..09362672f --- /dev/null +++ b/mocks/Worker.go @@ -0,0 +1,101 @@ +// Code generated by mockery v2.23.0. DO NOT EDIT. + +// Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + internal "go.uber.org/cadence/internal" +) + +// Worker is an autogenerated mock type for the Worker type +type Worker struct { + mock.Mock +} + +// RegisterActivity provides a mock function with given fields: a +func (_m *Worker) RegisterActivity(a interface{}) { + _m.Called(a) +} + +// RegisterActivityWithOptions provides a mock function with given fields: a, options +func (_m *Worker) RegisterActivityWithOptions(a interface{}, options internal.RegisterActivityOptions) { + _m.Called(a, options) +} + +// RegisterWorkflow provides a mock function with given fields: w +func (_m *Worker) RegisterWorkflow(w interface{}) { + _m.Called(w) +} + +// RegisterWorkflowWithOptions provides a mock function with given fields: w, options +func (_m *Worker) RegisterWorkflowWithOptions(w interface{}, options internal.RegisterWorkflowOptions) { + _m.Called(w, options) +} + +// Run provides a mock function with given fields: +func (_m *Worker) Run() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Start provides a mock function with given fields: +func (_m *Worker) Start() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Stop provides a mock function with given fields: +func (_m *Worker) Stop() { + _m.Called() +} + +type mockConstructorTestingTNewWorker interface { + mock.TestingT + Cleanup(func()) +} + +// NewWorker creates a new instance of Worker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewWorker(t mockConstructorTestingTNewWorker) *Worker { + mock := &Worker{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/WorkflowRun.go b/mocks/WorkflowRun.go index 8e7b1d038..550af808b 100644 --- a/mocks/WorkflowRun.go +++ b/mocks/WorkflowRun.go @@ -1,3 +1,5 @@ +// Code generated by mockery v2.23.0. DO NOT EDIT. + // Copyright (c) 2017 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,12 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import context "context" +import ( + context "context" -import mock "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" +) // WorkflowRun is an autogenerated mock type for the WorkflowRun type type WorkflowRun struct { @@ -71,3 +74,18 @@ func (_m *WorkflowRun) GetRunID() string { return r0 } + +type mockConstructorTestingTNewWorkflowRun interface { + mock.TestingT + Cleanup(func()) +} + +// NewWorkflowRun creates a new instance of WorkflowRun. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewWorkflowRun(t mockConstructorTestingTNewWorkflowRun) *WorkflowRun { + mock := &WorkflowRun{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/mocks.go b/mocks/mocks.go new file mode 100644 index 000000000..093a2de46 --- /dev/null +++ b/mocks/mocks.go @@ -0,0 +1,11 @@ +package mocks + +// Type ''go generate'' to rebuild needed mock. +//go:generate go install -v github.com/vektra/mockery/v2@v2.23.0 +//go:generate mockery --dir=../client --name=Client +//go:generate mockery --dir=../client --name=DomainClient +//go:generate mockery --dir=../internal --name=HistoryEventIterator +//go:generate mockery --dir=../internal --name=Value +//go:generate mockery --dir=../internal --name=WorkflowRun +//go:generate mockery --dir=../worker --name=Registry +//go:generate mockery --dir=../worker --name=Worker From 52b3d6ac504364402ef3f4302f8a506a24a93a8a Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Tue, 21 Mar 2023 12:44:36 +0100 Subject: [PATCH 2/3] complete verify and move generation to existing file --- mocks/mocks.go | 11 ----------- mocks/verify.go | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) delete mode 100644 mocks/mocks.go diff --git a/mocks/mocks.go b/mocks/mocks.go deleted file mode 100644 index 093a2de46..000000000 --- a/mocks/mocks.go +++ /dev/null @@ -1,11 +0,0 @@ -package mocks - -// Type ''go generate'' to rebuild needed mock. -//go:generate go install -v github.com/vektra/mockery/v2@v2.23.0 -//go:generate mockery --dir=../client --name=Client -//go:generate mockery --dir=../client --name=DomainClient -//go:generate mockery --dir=../internal --name=HistoryEventIterator -//go:generate mockery --dir=../internal --name=Value -//go:generate mockery --dir=../internal --name=WorkflowRun -//go:generate mockery --dir=../worker --name=Registry -//go:generate mockery --dir=../worker --name=Worker diff --git a/mocks/verify.go b/mocks/verify.go index f7f148737..6067fc3f9 100644 --- a/mocks/verify.go +++ b/mocks/verify.go @@ -22,8 +22,25 @@ package mocks import ( "go.uber.org/cadence/client" + internal "go.uber.org/cadence/internal" + "go.uber.org/cadence/worker" ) +// Type ''go generate'' to rebuild needed mock. +//go:generate go install -v github.com/vektra/mockery/v2@v2.23.0 +//go:generate mockery --dir=../client --name=Client +//go:generate mockery --dir=../client --name=DomainClient +//go:generate mockery --dir=../internal --name=HistoryEventIterator +//go:generate mockery --dir=../internal --name=Value +//go:generate mockery --dir=../internal --name=WorkflowRun +//go:generate mockery --dir=../worker --name=Registry +//go:generate mockery --dir=../worker --name=Worker + // make sure mocks are in sync with interfaces var _ client.Client = (*Client)(nil) var _ client.DomainClient = (*DomainClient)(nil) +var _ internal.HistoryEventIterator = (*HistoryEventIterator)(nil) +var _ internal.Value = (*Value)(nil) +var _ internal.WorkflowRun = (*WorkflowRun)(nil) +var _ worker.Registry = (*Registry)(nil) +var _ worker.Worker = (*Worker)(nil) From 5bfe4c48ccbd7553c20221d8c1ba8e5758c22503 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Tue, 21 Mar 2023 12:50:20 +0100 Subject: [PATCH 3/3] use .build/go1.20.2_linux_amd64/bin/copyright for header --- mocks/.mockery.yaml | 22 +--------------------- mocks/Client.go | 6 +++--- mocks/DomainClient.go | 6 +++--- mocks/HistoryEventIterator.go | 6 +++--- mocks/Registry.go | 6 +++--- mocks/Value.go | 6 +++--- mocks/Worker.go | 6 +++--- mocks/WorkflowRun.go | 6 +++--- 8 files changed, 22 insertions(+), 42 deletions(-) diff --git a/mocks/.mockery.yaml b/mocks/.mockery.yaml index 55a4e311b..a1cd88937 100644 --- a/mocks/.mockery.yaml +++ b/mocks/.mockery.yaml @@ -1,21 +1 @@ -output: "." -note: | - Copyright (c) 2017 Uber Technologies, Inc. - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files (the "Software"), to deal - // in the Software without restriction, including without limitation the rights - // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - // copies of the Software, and to permit persons to whom the Software is - // furnished to do so, subject to the following conditions: - // - // The above copyright notice and this permission notice shall be included in - // all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - // THE SOFTWARE. +output: "." \ No newline at end of file diff --git a/mocks/Client.go b/mocks/Client.go index c6dacbf1c..962bf487a 100644 --- a/mocks/Client.go +++ b/mocks/Client.go @@ -1,6 +1,4 @@ -// Code generated by mockery v2.23.0. DO NOT EDIT. - -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) 2017-2021 Uber Technologies Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// Code generated by mockery v2.23.0. DO NOT EDIT. + package mocks import ( diff --git a/mocks/DomainClient.go b/mocks/DomainClient.go index e54e9d880..dd790024a 100644 --- a/mocks/DomainClient.go +++ b/mocks/DomainClient.go @@ -1,6 +1,4 @@ -// Code generated by mockery v2.23.0. DO NOT EDIT. - -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) 2017-2021 Uber Technologies Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// Code generated by mockery v2.23.0. DO NOT EDIT. + package mocks import ( diff --git a/mocks/HistoryEventIterator.go b/mocks/HistoryEventIterator.go index 73698710e..21579881c 100644 --- a/mocks/HistoryEventIterator.go +++ b/mocks/HistoryEventIterator.go @@ -1,6 +1,4 @@ -// Code generated by mockery v2.23.0. DO NOT EDIT. - -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) 2017-2021 Uber Technologies Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// Code generated by mockery v2.23.0. DO NOT EDIT. + package mocks import ( diff --git a/mocks/Registry.go b/mocks/Registry.go index ae70f8921..7ae011d9b 100644 --- a/mocks/Registry.go +++ b/mocks/Registry.go @@ -1,6 +1,4 @@ -// Code generated by mockery v2.23.0. DO NOT EDIT. - -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) 2017-2021 Uber Technologies Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// Code generated by mockery v2.23.0. DO NOT EDIT. + package mocks import ( diff --git a/mocks/Value.go b/mocks/Value.go index 032c1df97..c3a4aedb7 100644 --- a/mocks/Value.go +++ b/mocks/Value.go @@ -1,6 +1,4 @@ -// Code generated by mockery v2.23.0. DO NOT EDIT. - -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) 2017-2021 Uber Technologies Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// Code generated by mockery v2.23.0. DO NOT EDIT. + package mocks import mock "github.com/stretchr/testify/mock" diff --git a/mocks/Worker.go b/mocks/Worker.go index 09362672f..808653fbf 100644 --- a/mocks/Worker.go +++ b/mocks/Worker.go @@ -1,6 +1,4 @@ -// Code generated by mockery v2.23.0. DO NOT EDIT. - -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) 2017-2021 Uber Technologies Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// Code generated by mockery v2.23.0. DO NOT EDIT. + package mocks import ( diff --git a/mocks/WorkflowRun.go b/mocks/WorkflowRun.go index 550af808b..f5f6b7743 100644 --- a/mocks/WorkflowRun.go +++ b/mocks/WorkflowRun.go @@ -1,6 +1,4 @@ -// Code generated by mockery v2.23.0. DO NOT EDIT. - -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) 2017-2021 Uber Technologies Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// Code generated by mockery v2.23.0. DO NOT EDIT. + package mocks import (