diff --git a/mocks/ScheduleClient.go b/mocks/ScheduleClient.go new file mode 100644 index 000000000..0eb78e67f --- /dev/null +++ b/mocks/ScheduleClient.go @@ -0,0 +1,121 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 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. + +// Code generated by mockery v2.30.16. DO NOT EDIT. +// Modified manually to add new method. +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + client "go.temporal.io/sdk/client" +) + +// ScheduleClient is an autogenerated mock type for the ScheduleClient type +type ScheduleClient struct { + mock.Mock +} + +// Create provides a mock function with given fields: ctx, options +func (_m *ScheduleClient) Create(ctx context.Context, options client.ScheduleOptions) (client.ScheduleHandle, error) { + ret := _m.Called(ctx, options) + + var r0 client.ScheduleHandle + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleOptions) (client.ScheduleHandle, error)); ok { + return rf(ctx, options) + } + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleOptions) client.ScheduleHandle); ok { + r0 = rf(ctx, options) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(client.ScheduleHandle) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, client.ScheduleOptions) error); ok { + r1 = rf(ctx, options) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetHandle provides a mock function with given fields: ctx, scheduleID +func (_m *ScheduleClient) GetHandle(ctx context.Context, scheduleID string) client.ScheduleHandle { + ret := _m.Called(ctx, scheduleID) + + var r0 client.ScheduleHandle + if rf, ok := ret.Get(0).(func(context.Context, string) client.ScheduleHandle); ok { + r0 = rf(ctx, scheduleID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(client.ScheduleHandle) + } + } + + return r0 +} + +// List provides a mock function with given fields: ctx, options +func (_m *ScheduleClient) List(ctx context.Context, options client.ScheduleListOptions) (client.ScheduleListIterator, error) { + ret := _m.Called(ctx, options) + + var r0 client.ScheduleListIterator + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleListOptions) (client.ScheduleListIterator, error)); ok { + return rf(ctx, options) + } + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleListOptions) client.ScheduleListIterator); ok { + r0 = rf(ctx, options) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(client.ScheduleListIterator) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, client.ScheduleListOptions) error); ok { + r1 = rf(ctx, options) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewScheduleClient creates a new instance of ScheduleClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewScheduleClient(t interface { + mock.TestingT + Cleanup(func()) +}) *ScheduleClient { + mock := &ScheduleClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/ScheduleHandle.go b/mocks/ScheduleHandle.go new file mode 100644 index 000000000..842aaae0b --- /dev/null +++ b/mocks/ScheduleHandle.go @@ -0,0 +1,177 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 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. + +// Code generated by mockery v2.30.16. DO NOT EDIT. +// Modified manually to add new method. +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + client "go.temporal.io/sdk/client" +) + +// ScheduleHandle is an autogenerated mock type for the ScheduleHandle type +type ScheduleHandle struct { + mock.Mock +} + +// Backfill provides a mock function with given fields: ctx, options +func (_m *ScheduleHandle) Backfill(ctx context.Context, options client.ScheduleBackfillOptions) error { + ret := _m.Called(ctx, options) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleBackfillOptions) error); ok { + r0 = rf(ctx, options) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Delete provides a mock function with given fields: ctx +func (_m *ScheduleHandle) Delete(ctx context.Context) error { + ret := _m.Called(ctx) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Describe provides a mock function with given fields: ctx +func (_m *ScheduleHandle) Describe(ctx context.Context) (*client.ScheduleDescription, error) { + ret := _m.Called(ctx) + + var r0 *client.ScheduleDescription + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*client.ScheduleDescription, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *client.ScheduleDescription); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.ScheduleDescription) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetID provides a mock function with given fields: +func (_m *ScheduleHandle) GetID() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Pause provides a mock function with given fields: ctx, options +func (_m *ScheduleHandle) Pause(ctx context.Context, options client.SchedulePauseOptions) error { + ret := _m.Called(ctx, options) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, client.SchedulePauseOptions) error); ok { + r0 = rf(ctx, options) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Trigger provides a mock function with given fields: ctx, options +func (_m *ScheduleHandle) Trigger(ctx context.Context, options client.ScheduleTriggerOptions) error { + ret := _m.Called(ctx, options) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleTriggerOptions) error); ok { + r0 = rf(ctx, options) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Unpause provides a mock function with given fields: ctx, options +func (_m *ScheduleHandle) Unpause(ctx context.Context, options client.ScheduleUnpauseOptions) error { + ret := _m.Called(ctx, options) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleUnpauseOptions) error); ok { + r0 = rf(ctx, options) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Update provides a mock function with given fields: ctx, options +func (_m *ScheduleHandle) Update(ctx context.Context, options client.ScheduleUpdateOptions) error { + ret := _m.Called(ctx, options) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, client.ScheduleUpdateOptions) error); ok { + r0 = rf(ctx, options) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewScheduleHandle creates a new instance of ScheduleHandle. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewScheduleHandle(t interface { + mock.TestingT + Cleanup(func()) +}) *ScheduleHandle { + mock := &ScheduleHandle{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/ScheduleListIterator.go b/mocks/ScheduleListIterator.go new file mode 100644 index 000000000..2ebf1e4a6 --- /dev/null +++ b/mocks/ScheduleListIterator.go @@ -0,0 +1,91 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 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. + +// Code generated by mockery v2.30.16. DO NOT EDIT. +// Modified manually to add new method. +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + client "go.temporal.io/sdk/client" +) + +// ScheduleListIterator is an autogenerated mock type for the ScheduleListIterator type +type ScheduleListIterator struct { + mock.Mock +} + +// HasNext provides a mock function with given fields: +func (_m *ScheduleListIterator) HasNext() bool { + ret := _m.Called() + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// Next provides a mock function with given fields: +func (_m *ScheduleListIterator) Next() (*client.ScheduleListEntry, error) { + ret := _m.Called() + + var r0 *client.ScheduleListEntry + var r1 error + if rf, ok := ret.Get(0).(func() (*client.ScheduleListEntry, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *client.ScheduleListEntry); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*client.ScheduleListEntry) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewScheduleListIterator creates a new instance of ScheduleListIterator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewScheduleListIterator(t interface { + mock.TestingT + Cleanup(func()) +}) *ScheduleListIterator { + mock := &ScheduleListIterator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/WorkflowUpdateHandle.go b/mocks/WorkflowUpdateHandle.go new file mode 100644 index 000000000..d2d35d266 --- /dev/null +++ b/mocks/WorkflowUpdateHandle.go @@ -0,0 +1,108 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 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. + +// Code generated by mockery v2.30.16. DO NOT EDIT. +// Modified manually to add new method. +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// WorkflowUpdateHandle is an autogenerated mock type for the WorkflowUpdateHandle type +type WorkflowUpdateHandle struct { + mock.Mock +} + +// Get provides a mock function with given fields: ctx, valuePtr +func (_m *WorkflowUpdateHandle) Get(ctx context.Context, valuePtr interface{}) error { + ret := _m.Called(ctx, valuePtr) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { + r0 = rf(ctx, valuePtr) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// RunID provides a mock function with given fields: +func (_m *WorkflowUpdateHandle) RunID() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// UpdateID provides a mock function with given fields: +func (_m *WorkflowUpdateHandle) UpdateID() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// WorkflowID provides a mock function with given fields: +func (_m *WorkflowUpdateHandle) WorkflowID() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// NewWorkflowUpdateHandle creates a new instance of WorkflowUpdateHandle. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewWorkflowUpdateHandle(t interface { + mock.TestingT + Cleanup(func()) +}) *WorkflowUpdateHandle { + mock := &WorkflowUpdateHandle{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/mock_test.go b/mocks/mock_test.go index 6b7c6de6f..c722e039d 100644 --- a/mocks/mock_test.go +++ b/mocks/mock_test.go @@ -117,3 +117,17 @@ func Test_MockResetWorkflowExecution(t *testing.T) { require.NoError(t, err) require.Equal(t, "new-run-id", actualResp.GetRunId()) } + +func Test_MockScheduleClient(t *testing.T) { + testScheduleID := "test-scheduleID" + mockClient := &ScheduleClient{} + + mockScheduleHandle := &ScheduleHandle{} + mockScheduleHandle.On("GetID").Return(testScheduleID).Times(1) + + mockClient.On("Create", mock.Anything, mock.Anything).Return(mockScheduleHandle, nil).Once() + wr, err := mockClient.Create(context.Background(), client.ScheduleOptions{}) + mockClient.AssertExpectations(t) + require.NoError(t, err) + require.Equal(t, testScheduleID, wr.GetID()) +}