From d7dc66a29d46a1b82c8c8be2235aa42f7df83e16 Mon Sep 17 00:00:00 2001 From: Christian Bianchi Date: Mon, 5 Aug 2024 11:10:16 +0200 Subject: [PATCH] Add unit test to check mapping of API responses to terraform status (#106) --- clickhouse/client_mock_test.go | 3110 ++++++++++++++++++++++++++++++++ clickhouse/service.go | 3 +- clickhouse/service_test.go | 428 +++++ go.mod | 4 +- go.sum | 10 +- 5 files changed, 3549 insertions(+), 6 deletions(-) create mode 100644 clickhouse/client_mock_test.go create mode 100644 clickhouse/service_test.go diff --git a/clickhouse/client_mock_test.go b/clickhouse/client_mock_test.go new file mode 100644 index 00000000..732c76cd --- /dev/null +++ b/clickhouse/client_mock_test.go @@ -0,0 +1,3110 @@ +// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT. + +package clickhouse + +//go:generate minimock -i terraform-provider-clickhouse/internal/api.Client -o client_mock_test.go -n ClientMock -p clickhouse + +import ( + mm_api "github.com/ClickHouse/terraform-provider-clickhouse/internal/api" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// ClientMock implements api.Client +type ClientMock struct { + t minimock.Tester + finishOnce sync.Once + + funcCreateService func(s mm_api.Service) (sp1 *mm_api.Service, s1 string, err error) + inspectFuncCreateService func(s mm_api.Service) + afterCreateServiceCounter uint64 + beforeCreateServiceCounter uint64 + CreateServiceMock mClientMockCreateService + + funcDeleteService func(serviceId string) (sp1 *mm_api.Service, err error) + inspectFuncDeleteService func(serviceId string) + afterDeleteServiceCounter uint64 + beforeDeleteServiceCounter uint64 + DeleteServiceMock mClientMockDeleteService + + funcGetOrgPrivateEndpointConfig func(cloudProvider string, region string) (op1 *mm_api.OrgPrivateEndpointConfig, err error) + inspectFuncGetOrgPrivateEndpointConfig func(cloudProvider string, region string) + afterGetOrgPrivateEndpointConfigCounter uint64 + beforeGetOrgPrivateEndpointConfigCounter uint64 + GetOrgPrivateEndpointConfigMock mClientMockGetOrgPrivateEndpointConfig + + funcGetOrganizationPrivateEndpoints func() (pap1 *[]mm_api.PrivateEndpoint, err error) + inspectFuncGetOrganizationPrivateEndpoints func() + afterGetOrganizationPrivateEndpointsCounter uint64 + beforeGetOrganizationPrivateEndpointsCounter uint64 + GetOrganizationPrivateEndpointsMock mClientMockGetOrganizationPrivateEndpoints + + funcGetService func(serviceId string) (sp1 *mm_api.Service, err error) + inspectFuncGetService func(serviceId string) + afterGetServiceCounter uint64 + beforeGetServiceCounter uint64 + GetServiceMock mClientMockGetService + + funcGetServiceStatusCode func(serviceId string) (ip1 *int, err error) + inspectFuncGetServiceStatusCode func(serviceId string) + afterGetServiceStatusCodeCounter uint64 + beforeGetServiceStatusCodeCounter uint64 + GetServiceStatusCodeMock mClientMockGetServiceStatusCode + + funcUpdateOrganizationPrivateEndpoints func(orgUpdate mm_api.OrganizationUpdate) (pap1 *[]mm_api.PrivateEndpoint, err error) + inspectFuncUpdateOrganizationPrivateEndpoints func(orgUpdate mm_api.OrganizationUpdate) + afterUpdateOrganizationPrivateEndpointsCounter uint64 + beforeUpdateOrganizationPrivateEndpointsCounter uint64 + UpdateOrganizationPrivateEndpointsMock mClientMockUpdateOrganizationPrivateEndpoints + + funcUpdateService func(serviceId string, s mm_api.ServiceUpdate) (sp1 *mm_api.Service, err error) + inspectFuncUpdateService func(serviceId string, s mm_api.ServiceUpdate) + afterUpdateServiceCounter uint64 + beforeUpdateServiceCounter uint64 + UpdateServiceMock mClientMockUpdateService + + funcUpdateServicePassword func(serviceId string, u mm_api.ServicePasswordUpdate) (sp1 *mm_api.ServicePasswordUpdateResult, err error) + inspectFuncUpdateServicePassword func(serviceId string, u mm_api.ServicePasswordUpdate) + afterUpdateServicePasswordCounter uint64 + beforeUpdateServicePasswordCounter uint64 + UpdateServicePasswordMock mClientMockUpdateServicePassword + + funcUpdateServiceScaling func(serviceId string, s mm_api.ServiceScalingUpdate) (sp1 *mm_api.Service, err error) + inspectFuncUpdateServiceScaling func(serviceId string, s mm_api.ServiceScalingUpdate) + afterUpdateServiceScalingCounter uint64 + beforeUpdateServiceScalingCounter uint64 + UpdateServiceScalingMock mClientMockUpdateServiceScaling +} + +// NewClientMock returns a mock for api.Client +func NewClientMock(t minimock.Tester) *ClientMock { + m := &ClientMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.CreateServiceMock = mClientMockCreateService{mock: m} + m.CreateServiceMock.callArgs = []*ClientMockCreateServiceParams{} + + m.DeleteServiceMock = mClientMockDeleteService{mock: m} + m.DeleteServiceMock.callArgs = []*ClientMockDeleteServiceParams{} + + m.GetOrgPrivateEndpointConfigMock = mClientMockGetOrgPrivateEndpointConfig{mock: m} + m.GetOrgPrivateEndpointConfigMock.callArgs = []*ClientMockGetOrgPrivateEndpointConfigParams{} + + m.GetOrganizationPrivateEndpointsMock = mClientMockGetOrganizationPrivateEndpoints{mock: m} + + m.GetServiceMock = mClientMockGetService{mock: m} + m.GetServiceMock.callArgs = []*ClientMockGetServiceParams{} + + m.GetServiceStatusCodeMock = mClientMockGetServiceStatusCode{mock: m} + m.GetServiceStatusCodeMock.callArgs = []*ClientMockGetServiceStatusCodeParams{} + + m.UpdateOrganizationPrivateEndpointsMock = mClientMockUpdateOrganizationPrivateEndpoints{mock: m} + m.UpdateOrganizationPrivateEndpointsMock.callArgs = []*ClientMockUpdateOrganizationPrivateEndpointsParams{} + + m.UpdateServiceMock = mClientMockUpdateService{mock: m} + m.UpdateServiceMock.callArgs = []*ClientMockUpdateServiceParams{} + + m.UpdateServicePasswordMock = mClientMockUpdateServicePassword{mock: m} + m.UpdateServicePasswordMock.callArgs = []*ClientMockUpdateServicePasswordParams{} + + m.UpdateServiceScalingMock = mClientMockUpdateServiceScaling{mock: m} + m.UpdateServiceScalingMock.callArgs = []*ClientMockUpdateServiceScalingParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mClientMockCreateService struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockCreateServiceExpectation + expectations []*ClientMockCreateServiceExpectation + + callArgs []*ClientMockCreateServiceParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockCreateServiceExpectation specifies expectation struct of the Client.CreateService +type ClientMockCreateServiceExpectation struct { + mock *ClientMock + params *ClientMockCreateServiceParams + paramPtrs *ClientMockCreateServiceParamPtrs + results *ClientMockCreateServiceResults + Counter uint64 +} + +// ClientMockCreateServiceParams contains parameters of the Client.CreateService +type ClientMockCreateServiceParams struct { + s mm_api.Service +} + +// ClientMockCreateServiceParamPtrs contains pointers to parameters of the Client.CreateService +type ClientMockCreateServiceParamPtrs struct { + s *mm_api.Service +} + +// ClientMockCreateServiceResults contains results of the Client.CreateService +type ClientMockCreateServiceResults struct { + sp1 *mm_api.Service + s1 string + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreateService *mClientMockCreateService) Optional() *mClientMockCreateService { + mmCreateService.optional = true + return mmCreateService +} + +// Expect sets up expected params for Client.CreateService +func (mmCreateService *mClientMockCreateService) Expect(s mm_api.Service) *mClientMockCreateService { + if mmCreateService.mock.funcCreateService != nil { + mmCreateService.mock.t.Fatalf("ClientMock.CreateService mock is already set by Set") + } + + if mmCreateService.defaultExpectation == nil { + mmCreateService.defaultExpectation = &ClientMockCreateServiceExpectation{} + } + + if mmCreateService.defaultExpectation.paramPtrs != nil { + mmCreateService.mock.t.Fatalf("ClientMock.CreateService mock is already set by ExpectParams functions") + } + + mmCreateService.defaultExpectation.params = &ClientMockCreateServiceParams{s} + for _, e := range mmCreateService.expectations { + if minimock.Equal(e.params, mmCreateService.defaultExpectation.params) { + mmCreateService.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateService.defaultExpectation.params) + } + } + + return mmCreateService +} + +// ExpectSParam1 sets up expected param s for Client.CreateService +func (mmCreateService *mClientMockCreateService) ExpectSParam1(s mm_api.Service) *mClientMockCreateService { + if mmCreateService.mock.funcCreateService != nil { + mmCreateService.mock.t.Fatalf("ClientMock.CreateService mock is already set by Set") + } + + if mmCreateService.defaultExpectation == nil { + mmCreateService.defaultExpectation = &ClientMockCreateServiceExpectation{} + } + + if mmCreateService.defaultExpectation.params != nil { + mmCreateService.mock.t.Fatalf("ClientMock.CreateService mock is already set by Expect") + } + + if mmCreateService.defaultExpectation.paramPtrs == nil { + mmCreateService.defaultExpectation.paramPtrs = &ClientMockCreateServiceParamPtrs{} + } + mmCreateService.defaultExpectation.paramPtrs.s = &s + + return mmCreateService +} + +// Inspect accepts an inspector function that has same arguments as the Client.CreateService +func (mmCreateService *mClientMockCreateService) Inspect(f func(s mm_api.Service)) *mClientMockCreateService { + if mmCreateService.mock.inspectFuncCreateService != nil { + mmCreateService.mock.t.Fatalf("Inspect function is already set for ClientMock.CreateService") + } + + mmCreateService.mock.inspectFuncCreateService = f + + return mmCreateService +} + +// Return sets up results that will be returned by Client.CreateService +func (mmCreateService *mClientMockCreateService) Return(sp1 *mm_api.Service, s1 string, err error) *ClientMock { + if mmCreateService.mock.funcCreateService != nil { + mmCreateService.mock.t.Fatalf("ClientMock.CreateService mock is already set by Set") + } + + if mmCreateService.defaultExpectation == nil { + mmCreateService.defaultExpectation = &ClientMockCreateServiceExpectation{mock: mmCreateService.mock} + } + mmCreateService.defaultExpectation.results = &ClientMockCreateServiceResults{sp1, s1, err} + return mmCreateService.mock +} + +// Set uses given function f to mock the Client.CreateService method +func (mmCreateService *mClientMockCreateService) Set(f func(s mm_api.Service) (sp1 *mm_api.Service, s1 string, err error)) *ClientMock { + if mmCreateService.defaultExpectation != nil { + mmCreateService.mock.t.Fatalf("Default expectation is already set for the Client.CreateService method") + } + + if len(mmCreateService.expectations) > 0 { + mmCreateService.mock.t.Fatalf("Some expectations are already set for the Client.CreateService method") + } + + mmCreateService.mock.funcCreateService = f + return mmCreateService.mock +} + +// When sets expectation for the Client.CreateService which will trigger the result defined by the following +// Then helper +func (mmCreateService *mClientMockCreateService) When(s mm_api.Service) *ClientMockCreateServiceExpectation { + if mmCreateService.mock.funcCreateService != nil { + mmCreateService.mock.t.Fatalf("ClientMock.CreateService mock is already set by Set") + } + + expectation := &ClientMockCreateServiceExpectation{ + mock: mmCreateService.mock, + params: &ClientMockCreateServiceParams{s}, + } + mmCreateService.expectations = append(mmCreateService.expectations, expectation) + return expectation +} + +// Then sets up Client.CreateService return parameters for the expectation previously defined by the When method +func (e *ClientMockCreateServiceExpectation) Then(sp1 *mm_api.Service, s1 string, err error) *ClientMock { + e.results = &ClientMockCreateServiceResults{sp1, s1, err} + return e.mock +} + +// Times sets number of times Client.CreateService should be invoked +func (mmCreateService *mClientMockCreateService) Times(n uint64) *mClientMockCreateService { + if n == 0 { + mmCreateService.mock.t.Fatalf("Times of ClientMock.CreateService mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreateService.expectedInvocations, n) + return mmCreateService +} + +func (mmCreateService *mClientMockCreateService) invocationsDone() bool { + if len(mmCreateService.expectations) == 0 && mmCreateService.defaultExpectation == nil && mmCreateService.mock.funcCreateService == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreateService.mock.afterCreateServiceCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreateService.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// CreateService implements api.Client +func (mmCreateService *ClientMock) CreateService(s mm_api.Service) (sp1 *mm_api.Service, s1 string, err error) { + mm_atomic.AddUint64(&mmCreateService.beforeCreateServiceCounter, 1) + defer mm_atomic.AddUint64(&mmCreateService.afterCreateServiceCounter, 1) + + if mmCreateService.inspectFuncCreateService != nil { + mmCreateService.inspectFuncCreateService(s) + } + + mm_params := ClientMockCreateServiceParams{s} + + // Record call args + mmCreateService.CreateServiceMock.mutex.Lock() + mmCreateService.CreateServiceMock.callArgs = append(mmCreateService.CreateServiceMock.callArgs, &mm_params) + mmCreateService.CreateServiceMock.mutex.Unlock() + + for _, e := range mmCreateService.CreateServiceMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.s1, e.results.err + } + } + + if mmCreateService.CreateServiceMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreateService.CreateServiceMock.defaultExpectation.Counter, 1) + mm_want := mmCreateService.CreateServiceMock.defaultExpectation.params + mm_want_ptrs := mmCreateService.CreateServiceMock.defaultExpectation.paramPtrs + + mm_got := ClientMockCreateServiceParams{s} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.s != nil && !minimock.Equal(*mm_want_ptrs.s, mm_got.s) { + mmCreateService.t.Errorf("ClientMock.CreateService got unexpected parameter s, want: %#v, got: %#v%s\n", *mm_want_ptrs.s, mm_got.s, minimock.Diff(*mm_want_ptrs.s, mm_got.s)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreateService.t.Errorf("ClientMock.CreateService got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreateService.CreateServiceMock.defaultExpectation.results + if mm_results == nil { + mmCreateService.t.Fatal("No results are set for the ClientMock.CreateService") + } + return (*mm_results).sp1, (*mm_results).s1, (*mm_results).err + } + if mmCreateService.funcCreateService != nil { + return mmCreateService.funcCreateService(s) + } + mmCreateService.t.Fatalf("Unexpected call to ClientMock.CreateService. %v", s) + return +} + +// CreateServiceAfterCounter returns a count of finished ClientMock.CreateService invocations +func (mmCreateService *ClientMock) CreateServiceAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateService.afterCreateServiceCounter) +} + +// CreateServiceBeforeCounter returns a count of ClientMock.CreateService invocations +func (mmCreateService *ClientMock) CreateServiceBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateService.beforeCreateServiceCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.CreateService. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreateService *mClientMockCreateService) Calls() []*ClientMockCreateServiceParams { + mmCreateService.mutex.RLock() + + argCopy := make([]*ClientMockCreateServiceParams, len(mmCreateService.callArgs)) + copy(argCopy, mmCreateService.callArgs) + + mmCreateService.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateServiceDone returns true if the count of the CreateService invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockCreateServiceDone() bool { + if m.CreateServiceMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateServiceMock.invocationsDone() +} + +// MinimockCreateServiceInspect logs each unmet expectation +func (m *ClientMock) MinimockCreateServiceInspect() { + for _, e := range m.CreateServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.CreateService with params: %#v", *e.params) + } + } + + afterCreateServiceCounter := mm_atomic.LoadUint64(&m.afterCreateServiceCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateServiceMock.defaultExpectation != nil && afterCreateServiceCounter < 1 { + if m.CreateServiceMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.CreateService") + } else { + m.t.Errorf("Expected call to ClientMock.CreateService with params: %#v", *m.CreateServiceMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreateService != nil && afterCreateServiceCounter < 1 { + m.t.Error("Expected call to ClientMock.CreateService") + } + + if !m.CreateServiceMock.invocationsDone() && afterCreateServiceCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.CreateService but found %d calls", + mm_atomic.LoadUint64(&m.CreateServiceMock.expectedInvocations), afterCreateServiceCounter) + } +} + +type mClientMockDeleteService struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockDeleteServiceExpectation + expectations []*ClientMockDeleteServiceExpectation + + callArgs []*ClientMockDeleteServiceParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockDeleteServiceExpectation specifies expectation struct of the Client.DeleteService +type ClientMockDeleteServiceExpectation struct { + mock *ClientMock + params *ClientMockDeleteServiceParams + paramPtrs *ClientMockDeleteServiceParamPtrs + results *ClientMockDeleteServiceResults + Counter uint64 +} + +// ClientMockDeleteServiceParams contains parameters of the Client.DeleteService +type ClientMockDeleteServiceParams struct { + serviceId string +} + +// ClientMockDeleteServiceParamPtrs contains pointers to parameters of the Client.DeleteService +type ClientMockDeleteServiceParamPtrs struct { + serviceId *string +} + +// ClientMockDeleteServiceResults contains results of the Client.DeleteService +type ClientMockDeleteServiceResults struct { + sp1 *mm_api.Service + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmDeleteService *mClientMockDeleteService) Optional() *mClientMockDeleteService { + mmDeleteService.optional = true + return mmDeleteService +} + +// Expect sets up expected params for Client.DeleteService +func (mmDeleteService *mClientMockDeleteService) Expect(serviceId string) *mClientMockDeleteService { + if mmDeleteService.mock.funcDeleteService != nil { + mmDeleteService.mock.t.Fatalf("ClientMock.DeleteService mock is already set by Set") + } + + if mmDeleteService.defaultExpectation == nil { + mmDeleteService.defaultExpectation = &ClientMockDeleteServiceExpectation{} + } + + if mmDeleteService.defaultExpectation.paramPtrs != nil { + mmDeleteService.mock.t.Fatalf("ClientMock.DeleteService mock is already set by ExpectParams functions") + } + + mmDeleteService.defaultExpectation.params = &ClientMockDeleteServiceParams{serviceId} + for _, e := range mmDeleteService.expectations { + if minimock.Equal(e.params, mmDeleteService.defaultExpectation.params) { + mmDeleteService.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteService.defaultExpectation.params) + } + } + + return mmDeleteService +} + +// ExpectServiceIdParam1 sets up expected param serviceId for Client.DeleteService +func (mmDeleteService *mClientMockDeleteService) ExpectServiceIdParam1(serviceId string) *mClientMockDeleteService { + if mmDeleteService.mock.funcDeleteService != nil { + mmDeleteService.mock.t.Fatalf("ClientMock.DeleteService mock is already set by Set") + } + + if mmDeleteService.defaultExpectation == nil { + mmDeleteService.defaultExpectation = &ClientMockDeleteServiceExpectation{} + } + + if mmDeleteService.defaultExpectation.params != nil { + mmDeleteService.mock.t.Fatalf("ClientMock.DeleteService mock is already set by Expect") + } + + if mmDeleteService.defaultExpectation.paramPtrs == nil { + mmDeleteService.defaultExpectation.paramPtrs = &ClientMockDeleteServiceParamPtrs{} + } + mmDeleteService.defaultExpectation.paramPtrs.serviceId = &serviceId + + return mmDeleteService +} + +// Inspect accepts an inspector function that has same arguments as the Client.DeleteService +func (mmDeleteService *mClientMockDeleteService) Inspect(f func(serviceId string)) *mClientMockDeleteService { + if mmDeleteService.mock.inspectFuncDeleteService != nil { + mmDeleteService.mock.t.Fatalf("Inspect function is already set for ClientMock.DeleteService") + } + + mmDeleteService.mock.inspectFuncDeleteService = f + + return mmDeleteService +} + +// Return sets up results that will be returned by Client.DeleteService +func (mmDeleteService *mClientMockDeleteService) Return(sp1 *mm_api.Service, err error) *ClientMock { + if mmDeleteService.mock.funcDeleteService != nil { + mmDeleteService.mock.t.Fatalf("ClientMock.DeleteService mock is already set by Set") + } + + if mmDeleteService.defaultExpectation == nil { + mmDeleteService.defaultExpectation = &ClientMockDeleteServiceExpectation{mock: mmDeleteService.mock} + } + mmDeleteService.defaultExpectation.results = &ClientMockDeleteServiceResults{sp1, err} + return mmDeleteService.mock +} + +// Set uses given function f to mock the Client.DeleteService method +func (mmDeleteService *mClientMockDeleteService) Set(f func(serviceId string) (sp1 *mm_api.Service, err error)) *ClientMock { + if mmDeleteService.defaultExpectation != nil { + mmDeleteService.mock.t.Fatalf("Default expectation is already set for the Client.DeleteService method") + } + + if len(mmDeleteService.expectations) > 0 { + mmDeleteService.mock.t.Fatalf("Some expectations are already set for the Client.DeleteService method") + } + + mmDeleteService.mock.funcDeleteService = f + return mmDeleteService.mock +} + +// When sets expectation for the Client.DeleteService which will trigger the result defined by the following +// Then helper +func (mmDeleteService *mClientMockDeleteService) When(serviceId string) *ClientMockDeleteServiceExpectation { + if mmDeleteService.mock.funcDeleteService != nil { + mmDeleteService.mock.t.Fatalf("ClientMock.DeleteService mock is already set by Set") + } + + expectation := &ClientMockDeleteServiceExpectation{ + mock: mmDeleteService.mock, + params: &ClientMockDeleteServiceParams{serviceId}, + } + mmDeleteService.expectations = append(mmDeleteService.expectations, expectation) + return expectation +} + +// Then sets up Client.DeleteService return parameters for the expectation previously defined by the When method +func (e *ClientMockDeleteServiceExpectation) Then(sp1 *mm_api.Service, err error) *ClientMock { + e.results = &ClientMockDeleteServiceResults{sp1, err} + return e.mock +} + +// Times sets number of times Client.DeleteService should be invoked +func (mmDeleteService *mClientMockDeleteService) Times(n uint64) *mClientMockDeleteService { + if n == 0 { + mmDeleteService.mock.t.Fatalf("Times of ClientMock.DeleteService mock can not be zero") + } + mm_atomic.StoreUint64(&mmDeleteService.expectedInvocations, n) + return mmDeleteService +} + +func (mmDeleteService *mClientMockDeleteService) invocationsDone() bool { + if len(mmDeleteService.expectations) == 0 && mmDeleteService.defaultExpectation == nil && mmDeleteService.mock.funcDeleteService == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmDeleteService.mock.afterDeleteServiceCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmDeleteService.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// DeleteService implements api.Client +func (mmDeleteService *ClientMock) DeleteService(serviceId string) (sp1 *mm_api.Service, err error) { + mm_atomic.AddUint64(&mmDeleteService.beforeDeleteServiceCounter, 1) + defer mm_atomic.AddUint64(&mmDeleteService.afterDeleteServiceCounter, 1) + + if mmDeleteService.inspectFuncDeleteService != nil { + mmDeleteService.inspectFuncDeleteService(serviceId) + } + + mm_params := ClientMockDeleteServiceParams{serviceId} + + // Record call args + mmDeleteService.DeleteServiceMock.mutex.Lock() + mmDeleteService.DeleteServiceMock.callArgs = append(mmDeleteService.DeleteServiceMock.callArgs, &mm_params) + mmDeleteService.DeleteServiceMock.mutex.Unlock() + + for _, e := range mmDeleteService.DeleteServiceMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.err + } + } + + if mmDeleteService.DeleteServiceMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmDeleteService.DeleteServiceMock.defaultExpectation.Counter, 1) + mm_want := mmDeleteService.DeleteServiceMock.defaultExpectation.params + mm_want_ptrs := mmDeleteService.DeleteServiceMock.defaultExpectation.paramPtrs + + mm_got := ClientMockDeleteServiceParams{serviceId} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.serviceId != nil && !minimock.Equal(*mm_want_ptrs.serviceId, mm_got.serviceId) { + mmDeleteService.t.Errorf("ClientMock.DeleteService got unexpected parameter serviceId, want: %#v, got: %#v%s\n", *mm_want_ptrs.serviceId, mm_got.serviceId, minimock.Diff(*mm_want_ptrs.serviceId, mm_got.serviceId)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmDeleteService.t.Errorf("ClientMock.DeleteService got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmDeleteService.DeleteServiceMock.defaultExpectation.results + if mm_results == nil { + mmDeleteService.t.Fatal("No results are set for the ClientMock.DeleteService") + } + return (*mm_results).sp1, (*mm_results).err + } + if mmDeleteService.funcDeleteService != nil { + return mmDeleteService.funcDeleteService(serviceId) + } + mmDeleteService.t.Fatalf("Unexpected call to ClientMock.DeleteService. %v", serviceId) + return +} + +// DeleteServiceAfterCounter returns a count of finished ClientMock.DeleteService invocations +func (mmDeleteService *ClientMock) DeleteServiceAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeleteService.afterDeleteServiceCounter) +} + +// DeleteServiceBeforeCounter returns a count of ClientMock.DeleteService invocations +func (mmDeleteService *ClientMock) DeleteServiceBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeleteService.beforeDeleteServiceCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.DeleteService. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmDeleteService *mClientMockDeleteService) Calls() []*ClientMockDeleteServiceParams { + mmDeleteService.mutex.RLock() + + argCopy := make([]*ClientMockDeleteServiceParams, len(mmDeleteService.callArgs)) + copy(argCopy, mmDeleteService.callArgs) + + mmDeleteService.mutex.RUnlock() + + return argCopy +} + +// MinimockDeleteServiceDone returns true if the count of the DeleteService invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockDeleteServiceDone() bool { + if m.DeleteServiceMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.DeleteServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.DeleteServiceMock.invocationsDone() +} + +// MinimockDeleteServiceInspect logs each unmet expectation +func (m *ClientMock) MinimockDeleteServiceInspect() { + for _, e := range m.DeleteServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.DeleteService with params: %#v", *e.params) + } + } + + afterDeleteServiceCounter := mm_atomic.LoadUint64(&m.afterDeleteServiceCounter) + // if default expectation was set then invocations count should be greater than zero + if m.DeleteServiceMock.defaultExpectation != nil && afterDeleteServiceCounter < 1 { + if m.DeleteServiceMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.DeleteService") + } else { + m.t.Errorf("Expected call to ClientMock.DeleteService with params: %#v", *m.DeleteServiceMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcDeleteService != nil && afterDeleteServiceCounter < 1 { + m.t.Error("Expected call to ClientMock.DeleteService") + } + + if !m.DeleteServiceMock.invocationsDone() && afterDeleteServiceCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.DeleteService but found %d calls", + mm_atomic.LoadUint64(&m.DeleteServiceMock.expectedInvocations), afterDeleteServiceCounter) + } +} + +type mClientMockGetOrgPrivateEndpointConfig struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockGetOrgPrivateEndpointConfigExpectation + expectations []*ClientMockGetOrgPrivateEndpointConfigExpectation + + callArgs []*ClientMockGetOrgPrivateEndpointConfigParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockGetOrgPrivateEndpointConfigExpectation specifies expectation struct of the Client.GetOrgPrivateEndpointConfig +type ClientMockGetOrgPrivateEndpointConfigExpectation struct { + mock *ClientMock + params *ClientMockGetOrgPrivateEndpointConfigParams + paramPtrs *ClientMockGetOrgPrivateEndpointConfigParamPtrs + results *ClientMockGetOrgPrivateEndpointConfigResults + Counter uint64 +} + +// ClientMockGetOrgPrivateEndpointConfigParams contains parameters of the Client.GetOrgPrivateEndpointConfig +type ClientMockGetOrgPrivateEndpointConfigParams struct { + cloudProvider string + region string +} + +// ClientMockGetOrgPrivateEndpointConfigParamPtrs contains pointers to parameters of the Client.GetOrgPrivateEndpointConfig +type ClientMockGetOrgPrivateEndpointConfigParamPtrs struct { + cloudProvider *string + region *string +} + +// ClientMockGetOrgPrivateEndpointConfigResults contains results of the Client.GetOrgPrivateEndpointConfig +type ClientMockGetOrgPrivateEndpointConfigResults struct { + op1 *mm_api.OrgPrivateEndpointConfig + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) Optional() *mClientMockGetOrgPrivateEndpointConfig { + mmGetOrgPrivateEndpointConfig.optional = true + return mmGetOrgPrivateEndpointConfig +} + +// Expect sets up expected params for Client.GetOrgPrivateEndpointConfig +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) Expect(cloudProvider string, region string) *mClientMockGetOrgPrivateEndpointConfig { + if mmGetOrgPrivateEndpointConfig.mock.funcGetOrgPrivateEndpointConfig != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by Set") + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation == nil { + mmGetOrgPrivateEndpointConfig.defaultExpectation = &ClientMockGetOrgPrivateEndpointConfigExpectation{} + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation.paramPtrs != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by ExpectParams functions") + } + + mmGetOrgPrivateEndpointConfig.defaultExpectation.params = &ClientMockGetOrgPrivateEndpointConfigParams{cloudProvider, region} + for _, e := range mmGetOrgPrivateEndpointConfig.expectations { + if minimock.Equal(e.params, mmGetOrgPrivateEndpointConfig.defaultExpectation.params) { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetOrgPrivateEndpointConfig.defaultExpectation.params) + } + } + + return mmGetOrgPrivateEndpointConfig +} + +// ExpectCloudProviderParam1 sets up expected param cloudProvider for Client.GetOrgPrivateEndpointConfig +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) ExpectCloudProviderParam1(cloudProvider string) *mClientMockGetOrgPrivateEndpointConfig { + if mmGetOrgPrivateEndpointConfig.mock.funcGetOrgPrivateEndpointConfig != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by Set") + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation == nil { + mmGetOrgPrivateEndpointConfig.defaultExpectation = &ClientMockGetOrgPrivateEndpointConfigExpectation{} + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation.params != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by Expect") + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation.paramPtrs == nil { + mmGetOrgPrivateEndpointConfig.defaultExpectation.paramPtrs = &ClientMockGetOrgPrivateEndpointConfigParamPtrs{} + } + mmGetOrgPrivateEndpointConfig.defaultExpectation.paramPtrs.cloudProvider = &cloudProvider + + return mmGetOrgPrivateEndpointConfig +} + +// ExpectRegionParam2 sets up expected param region for Client.GetOrgPrivateEndpointConfig +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) ExpectRegionParam2(region string) *mClientMockGetOrgPrivateEndpointConfig { + if mmGetOrgPrivateEndpointConfig.mock.funcGetOrgPrivateEndpointConfig != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by Set") + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation == nil { + mmGetOrgPrivateEndpointConfig.defaultExpectation = &ClientMockGetOrgPrivateEndpointConfigExpectation{} + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation.params != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by Expect") + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation.paramPtrs == nil { + mmGetOrgPrivateEndpointConfig.defaultExpectation.paramPtrs = &ClientMockGetOrgPrivateEndpointConfigParamPtrs{} + } + mmGetOrgPrivateEndpointConfig.defaultExpectation.paramPtrs.region = ®ion + + return mmGetOrgPrivateEndpointConfig +} + +// Inspect accepts an inspector function that has same arguments as the Client.GetOrgPrivateEndpointConfig +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) Inspect(f func(cloudProvider string, region string)) *mClientMockGetOrgPrivateEndpointConfig { + if mmGetOrgPrivateEndpointConfig.mock.inspectFuncGetOrgPrivateEndpointConfig != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("Inspect function is already set for ClientMock.GetOrgPrivateEndpointConfig") + } + + mmGetOrgPrivateEndpointConfig.mock.inspectFuncGetOrgPrivateEndpointConfig = f + + return mmGetOrgPrivateEndpointConfig +} + +// Return sets up results that will be returned by Client.GetOrgPrivateEndpointConfig +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) Return(op1 *mm_api.OrgPrivateEndpointConfig, err error) *ClientMock { + if mmGetOrgPrivateEndpointConfig.mock.funcGetOrgPrivateEndpointConfig != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by Set") + } + + if mmGetOrgPrivateEndpointConfig.defaultExpectation == nil { + mmGetOrgPrivateEndpointConfig.defaultExpectation = &ClientMockGetOrgPrivateEndpointConfigExpectation{mock: mmGetOrgPrivateEndpointConfig.mock} + } + mmGetOrgPrivateEndpointConfig.defaultExpectation.results = &ClientMockGetOrgPrivateEndpointConfigResults{op1, err} + return mmGetOrgPrivateEndpointConfig.mock +} + +// Set uses given function f to mock the Client.GetOrgPrivateEndpointConfig method +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) Set(f func(cloudProvider string, region string) (op1 *mm_api.OrgPrivateEndpointConfig, err error)) *ClientMock { + if mmGetOrgPrivateEndpointConfig.defaultExpectation != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("Default expectation is already set for the Client.GetOrgPrivateEndpointConfig method") + } + + if len(mmGetOrgPrivateEndpointConfig.expectations) > 0 { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("Some expectations are already set for the Client.GetOrgPrivateEndpointConfig method") + } + + mmGetOrgPrivateEndpointConfig.mock.funcGetOrgPrivateEndpointConfig = f + return mmGetOrgPrivateEndpointConfig.mock +} + +// When sets expectation for the Client.GetOrgPrivateEndpointConfig which will trigger the result defined by the following +// Then helper +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) When(cloudProvider string, region string) *ClientMockGetOrgPrivateEndpointConfigExpectation { + if mmGetOrgPrivateEndpointConfig.mock.funcGetOrgPrivateEndpointConfig != nil { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("ClientMock.GetOrgPrivateEndpointConfig mock is already set by Set") + } + + expectation := &ClientMockGetOrgPrivateEndpointConfigExpectation{ + mock: mmGetOrgPrivateEndpointConfig.mock, + params: &ClientMockGetOrgPrivateEndpointConfigParams{cloudProvider, region}, + } + mmGetOrgPrivateEndpointConfig.expectations = append(mmGetOrgPrivateEndpointConfig.expectations, expectation) + return expectation +} + +// Then sets up Client.GetOrgPrivateEndpointConfig return parameters for the expectation previously defined by the When method +func (e *ClientMockGetOrgPrivateEndpointConfigExpectation) Then(op1 *mm_api.OrgPrivateEndpointConfig, err error) *ClientMock { + e.results = &ClientMockGetOrgPrivateEndpointConfigResults{op1, err} + return e.mock +} + +// Times sets number of times Client.GetOrgPrivateEndpointConfig should be invoked +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) Times(n uint64) *mClientMockGetOrgPrivateEndpointConfig { + if n == 0 { + mmGetOrgPrivateEndpointConfig.mock.t.Fatalf("Times of ClientMock.GetOrgPrivateEndpointConfig mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetOrgPrivateEndpointConfig.expectedInvocations, n) + return mmGetOrgPrivateEndpointConfig +} + +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) invocationsDone() bool { + if len(mmGetOrgPrivateEndpointConfig.expectations) == 0 && mmGetOrgPrivateEndpointConfig.defaultExpectation == nil && mmGetOrgPrivateEndpointConfig.mock.funcGetOrgPrivateEndpointConfig == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetOrgPrivateEndpointConfig.mock.afterGetOrgPrivateEndpointConfigCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetOrgPrivateEndpointConfig.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetOrgPrivateEndpointConfig implements api.Client +func (mmGetOrgPrivateEndpointConfig *ClientMock) GetOrgPrivateEndpointConfig(cloudProvider string, region string) (op1 *mm_api.OrgPrivateEndpointConfig, err error) { + mm_atomic.AddUint64(&mmGetOrgPrivateEndpointConfig.beforeGetOrgPrivateEndpointConfigCounter, 1) + defer mm_atomic.AddUint64(&mmGetOrgPrivateEndpointConfig.afterGetOrgPrivateEndpointConfigCounter, 1) + + if mmGetOrgPrivateEndpointConfig.inspectFuncGetOrgPrivateEndpointConfig != nil { + mmGetOrgPrivateEndpointConfig.inspectFuncGetOrgPrivateEndpointConfig(cloudProvider, region) + } + + mm_params := ClientMockGetOrgPrivateEndpointConfigParams{cloudProvider, region} + + // Record call args + mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.mutex.Lock() + mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.callArgs = append(mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.callArgs, &mm_params) + mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.mutex.Unlock() + + for _, e := range mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.op1, e.results.err + } + } + + if mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.defaultExpectation.Counter, 1) + mm_want := mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.defaultExpectation.params + mm_want_ptrs := mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.defaultExpectation.paramPtrs + + mm_got := ClientMockGetOrgPrivateEndpointConfigParams{cloudProvider, region} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.cloudProvider != nil && !minimock.Equal(*mm_want_ptrs.cloudProvider, mm_got.cloudProvider) { + mmGetOrgPrivateEndpointConfig.t.Errorf("ClientMock.GetOrgPrivateEndpointConfig got unexpected parameter cloudProvider, want: %#v, got: %#v%s\n", *mm_want_ptrs.cloudProvider, mm_got.cloudProvider, minimock.Diff(*mm_want_ptrs.cloudProvider, mm_got.cloudProvider)) + } + + if mm_want_ptrs.region != nil && !minimock.Equal(*mm_want_ptrs.region, mm_got.region) { + mmGetOrgPrivateEndpointConfig.t.Errorf("ClientMock.GetOrgPrivateEndpointConfig got unexpected parameter region, want: %#v, got: %#v%s\n", *mm_want_ptrs.region, mm_got.region, minimock.Diff(*mm_want_ptrs.region, mm_got.region)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetOrgPrivateEndpointConfig.t.Errorf("ClientMock.GetOrgPrivateEndpointConfig got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetOrgPrivateEndpointConfig.GetOrgPrivateEndpointConfigMock.defaultExpectation.results + if mm_results == nil { + mmGetOrgPrivateEndpointConfig.t.Fatal("No results are set for the ClientMock.GetOrgPrivateEndpointConfig") + } + return (*mm_results).op1, (*mm_results).err + } + if mmGetOrgPrivateEndpointConfig.funcGetOrgPrivateEndpointConfig != nil { + return mmGetOrgPrivateEndpointConfig.funcGetOrgPrivateEndpointConfig(cloudProvider, region) + } + mmGetOrgPrivateEndpointConfig.t.Fatalf("Unexpected call to ClientMock.GetOrgPrivateEndpointConfig. %v %v", cloudProvider, region) + return +} + +// GetOrgPrivateEndpointConfigAfterCounter returns a count of finished ClientMock.GetOrgPrivateEndpointConfig invocations +func (mmGetOrgPrivateEndpointConfig *ClientMock) GetOrgPrivateEndpointConfigAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetOrgPrivateEndpointConfig.afterGetOrgPrivateEndpointConfigCounter) +} + +// GetOrgPrivateEndpointConfigBeforeCounter returns a count of ClientMock.GetOrgPrivateEndpointConfig invocations +func (mmGetOrgPrivateEndpointConfig *ClientMock) GetOrgPrivateEndpointConfigBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetOrgPrivateEndpointConfig.beforeGetOrgPrivateEndpointConfigCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.GetOrgPrivateEndpointConfig. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetOrgPrivateEndpointConfig *mClientMockGetOrgPrivateEndpointConfig) Calls() []*ClientMockGetOrgPrivateEndpointConfigParams { + mmGetOrgPrivateEndpointConfig.mutex.RLock() + + argCopy := make([]*ClientMockGetOrgPrivateEndpointConfigParams, len(mmGetOrgPrivateEndpointConfig.callArgs)) + copy(argCopy, mmGetOrgPrivateEndpointConfig.callArgs) + + mmGetOrgPrivateEndpointConfig.mutex.RUnlock() + + return argCopy +} + +// MinimockGetOrgPrivateEndpointConfigDone returns true if the count of the GetOrgPrivateEndpointConfig invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockGetOrgPrivateEndpointConfigDone() bool { + if m.GetOrgPrivateEndpointConfigMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetOrgPrivateEndpointConfigMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetOrgPrivateEndpointConfigMock.invocationsDone() +} + +// MinimockGetOrgPrivateEndpointConfigInspect logs each unmet expectation +func (m *ClientMock) MinimockGetOrgPrivateEndpointConfigInspect() { + for _, e := range m.GetOrgPrivateEndpointConfigMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.GetOrgPrivateEndpointConfig with params: %#v", *e.params) + } + } + + afterGetOrgPrivateEndpointConfigCounter := mm_atomic.LoadUint64(&m.afterGetOrgPrivateEndpointConfigCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetOrgPrivateEndpointConfigMock.defaultExpectation != nil && afterGetOrgPrivateEndpointConfigCounter < 1 { + if m.GetOrgPrivateEndpointConfigMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.GetOrgPrivateEndpointConfig") + } else { + m.t.Errorf("Expected call to ClientMock.GetOrgPrivateEndpointConfig with params: %#v", *m.GetOrgPrivateEndpointConfigMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetOrgPrivateEndpointConfig != nil && afterGetOrgPrivateEndpointConfigCounter < 1 { + m.t.Error("Expected call to ClientMock.GetOrgPrivateEndpointConfig") + } + + if !m.GetOrgPrivateEndpointConfigMock.invocationsDone() && afterGetOrgPrivateEndpointConfigCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.GetOrgPrivateEndpointConfig but found %d calls", + mm_atomic.LoadUint64(&m.GetOrgPrivateEndpointConfigMock.expectedInvocations), afterGetOrgPrivateEndpointConfigCounter) + } +} + +type mClientMockGetOrganizationPrivateEndpoints struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockGetOrganizationPrivateEndpointsExpectation + expectations []*ClientMockGetOrganizationPrivateEndpointsExpectation + + expectedInvocations uint64 +} + +// ClientMockGetOrganizationPrivateEndpointsExpectation specifies expectation struct of the Client.GetOrganizationPrivateEndpoints +type ClientMockGetOrganizationPrivateEndpointsExpectation struct { + mock *ClientMock + + results *ClientMockGetOrganizationPrivateEndpointsResults + Counter uint64 +} + +// ClientMockGetOrganizationPrivateEndpointsResults contains results of the Client.GetOrganizationPrivateEndpoints +type ClientMockGetOrganizationPrivateEndpointsResults struct { + pap1 *[]mm_api.PrivateEndpoint + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetOrganizationPrivateEndpoints *mClientMockGetOrganizationPrivateEndpoints) Optional() *mClientMockGetOrganizationPrivateEndpoints { + mmGetOrganizationPrivateEndpoints.optional = true + return mmGetOrganizationPrivateEndpoints +} + +// Expect sets up expected params for Client.GetOrganizationPrivateEndpoints +func (mmGetOrganizationPrivateEndpoints *mClientMockGetOrganizationPrivateEndpoints) Expect() *mClientMockGetOrganizationPrivateEndpoints { + if mmGetOrganizationPrivateEndpoints.mock.funcGetOrganizationPrivateEndpoints != nil { + mmGetOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.GetOrganizationPrivateEndpoints mock is already set by Set") + } + + if mmGetOrganizationPrivateEndpoints.defaultExpectation == nil { + mmGetOrganizationPrivateEndpoints.defaultExpectation = &ClientMockGetOrganizationPrivateEndpointsExpectation{} + } + + return mmGetOrganizationPrivateEndpoints +} + +// Inspect accepts an inspector function that has same arguments as the Client.GetOrganizationPrivateEndpoints +func (mmGetOrganizationPrivateEndpoints *mClientMockGetOrganizationPrivateEndpoints) Inspect(f func()) *mClientMockGetOrganizationPrivateEndpoints { + if mmGetOrganizationPrivateEndpoints.mock.inspectFuncGetOrganizationPrivateEndpoints != nil { + mmGetOrganizationPrivateEndpoints.mock.t.Fatalf("Inspect function is already set for ClientMock.GetOrganizationPrivateEndpoints") + } + + mmGetOrganizationPrivateEndpoints.mock.inspectFuncGetOrganizationPrivateEndpoints = f + + return mmGetOrganizationPrivateEndpoints +} + +// Return sets up results that will be returned by Client.GetOrganizationPrivateEndpoints +func (mmGetOrganizationPrivateEndpoints *mClientMockGetOrganizationPrivateEndpoints) Return(pap1 *[]mm_api.PrivateEndpoint, err error) *ClientMock { + if mmGetOrganizationPrivateEndpoints.mock.funcGetOrganizationPrivateEndpoints != nil { + mmGetOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.GetOrganizationPrivateEndpoints mock is already set by Set") + } + + if mmGetOrganizationPrivateEndpoints.defaultExpectation == nil { + mmGetOrganizationPrivateEndpoints.defaultExpectation = &ClientMockGetOrganizationPrivateEndpointsExpectation{mock: mmGetOrganizationPrivateEndpoints.mock} + } + mmGetOrganizationPrivateEndpoints.defaultExpectation.results = &ClientMockGetOrganizationPrivateEndpointsResults{pap1, err} + return mmGetOrganizationPrivateEndpoints.mock +} + +// Set uses given function f to mock the Client.GetOrganizationPrivateEndpoints method +func (mmGetOrganizationPrivateEndpoints *mClientMockGetOrganizationPrivateEndpoints) Set(f func() (pap1 *[]mm_api.PrivateEndpoint, err error)) *ClientMock { + if mmGetOrganizationPrivateEndpoints.defaultExpectation != nil { + mmGetOrganizationPrivateEndpoints.mock.t.Fatalf("Default expectation is already set for the Client.GetOrganizationPrivateEndpoints method") + } + + if len(mmGetOrganizationPrivateEndpoints.expectations) > 0 { + mmGetOrganizationPrivateEndpoints.mock.t.Fatalf("Some expectations are already set for the Client.GetOrganizationPrivateEndpoints method") + } + + mmGetOrganizationPrivateEndpoints.mock.funcGetOrganizationPrivateEndpoints = f + return mmGetOrganizationPrivateEndpoints.mock +} + +// Times sets number of times Client.GetOrganizationPrivateEndpoints should be invoked +func (mmGetOrganizationPrivateEndpoints *mClientMockGetOrganizationPrivateEndpoints) Times(n uint64) *mClientMockGetOrganizationPrivateEndpoints { + if n == 0 { + mmGetOrganizationPrivateEndpoints.mock.t.Fatalf("Times of ClientMock.GetOrganizationPrivateEndpoints mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetOrganizationPrivateEndpoints.expectedInvocations, n) + return mmGetOrganizationPrivateEndpoints +} + +func (mmGetOrganizationPrivateEndpoints *mClientMockGetOrganizationPrivateEndpoints) invocationsDone() bool { + if len(mmGetOrganizationPrivateEndpoints.expectations) == 0 && mmGetOrganizationPrivateEndpoints.defaultExpectation == nil && mmGetOrganizationPrivateEndpoints.mock.funcGetOrganizationPrivateEndpoints == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetOrganizationPrivateEndpoints.mock.afterGetOrganizationPrivateEndpointsCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetOrganizationPrivateEndpoints.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetOrganizationPrivateEndpoints implements api.Client +func (mmGetOrganizationPrivateEndpoints *ClientMock) GetOrganizationPrivateEndpoints() (pap1 *[]mm_api.PrivateEndpoint, err error) { + mm_atomic.AddUint64(&mmGetOrganizationPrivateEndpoints.beforeGetOrganizationPrivateEndpointsCounter, 1) + defer mm_atomic.AddUint64(&mmGetOrganizationPrivateEndpoints.afterGetOrganizationPrivateEndpointsCounter, 1) + + if mmGetOrganizationPrivateEndpoints.inspectFuncGetOrganizationPrivateEndpoints != nil { + mmGetOrganizationPrivateEndpoints.inspectFuncGetOrganizationPrivateEndpoints() + } + + if mmGetOrganizationPrivateEndpoints.GetOrganizationPrivateEndpointsMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetOrganizationPrivateEndpoints.GetOrganizationPrivateEndpointsMock.defaultExpectation.Counter, 1) + + mm_results := mmGetOrganizationPrivateEndpoints.GetOrganizationPrivateEndpointsMock.defaultExpectation.results + if mm_results == nil { + mmGetOrganizationPrivateEndpoints.t.Fatal("No results are set for the ClientMock.GetOrganizationPrivateEndpoints") + } + return (*mm_results).pap1, (*mm_results).err + } + if mmGetOrganizationPrivateEndpoints.funcGetOrganizationPrivateEndpoints != nil { + return mmGetOrganizationPrivateEndpoints.funcGetOrganizationPrivateEndpoints() + } + mmGetOrganizationPrivateEndpoints.t.Fatalf("Unexpected call to ClientMock.GetOrganizationPrivateEndpoints.") + return +} + +// GetOrganizationPrivateEndpointsAfterCounter returns a count of finished ClientMock.GetOrganizationPrivateEndpoints invocations +func (mmGetOrganizationPrivateEndpoints *ClientMock) GetOrganizationPrivateEndpointsAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetOrganizationPrivateEndpoints.afterGetOrganizationPrivateEndpointsCounter) +} + +// GetOrganizationPrivateEndpointsBeforeCounter returns a count of ClientMock.GetOrganizationPrivateEndpoints invocations +func (mmGetOrganizationPrivateEndpoints *ClientMock) GetOrganizationPrivateEndpointsBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetOrganizationPrivateEndpoints.beforeGetOrganizationPrivateEndpointsCounter) +} + +// MinimockGetOrganizationPrivateEndpointsDone returns true if the count of the GetOrganizationPrivateEndpoints invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockGetOrganizationPrivateEndpointsDone() bool { + if m.GetOrganizationPrivateEndpointsMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetOrganizationPrivateEndpointsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetOrganizationPrivateEndpointsMock.invocationsDone() +} + +// MinimockGetOrganizationPrivateEndpointsInspect logs each unmet expectation +func (m *ClientMock) MinimockGetOrganizationPrivateEndpointsInspect() { + for _, e := range m.GetOrganizationPrivateEndpointsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Error("Expected call to ClientMock.GetOrganizationPrivateEndpoints") + } + } + + afterGetOrganizationPrivateEndpointsCounter := mm_atomic.LoadUint64(&m.afterGetOrganizationPrivateEndpointsCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetOrganizationPrivateEndpointsMock.defaultExpectation != nil && afterGetOrganizationPrivateEndpointsCounter < 1 { + m.t.Error("Expected call to ClientMock.GetOrganizationPrivateEndpoints") + } + // if func was set then invocations count should be greater than zero + if m.funcGetOrganizationPrivateEndpoints != nil && afterGetOrganizationPrivateEndpointsCounter < 1 { + m.t.Error("Expected call to ClientMock.GetOrganizationPrivateEndpoints") + } + + if !m.GetOrganizationPrivateEndpointsMock.invocationsDone() && afterGetOrganizationPrivateEndpointsCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.GetOrganizationPrivateEndpoints but found %d calls", + mm_atomic.LoadUint64(&m.GetOrganizationPrivateEndpointsMock.expectedInvocations), afterGetOrganizationPrivateEndpointsCounter) + } +} + +type mClientMockGetService struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockGetServiceExpectation + expectations []*ClientMockGetServiceExpectation + + callArgs []*ClientMockGetServiceParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockGetServiceExpectation specifies expectation struct of the Client.GetService +type ClientMockGetServiceExpectation struct { + mock *ClientMock + params *ClientMockGetServiceParams + paramPtrs *ClientMockGetServiceParamPtrs + results *ClientMockGetServiceResults + Counter uint64 +} + +// ClientMockGetServiceParams contains parameters of the Client.GetService +type ClientMockGetServiceParams struct { + serviceId string +} + +// ClientMockGetServiceParamPtrs contains pointers to parameters of the Client.GetService +type ClientMockGetServiceParamPtrs struct { + serviceId *string +} + +// ClientMockGetServiceResults contains results of the Client.GetService +type ClientMockGetServiceResults struct { + sp1 *mm_api.Service + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetService *mClientMockGetService) Optional() *mClientMockGetService { + mmGetService.optional = true + return mmGetService +} + +// Expect sets up expected params for Client.GetService +func (mmGetService *mClientMockGetService) Expect(serviceId string) *mClientMockGetService { + if mmGetService.mock.funcGetService != nil { + mmGetService.mock.t.Fatalf("ClientMock.GetService mock is already set by Set") + } + + if mmGetService.defaultExpectation == nil { + mmGetService.defaultExpectation = &ClientMockGetServiceExpectation{} + } + + if mmGetService.defaultExpectation.paramPtrs != nil { + mmGetService.mock.t.Fatalf("ClientMock.GetService mock is already set by ExpectParams functions") + } + + mmGetService.defaultExpectation.params = &ClientMockGetServiceParams{serviceId} + for _, e := range mmGetService.expectations { + if minimock.Equal(e.params, mmGetService.defaultExpectation.params) { + mmGetService.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetService.defaultExpectation.params) + } + } + + return mmGetService +} + +// ExpectServiceIdParam1 sets up expected param serviceId for Client.GetService +func (mmGetService *mClientMockGetService) ExpectServiceIdParam1(serviceId string) *mClientMockGetService { + if mmGetService.mock.funcGetService != nil { + mmGetService.mock.t.Fatalf("ClientMock.GetService mock is already set by Set") + } + + if mmGetService.defaultExpectation == nil { + mmGetService.defaultExpectation = &ClientMockGetServiceExpectation{} + } + + if mmGetService.defaultExpectation.params != nil { + mmGetService.mock.t.Fatalf("ClientMock.GetService mock is already set by Expect") + } + + if mmGetService.defaultExpectation.paramPtrs == nil { + mmGetService.defaultExpectation.paramPtrs = &ClientMockGetServiceParamPtrs{} + } + mmGetService.defaultExpectation.paramPtrs.serviceId = &serviceId + + return mmGetService +} + +// Inspect accepts an inspector function that has same arguments as the Client.GetService +func (mmGetService *mClientMockGetService) Inspect(f func(serviceId string)) *mClientMockGetService { + if mmGetService.mock.inspectFuncGetService != nil { + mmGetService.mock.t.Fatalf("Inspect function is already set for ClientMock.GetService") + } + + mmGetService.mock.inspectFuncGetService = f + + return mmGetService +} + +// Return sets up results that will be returned by Client.GetService +func (mmGetService *mClientMockGetService) Return(sp1 *mm_api.Service, err error) *ClientMock { + if mmGetService.mock.funcGetService != nil { + mmGetService.mock.t.Fatalf("ClientMock.GetService mock is already set by Set") + } + + if mmGetService.defaultExpectation == nil { + mmGetService.defaultExpectation = &ClientMockGetServiceExpectation{mock: mmGetService.mock} + } + mmGetService.defaultExpectation.results = &ClientMockGetServiceResults{sp1, err} + return mmGetService.mock +} + +// Set uses given function f to mock the Client.GetService method +func (mmGetService *mClientMockGetService) Set(f func(serviceId string) (sp1 *mm_api.Service, err error)) *ClientMock { + if mmGetService.defaultExpectation != nil { + mmGetService.mock.t.Fatalf("Default expectation is already set for the Client.GetService method") + } + + if len(mmGetService.expectations) > 0 { + mmGetService.mock.t.Fatalf("Some expectations are already set for the Client.GetService method") + } + + mmGetService.mock.funcGetService = f + return mmGetService.mock +} + +// When sets expectation for the Client.GetService which will trigger the result defined by the following +// Then helper +func (mmGetService *mClientMockGetService) When(serviceId string) *ClientMockGetServiceExpectation { + if mmGetService.mock.funcGetService != nil { + mmGetService.mock.t.Fatalf("ClientMock.GetService mock is already set by Set") + } + + expectation := &ClientMockGetServiceExpectation{ + mock: mmGetService.mock, + params: &ClientMockGetServiceParams{serviceId}, + } + mmGetService.expectations = append(mmGetService.expectations, expectation) + return expectation +} + +// Then sets up Client.GetService return parameters for the expectation previously defined by the When method +func (e *ClientMockGetServiceExpectation) Then(sp1 *mm_api.Service, err error) *ClientMock { + e.results = &ClientMockGetServiceResults{sp1, err} + return e.mock +} + +// Times sets number of times Client.GetService should be invoked +func (mmGetService *mClientMockGetService) Times(n uint64) *mClientMockGetService { + if n == 0 { + mmGetService.mock.t.Fatalf("Times of ClientMock.GetService mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetService.expectedInvocations, n) + return mmGetService +} + +func (mmGetService *mClientMockGetService) invocationsDone() bool { + if len(mmGetService.expectations) == 0 && mmGetService.defaultExpectation == nil && mmGetService.mock.funcGetService == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetService.mock.afterGetServiceCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetService.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetService implements api.Client +func (mmGetService *ClientMock) GetService(serviceId string) (sp1 *mm_api.Service, err error) { + mm_atomic.AddUint64(&mmGetService.beforeGetServiceCounter, 1) + defer mm_atomic.AddUint64(&mmGetService.afterGetServiceCounter, 1) + + if mmGetService.inspectFuncGetService != nil { + mmGetService.inspectFuncGetService(serviceId) + } + + mm_params := ClientMockGetServiceParams{serviceId} + + // Record call args + mmGetService.GetServiceMock.mutex.Lock() + mmGetService.GetServiceMock.callArgs = append(mmGetService.GetServiceMock.callArgs, &mm_params) + mmGetService.GetServiceMock.mutex.Unlock() + + for _, e := range mmGetService.GetServiceMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.err + } + } + + if mmGetService.GetServiceMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetService.GetServiceMock.defaultExpectation.Counter, 1) + mm_want := mmGetService.GetServiceMock.defaultExpectation.params + mm_want_ptrs := mmGetService.GetServiceMock.defaultExpectation.paramPtrs + + mm_got := ClientMockGetServiceParams{serviceId} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.serviceId != nil && !minimock.Equal(*mm_want_ptrs.serviceId, mm_got.serviceId) { + mmGetService.t.Errorf("ClientMock.GetService got unexpected parameter serviceId, want: %#v, got: %#v%s\n", *mm_want_ptrs.serviceId, mm_got.serviceId, minimock.Diff(*mm_want_ptrs.serviceId, mm_got.serviceId)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetService.t.Errorf("ClientMock.GetService got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetService.GetServiceMock.defaultExpectation.results + if mm_results == nil { + mmGetService.t.Fatal("No results are set for the ClientMock.GetService") + } + return (*mm_results).sp1, (*mm_results).err + } + if mmGetService.funcGetService != nil { + return mmGetService.funcGetService(serviceId) + } + mmGetService.t.Fatalf("Unexpected call to ClientMock.GetService. %v", serviceId) + return +} + +// GetServiceAfterCounter returns a count of finished ClientMock.GetService invocations +func (mmGetService *ClientMock) GetServiceAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetService.afterGetServiceCounter) +} + +// GetServiceBeforeCounter returns a count of ClientMock.GetService invocations +func (mmGetService *ClientMock) GetServiceBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetService.beforeGetServiceCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.GetService. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetService *mClientMockGetService) Calls() []*ClientMockGetServiceParams { + mmGetService.mutex.RLock() + + argCopy := make([]*ClientMockGetServiceParams, len(mmGetService.callArgs)) + copy(argCopy, mmGetService.callArgs) + + mmGetService.mutex.RUnlock() + + return argCopy +} + +// MinimockGetServiceDone returns true if the count of the GetService invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockGetServiceDone() bool { + if m.GetServiceMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetServiceMock.invocationsDone() +} + +// MinimockGetServiceInspect logs each unmet expectation +func (m *ClientMock) MinimockGetServiceInspect() { + for _, e := range m.GetServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.GetService with params: %#v", *e.params) + } + } + + afterGetServiceCounter := mm_atomic.LoadUint64(&m.afterGetServiceCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetServiceMock.defaultExpectation != nil && afterGetServiceCounter < 1 { + if m.GetServiceMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.GetService") + } else { + m.t.Errorf("Expected call to ClientMock.GetService with params: %#v", *m.GetServiceMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetService != nil && afterGetServiceCounter < 1 { + m.t.Error("Expected call to ClientMock.GetService") + } + + if !m.GetServiceMock.invocationsDone() && afterGetServiceCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.GetService but found %d calls", + mm_atomic.LoadUint64(&m.GetServiceMock.expectedInvocations), afterGetServiceCounter) + } +} + +type mClientMockGetServiceStatusCode struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockGetServiceStatusCodeExpectation + expectations []*ClientMockGetServiceStatusCodeExpectation + + callArgs []*ClientMockGetServiceStatusCodeParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockGetServiceStatusCodeExpectation specifies expectation struct of the Client.GetServiceStatusCode +type ClientMockGetServiceStatusCodeExpectation struct { + mock *ClientMock + params *ClientMockGetServiceStatusCodeParams + paramPtrs *ClientMockGetServiceStatusCodeParamPtrs + results *ClientMockGetServiceStatusCodeResults + Counter uint64 +} + +// ClientMockGetServiceStatusCodeParams contains parameters of the Client.GetServiceStatusCode +type ClientMockGetServiceStatusCodeParams struct { + serviceId string +} + +// ClientMockGetServiceStatusCodeParamPtrs contains pointers to parameters of the Client.GetServiceStatusCode +type ClientMockGetServiceStatusCodeParamPtrs struct { + serviceId *string +} + +// ClientMockGetServiceStatusCodeResults contains results of the Client.GetServiceStatusCode +type ClientMockGetServiceStatusCodeResults struct { + ip1 *int + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) Optional() *mClientMockGetServiceStatusCode { + mmGetServiceStatusCode.optional = true + return mmGetServiceStatusCode +} + +// Expect sets up expected params for Client.GetServiceStatusCode +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) Expect(serviceId string) *mClientMockGetServiceStatusCode { + if mmGetServiceStatusCode.mock.funcGetServiceStatusCode != nil { + mmGetServiceStatusCode.mock.t.Fatalf("ClientMock.GetServiceStatusCode mock is already set by Set") + } + + if mmGetServiceStatusCode.defaultExpectation == nil { + mmGetServiceStatusCode.defaultExpectation = &ClientMockGetServiceStatusCodeExpectation{} + } + + if mmGetServiceStatusCode.defaultExpectation.paramPtrs != nil { + mmGetServiceStatusCode.mock.t.Fatalf("ClientMock.GetServiceStatusCode mock is already set by ExpectParams functions") + } + + mmGetServiceStatusCode.defaultExpectation.params = &ClientMockGetServiceStatusCodeParams{serviceId} + for _, e := range mmGetServiceStatusCode.expectations { + if minimock.Equal(e.params, mmGetServiceStatusCode.defaultExpectation.params) { + mmGetServiceStatusCode.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetServiceStatusCode.defaultExpectation.params) + } + } + + return mmGetServiceStatusCode +} + +// ExpectServiceIdParam1 sets up expected param serviceId for Client.GetServiceStatusCode +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) ExpectServiceIdParam1(serviceId string) *mClientMockGetServiceStatusCode { + if mmGetServiceStatusCode.mock.funcGetServiceStatusCode != nil { + mmGetServiceStatusCode.mock.t.Fatalf("ClientMock.GetServiceStatusCode mock is already set by Set") + } + + if mmGetServiceStatusCode.defaultExpectation == nil { + mmGetServiceStatusCode.defaultExpectation = &ClientMockGetServiceStatusCodeExpectation{} + } + + if mmGetServiceStatusCode.defaultExpectation.params != nil { + mmGetServiceStatusCode.mock.t.Fatalf("ClientMock.GetServiceStatusCode mock is already set by Expect") + } + + if mmGetServiceStatusCode.defaultExpectation.paramPtrs == nil { + mmGetServiceStatusCode.defaultExpectation.paramPtrs = &ClientMockGetServiceStatusCodeParamPtrs{} + } + mmGetServiceStatusCode.defaultExpectation.paramPtrs.serviceId = &serviceId + + return mmGetServiceStatusCode +} + +// Inspect accepts an inspector function that has same arguments as the Client.GetServiceStatusCode +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) Inspect(f func(serviceId string)) *mClientMockGetServiceStatusCode { + if mmGetServiceStatusCode.mock.inspectFuncGetServiceStatusCode != nil { + mmGetServiceStatusCode.mock.t.Fatalf("Inspect function is already set for ClientMock.GetServiceStatusCode") + } + + mmGetServiceStatusCode.mock.inspectFuncGetServiceStatusCode = f + + return mmGetServiceStatusCode +} + +// Return sets up results that will be returned by Client.GetServiceStatusCode +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) Return(ip1 *int, err error) *ClientMock { + if mmGetServiceStatusCode.mock.funcGetServiceStatusCode != nil { + mmGetServiceStatusCode.mock.t.Fatalf("ClientMock.GetServiceStatusCode mock is already set by Set") + } + + if mmGetServiceStatusCode.defaultExpectation == nil { + mmGetServiceStatusCode.defaultExpectation = &ClientMockGetServiceStatusCodeExpectation{mock: mmGetServiceStatusCode.mock} + } + mmGetServiceStatusCode.defaultExpectation.results = &ClientMockGetServiceStatusCodeResults{ip1, err} + return mmGetServiceStatusCode.mock +} + +// Set uses given function f to mock the Client.GetServiceStatusCode method +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) Set(f func(serviceId string) (ip1 *int, err error)) *ClientMock { + if mmGetServiceStatusCode.defaultExpectation != nil { + mmGetServiceStatusCode.mock.t.Fatalf("Default expectation is already set for the Client.GetServiceStatusCode method") + } + + if len(mmGetServiceStatusCode.expectations) > 0 { + mmGetServiceStatusCode.mock.t.Fatalf("Some expectations are already set for the Client.GetServiceStatusCode method") + } + + mmGetServiceStatusCode.mock.funcGetServiceStatusCode = f + return mmGetServiceStatusCode.mock +} + +// When sets expectation for the Client.GetServiceStatusCode which will trigger the result defined by the following +// Then helper +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) When(serviceId string) *ClientMockGetServiceStatusCodeExpectation { + if mmGetServiceStatusCode.mock.funcGetServiceStatusCode != nil { + mmGetServiceStatusCode.mock.t.Fatalf("ClientMock.GetServiceStatusCode mock is already set by Set") + } + + expectation := &ClientMockGetServiceStatusCodeExpectation{ + mock: mmGetServiceStatusCode.mock, + params: &ClientMockGetServiceStatusCodeParams{serviceId}, + } + mmGetServiceStatusCode.expectations = append(mmGetServiceStatusCode.expectations, expectation) + return expectation +} + +// Then sets up Client.GetServiceStatusCode return parameters for the expectation previously defined by the When method +func (e *ClientMockGetServiceStatusCodeExpectation) Then(ip1 *int, err error) *ClientMock { + e.results = &ClientMockGetServiceStatusCodeResults{ip1, err} + return e.mock +} + +// Times sets number of times Client.GetServiceStatusCode should be invoked +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) Times(n uint64) *mClientMockGetServiceStatusCode { + if n == 0 { + mmGetServiceStatusCode.mock.t.Fatalf("Times of ClientMock.GetServiceStatusCode mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetServiceStatusCode.expectedInvocations, n) + return mmGetServiceStatusCode +} + +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) invocationsDone() bool { + if len(mmGetServiceStatusCode.expectations) == 0 && mmGetServiceStatusCode.defaultExpectation == nil && mmGetServiceStatusCode.mock.funcGetServiceStatusCode == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetServiceStatusCode.mock.afterGetServiceStatusCodeCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetServiceStatusCode.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetServiceStatusCode implements api.Client +func (mmGetServiceStatusCode *ClientMock) GetServiceStatusCode(serviceId string) (ip1 *int, err error) { + mm_atomic.AddUint64(&mmGetServiceStatusCode.beforeGetServiceStatusCodeCounter, 1) + defer mm_atomic.AddUint64(&mmGetServiceStatusCode.afterGetServiceStatusCodeCounter, 1) + + if mmGetServiceStatusCode.inspectFuncGetServiceStatusCode != nil { + mmGetServiceStatusCode.inspectFuncGetServiceStatusCode(serviceId) + } + + mm_params := ClientMockGetServiceStatusCodeParams{serviceId} + + // Record call args + mmGetServiceStatusCode.GetServiceStatusCodeMock.mutex.Lock() + mmGetServiceStatusCode.GetServiceStatusCodeMock.callArgs = append(mmGetServiceStatusCode.GetServiceStatusCodeMock.callArgs, &mm_params) + mmGetServiceStatusCode.GetServiceStatusCodeMock.mutex.Unlock() + + for _, e := range mmGetServiceStatusCode.GetServiceStatusCodeMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ip1, e.results.err + } + } + + if mmGetServiceStatusCode.GetServiceStatusCodeMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetServiceStatusCode.GetServiceStatusCodeMock.defaultExpectation.Counter, 1) + mm_want := mmGetServiceStatusCode.GetServiceStatusCodeMock.defaultExpectation.params + mm_want_ptrs := mmGetServiceStatusCode.GetServiceStatusCodeMock.defaultExpectation.paramPtrs + + mm_got := ClientMockGetServiceStatusCodeParams{serviceId} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.serviceId != nil && !minimock.Equal(*mm_want_ptrs.serviceId, mm_got.serviceId) { + mmGetServiceStatusCode.t.Errorf("ClientMock.GetServiceStatusCode got unexpected parameter serviceId, want: %#v, got: %#v%s\n", *mm_want_ptrs.serviceId, mm_got.serviceId, minimock.Diff(*mm_want_ptrs.serviceId, mm_got.serviceId)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetServiceStatusCode.t.Errorf("ClientMock.GetServiceStatusCode got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetServiceStatusCode.GetServiceStatusCodeMock.defaultExpectation.results + if mm_results == nil { + mmGetServiceStatusCode.t.Fatal("No results are set for the ClientMock.GetServiceStatusCode") + } + return (*mm_results).ip1, (*mm_results).err + } + if mmGetServiceStatusCode.funcGetServiceStatusCode != nil { + return mmGetServiceStatusCode.funcGetServiceStatusCode(serviceId) + } + mmGetServiceStatusCode.t.Fatalf("Unexpected call to ClientMock.GetServiceStatusCode. %v", serviceId) + return +} + +// GetServiceStatusCodeAfterCounter returns a count of finished ClientMock.GetServiceStatusCode invocations +func (mmGetServiceStatusCode *ClientMock) GetServiceStatusCodeAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetServiceStatusCode.afterGetServiceStatusCodeCounter) +} + +// GetServiceStatusCodeBeforeCounter returns a count of ClientMock.GetServiceStatusCode invocations +func (mmGetServiceStatusCode *ClientMock) GetServiceStatusCodeBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetServiceStatusCode.beforeGetServiceStatusCodeCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.GetServiceStatusCode. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetServiceStatusCode *mClientMockGetServiceStatusCode) Calls() []*ClientMockGetServiceStatusCodeParams { + mmGetServiceStatusCode.mutex.RLock() + + argCopy := make([]*ClientMockGetServiceStatusCodeParams, len(mmGetServiceStatusCode.callArgs)) + copy(argCopy, mmGetServiceStatusCode.callArgs) + + mmGetServiceStatusCode.mutex.RUnlock() + + return argCopy +} + +// MinimockGetServiceStatusCodeDone returns true if the count of the GetServiceStatusCode invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockGetServiceStatusCodeDone() bool { + if m.GetServiceStatusCodeMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetServiceStatusCodeMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetServiceStatusCodeMock.invocationsDone() +} + +// MinimockGetServiceStatusCodeInspect logs each unmet expectation +func (m *ClientMock) MinimockGetServiceStatusCodeInspect() { + for _, e := range m.GetServiceStatusCodeMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.GetServiceStatusCode with params: %#v", *e.params) + } + } + + afterGetServiceStatusCodeCounter := mm_atomic.LoadUint64(&m.afterGetServiceStatusCodeCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetServiceStatusCodeMock.defaultExpectation != nil && afterGetServiceStatusCodeCounter < 1 { + if m.GetServiceStatusCodeMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.GetServiceStatusCode") + } else { + m.t.Errorf("Expected call to ClientMock.GetServiceStatusCode with params: %#v", *m.GetServiceStatusCodeMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetServiceStatusCode != nil && afterGetServiceStatusCodeCounter < 1 { + m.t.Error("Expected call to ClientMock.GetServiceStatusCode") + } + + if !m.GetServiceStatusCodeMock.invocationsDone() && afterGetServiceStatusCodeCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.GetServiceStatusCode but found %d calls", + mm_atomic.LoadUint64(&m.GetServiceStatusCodeMock.expectedInvocations), afterGetServiceStatusCodeCounter) + } +} + +type mClientMockUpdateOrganizationPrivateEndpoints struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockUpdateOrganizationPrivateEndpointsExpectation + expectations []*ClientMockUpdateOrganizationPrivateEndpointsExpectation + + callArgs []*ClientMockUpdateOrganizationPrivateEndpointsParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockUpdateOrganizationPrivateEndpointsExpectation specifies expectation struct of the Client.UpdateOrganizationPrivateEndpoints +type ClientMockUpdateOrganizationPrivateEndpointsExpectation struct { + mock *ClientMock + params *ClientMockUpdateOrganizationPrivateEndpointsParams + paramPtrs *ClientMockUpdateOrganizationPrivateEndpointsParamPtrs + results *ClientMockUpdateOrganizationPrivateEndpointsResults + Counter uint64 +} + +// ClientMockUpdateOrganizationPrivateEndpointsParams contains parameters of the Client.UpdateOrganizationPrivateEndpoints +type ClientMockUpdateOrganizationPrivateEndpointsParams struct { + orgUpdate mm_api.OrganizationUpdate +} + +// ClientMockUpdateOrganizationPrivateEndpointsParamPtrs contains pointers to parameters of the Client.UpdateOrganizationPrivateEndpoints +type ClientMockUpdateOrganizationPrivateEndpointsParamPtrs struct { + orgUpdate *mm_api.OrganizationUpdate +} + +// ClientMockUpdateOrganizationPrivateEndpointsResults contains results of the Client.UpdateOrganizationPrivateEndpoints +type ClientMockUpdateOrganizationPrivateEndpointsResults struct { + pap1 *[]mm_api.PrivateEndpoint + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) Optional() *mClientMockUpdateOrganizationPrivateEndpoints { + mmUpdateOrganizationPrivateEndpoints.optional = true + return mmUpdateOrganizationPrivateEndpoints +} + +// Expect sets up expected params for Client.UpdateOrganizationPrivateEndpoints +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) Expect(orgUpdate mm_api.OrganizationUpdate) *mClientMockUpdateOrganizationPrivateEndpoints { + if mmUpdateOrganizationPrivateEndpoints.mock.funcUpdateOrganizationPrivateEndpoints != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.UpdateOrganizationPrivateEndpoints mock is already set by Set") + } + + if mmUpdateOrganizationPrivateEndpoints.defaultExpectation == nil { + mmUpdateOrganizationPrivateEndpoints.defaultExpectation = &ClientMockUpdateOrganizationPrivateEndpointsExpectation{} + } + + if mmUpdateOrganizationPrivateEndpoints.defaultExpectation.paramPtrs != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.UpdateOrganizationPrivateEndpoints mock is already set by ExpectParams functions") + } + + mmUpdateOrganizationPrivateEndpoints.defaultExpectation.params = &ClientMockUpdateOrganizationPrivateEndpointsParams{orgUpdate} + for _, e := range mmUpdateOrganizationPrivateEndpoints.expectations { + if minimock.Equal(e.params, mmUpdateOrganizationPrivateEndpoints.defaultExpectation.params) { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateOrganizationPrivateEndpoints.defaultExpectation.params) + } + } + + return mmUpdateOrganizationPrivateEndpoints +} + +// ExpectOrgUpdateParam1 sets up expected param orgUpdate for Client.UpdateOrganizationPrivateEndpoints +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) ExpectOrgUpdateParam1(orgUpdate mm_api.OrganizationUpdate) *mClientMockUpdateOrganizationPrivateEndpoints { + if mmUpdateOrganizationPrivateEndpoints.mock.funcUpdateOrganizationPrivateEndpoints != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.UpdateOrganizationPrivateEndpoints mock is already set by Set") + } + + if mmUpdateOrganizationPrivateEndpoints.defaultExpectation == nil { + mmUpdateOrganizationPrivateEndpoints.defaultExpectation = &ClientMockUpdateOrganizationPrivateEndpointsExpectation{} + } + + if mmUpdateOrganizationPrivateEndpoints.defaultExpectation.params != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.UpdateOrganizationPrivateEndpoints mock is already set by Expect") + } + + if mmUpdateOrganizationPrivateEndpoints.defaultExpectation.paramPtrs == nil { + mmUpdateOrganizationPrivateEndpoints.defaultExpectation.paramPtrs = &ClientMockUpdateOrganizationPrivateEndpointsParamPtrs{} + } + mmUpdateOrganizationPrivateEndpoints.defaultExpectation.paramPtrs.orgUpdate = &orgUpdate + + return mmUpdateOrganizationPrivateEndpoints +} + +// Inspect accepts an inspector function that has same arguments as the Client.UpdateOrganizationPrivateEndpoints +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) Inspect(f func(orgUpdate mm_api.OrganizationUpdate)) *mClientMockUpdateOrganizationPrivateEndpoints { + if mmUpdateOrganizationPrivateEndpoints.mock.inspectFuncUpdateOrganizationPrivateEndpoints != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("Inspect function is already set for ClientMock.UpdateOrganizationPrivateEndpoints") + } + + mmUpdateOrganizationPrivateEndpoints.mock.inspectFuncUpdateOrganizationPrivateEndpoints = f + + return mmUpdateOrganizationPrivateEndpoints +} + +// Return sets up results that will be returned by Client.UpdateOrganizationPrivateEndpoints +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) Return(pap1 *[]mm_api.PrivateEndpoint, err error) *ClientMock { + if mmUpdateOrganizationPrivateEndpoints.mock.funcUpdateOrganizationPrivateEndpoints != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.UpdateOrganizationPrivateEndpoints mock is already set by Set") + } + + if mmUpdateOrganizationPrivateEndpoints.defaultExpectation == nil { + mmUpdateOrganizationPrivateEndpoints.defaultExpectation = &ClientMockUpdateOrganizationPrivateEndpointsExpectation{mock: mmUpdateOrganizationPrivateEndpoints.mock} + } + mmUpdateOrganizationPrivateEndpoints.defaultExpectation.results = &ClientMockUpdateOrganizationPrivateEndpointsResults{pap1, err} + return mmUpdateOrganizationPrivateEndpoints.mock +} + +// Set uses given function f to mock the Client.UpdateOrganizationPrivateEndpoints method +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) Set(f func(orgUpdate mm_api.OrganizationUpdate) (pap1 *[]mm_api.PrivateEndpoint, err error)) *ClientMock { + if mmUpdateOrganizationPrivateEndpoints.defaultExpectation != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("Default expectation is already set for the Client.UpdateOrganizationPrivateEndpoints method") + } + + if len(mmUpdateOrganizationPrivateEndpoints.expectations) > 0 { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("Some expectations are already set for the Client.UpdateOrganizationPrivateEndpoints method") + } + + mmUpdateOrganizationPrivateEndpoints.mock.funcUpdateOrganizationPrivateEndpoints = f + return mmUpdateOrganizationPrivateEndpoints.mock +} + +// When sets expectation for the Client.UpdateOrganizationPrivateEndpoints which will trigger the result defined by the following +// Then helper +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) When(orgUpdate mm_api.OrganizationUpdate) *ClientMockUpdateOrganizationPrivateEndpointsExpectation { + if mmUpdateOrganizationPrivateEndpoints.mock.funcUpdateOrganizationPrivateEndpoints != nil { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("ClientMock.UpdateOrganizationPrivateEndpoints mock is already set by Set") + } + + expectation := &ClientMockUpdateOrganizationPrivateEndpointsExpectation{ + mock: mmUpdateOrganizationPrivateEndpoints.mock, + params: &ClientMockUpdateOrganizationPrivateEndpointsParams{orgUpdate}, + } + mmUpdateOrganizationPrivateEndpoints.expectations = append(mmUpdateOrganizationPrivateEndpoints.expectations, expectation) + return expectation +} + +// Then sets up Client.UpdateOrganizationPrivateEndpoints return parameters for the expectation previously defined by the When method +func (e *ClientMockUpdateOrganizationPrivateEndpointsExpectation) Then(pap1 *[]mm_api.PrivateEndpoint, err error) *ClientMock { + e.results = &ClientMockUpdateOrganizationPrivateEndpointsResults{pap1, err} + return e.mock +} + +// Times sets number of times Client.UpdateOrganizationPrivateEndpoints should be invoked +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) Times(n uint64) *mClientMockUpdateOrganizationPrivateEndpoints { + if n == 0 { + mmUpdateOrganizationPrivateEndpoints.mock.t.Fatalf("Times of ClientMock.UpdateOrganizationPrivateEndpoints mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateOrganizationPrivateEndpoints.expectedInvocations, n) + return mmUpdateOrganizationPrivateEndpoints +} + +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) invocationsDone() bool { + if len(mmUpdateOrganizationPrivateEndpoints.expectations) == 0 && mmUpdateOrganizationPrivateEndpoints.defaultExpectation == nil && mmUpdateOrganizationPrivateEndpoints.mock.funcUpdateOrganizationPrivateEndpoints == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateOrganizationPrivateEndpoints.mock.afterUpdateOrganizationPrivateEndpointsCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateOrganizationPrivateEndpoints.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateOrganizationPrivateEndpoints implements api.Client +func (mmUpdateOrganizationPrivateEndpoints *ClientMock) UpdateOrganizationPrivateEndpoints(orgUpdate mm_api.OrganizationUpdate) (pap1 *[]mm_api.PrivateEndpoint, err error) { + mm_atomic.AddUint64(&mmUpdateOrganizationPrivateEndpoints.beforeUpdateOrganizationPrivateEndpointsCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateOrganizationPrivateEndpoints.afterUpdateOrganizationPrivateEndpointsCounter, 1) + + if mmUpdateOrganizationPrivateEndpoints.inspectFuncUpdateOrganizationPrivateEndpoints != nil { + mmUpdateOrganizationPrivateEndpoints.inspectFuncUpdateOrganizationPrivateEndpoints(orgUpdate) + } + + mm_params := ClientMockUpdateOrganizationPrivateEndpointsParams{orgUpdate} + + // Record call args + mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.mutex.Lock() + mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.callArgs = append(mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.callArgs, &mm_params) + mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.mutex.Unlock() + + for _, e := range mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.pap1, e.results.err + } + } + + if mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.defaultExpectation.params + mm_want_ptrs := mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.defaultExpectation.paramPtrs + + mm_got := ClientMockUpdateOrganizationPrivateEndpointsParams{orgUpdate} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.orgUpdate != nil && !minimock.Equal(*mm_want_ptrs.orgUpdate, mm_got.orgUpdate) { + mmUpdateOrganizationPrivateEndpoints.t.Errorf("ClientMock.UpdateOrganizationPrivateEndpoints got unexpected parameter orgUpdate, want: %#v, got: %#v%s\n", *mm_want_ptrs.orgUpdate, mm_got.orgUpdate, minimock.Diff(*mm_want_ptrs.orgUpdate, mm_got.orgUpdate)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateOrganizationPrivateEndpoints.t.Errorf("ClientMock.UpdateOrganizationPrivateEndpoints got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateOrganizationPrivateEndpoints.UpdateOrganizationPrivateEndpointsMock.defaultExpectation.results + if mm_results == nil { + mmUpdateOrganizationPrivateEndpoints.t.Fatal("No results are set for the ClientMock.UpdateOrganizationPrivateEndpoints") + } + return (*mm_results).pap1, (*mm_results).err + } + if mmUpdateOrganizationPrivateEndpoints.funcUpdateOrganizationPrivateEndpoints != nil { + return mmUpdateOrganizationPrivateEndpoints.funcUpdateOrganizationPrivateEndpoints(orgUpdate) + } + mmUpdateOrganizationPrivateEndpoints.t.Fatalf("Unexpected call to ClientMock.UpdateOrganizationPrivateEndpoints. %v", orgUpdate) + return +} + +// UpdateOrganizationPrivateEndpointsAfterCounter returns a count of finished ClientMock.UpdateOrganizationPrivateEndpoints invocations +func (mmUpdateOrganizationPrivateEndpoints *ClientMock) UpdateOrganizationPrivateEndpointsAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateOrganizationPrivateEndpoints.afterUpdateOrganizationPrivateEndpointsCounter) +} + +// UpdateOrganizationPrivateEndpointsBeforeCounter returns a count of ClientMock.UpdateOrganizationPrivateEndpoints invocations +func (mmUpdateOrganizationPrivateEndpoints *ClientMock) UpdateOrganizationPrivateEndpointsBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateOrganizationPrivateEndpoints.beforeUpdateOrganizationPrivateEndpointsCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.UpdateOrganizationPrivateEndpoints. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateOrganizationPrivateEndpoints *mClientMockUpdateOrganizationPrivateEndpoints) Calls() []*ClientMockUpdateOrganizationPrivateEndpointsParams { + mmUpdateOrganizationPrivateEndpoints.mutex.RLock() + + argCopy := make([]*ClientMockUpdateOrganizationPrivateEndpointsParams, len(mmUpdateOrganizationPrivateEndpoints.callArgs)) + copy(argCopy, mmUpdateOrganizationPrivateEndpoints.callArgs) + + mmUpdateOrganizationPrivateEndpoints.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateOrganizationPrivateEndpointsDone returns true if the count of the UpdateOrganizationPrivateEndpoints invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockUpdateOrganizationPrivateEndpointsDone() bool { + if m.UpdateOrganizationPrivateEndpointsMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateOrganizationPrivateEndpointsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateOrganizationPrivateEndpointsMock.invocationsDone() +} + +// MinimockUpdateOrganizationPrivateEndpointsInspect logs each unmet expectation +func (m *ClientMock) MinimockUpdateOrganizationPrivateEndpointsInspect() { + for _, e := range m.UpdateOrganizationPrivateEndpointsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.UpdateOrganizationPrivateEndpoints with params: %#v", *e.params) + } + } + + afterUpdateOrganizationPrivateEndpointsCounter := mm_atomic.LoadUint64(&m.afterUpdateOrganizationPrivateEndpointsCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateOrganizationPrivateEndpointsMock.defaultExpectation != nil && afterUpdateOrganizationPrivateEndpointsCounter < 1 { + if m.UpdateOrganizationPrivateEndpointsMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.UpdateOrganizationPrivateEndpoints") + } else { + m.t.Errorf("Expected call to ClientMock.UpdateOrganizationPrivateEndpoints with params: %#v", *m.UpdateOrganizationPrivateEndpointsMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateOrganizationPrivateEndpoints != nil && afterUpdateOrganizationPrivateEndpointsCounter < 1 { + m.t.Error("Expected call to ClientMock.UpdateOrganizationPrivateEndpoints") + } + + if !m.UpdateOrganizationPrivateEndpointsMock.invocationsDone() && afterUpdateOrganizationPrivateEndpointsCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.UpdateOrganizationPrivateEndpoints but found %d calls", + mm_atomic.LoadUint64(&m.UpdateOrganizationPrivateEndpointsMock.expectedInvocations), afterUpdateOrganizationPrivateEndpointsCounter) + } +} + +type mClientMockUpdateService struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockUpdateServiceExpectation + expectations []*ClientMockUpdateServiceExpectation + + callArgs []*ClientMockUpdateServiceParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockUpdateServiceExpectation specifies expectation struct of the Client.UpdateService +type ClientMockUpdateServiceExpectation struct { + mock *ClientMock + params *ClientMockUpdateServiceParams + paramPtrs *ClientMockUpdateServiceParamPtrs + results *ClientMockUpdateServiceResults + Counter uint64 +} + +// ClientMockUpdateServiceParams contains parameters of the Client.UpdateService +type ClientMockUpdateServiceParams struct { + serviceId string + s mm_api.ServiceUpdate +} + +// ClientMockUpdateServiceParamPtrs contains pointers to parameters of the Client.UpdateService +type ClientMockUpdateServiceParamPtrs struct { + serviceId *string + s *mm_api.ServiceUpdate +} + +// ClientMockUpdateServiceResults contains results of the Client.UpdateService +type ClientMockUpdateServiceResults struct { + sp1 *mm_api.Service + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateService *mClientMockUpdateService) Optional() *mClientMockUpdateService { + mmUpdateService.optional = true + return mmUpdateService +} + +// Expect sets up expected params for Client.UpdateService +func (mmUpdateService *mClientMockUpdateService) Expect(serviceId string, s mm_api.ServiceUpdate) *mClientMockUpdateService { + if mmUpdateService.mock.funcUpdateService != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by Set") + } + + if mmUpdateService.defaultExpectation == nil { + mmUpdateService.defaultExpectation = &ClientMockUpdateServiceExpectation{} + } + + if mmUpdateService.defaultExpectation.paramPtrs != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by ExpectParams functions") + } + + mmUpdateService.defaultExpectation.params = &ClientMockUpdateServiceParams{serviceId, s} + for _, e := range mmUpdateService.expectations { + if minimock.Equal(e.params, mmUpdateService.defaultExpectation.params) { + mmUpdateService.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateService.defaultExpectation.params) + } + } + + return mmUpdateService +} + +// ExpectServiceIdParam1 sets up expected param serviceId for Client.UpdateService +func (mmUpdateService *mClientMockUpdateService) ExpectServiceIdParam1(serviceId string) *mClientMockUpdateService { + if mmUpdateService.mock.funcUpdateService != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by Set") + } + + if mmUpdateService.defaultExpectation == nil { + mmUpdateService.defaultExpectation = &ClientMockUpdateServiceExpectation{} + } + + if mmUpdateService.defaultExpectation.params != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by Expect") + } + + if mmUpdateService.defaultExpectation.paramPtrs == nil { + mmUpdateService.defaultExpectation.paramPtrs = &ClientMockUpdateServiceParamPtrs{} + } + mmUpdateService.defaultExpectation.paramPtrs.serviceId = &serviceId + + return mmUpdateService +} + +// ExpectSParam2 sets up expected param s for Client.UpdateService +func (mmUpdateService *mClientMockUpdateService) ExpectSParam2(s mm_api.ServiceUpdate) *mClientMockUpdateService { + if mmUpdateService.mock.funcUpdateService != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by Set") + } + + if mmUpdateService.defaultExpectation == nil { + mmUpdateService.defaultExpectation = &ClientMockUpdateServiceExpectation{} + } + + if mmUpdateService.defaultExpectation.params != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by Expect") + } + + if mmUpdateService.defaultExpectation.paramPtrs == nil { + mmUpdateService.defaultExpectation.paramPtrs = &ClientMockUpdateServiceParamPtrs{} + } + mmUpdateService.defaultExpectation.paramPtrs.s = &s + + return mmUpdateService +} + +// Inspect accepts an inspector function that has same arguments as the Client.UpdateService +func (mmUpdateService *mClientMockUpdateService) Inspect(f func(serviceId string, s mm_api.ServiceUpdate)) *mClientMockUpdateService { + if mmUpdateService.mock.inspectFuncUpdateService != nil { + mmUpdateService.mock.t.Fatalf("Inspect function is already set for ClientMock.UpdateService") + } + + mmUpdateService.mock.inspectFuncUpdateService = f + + return mmUpdateService +} + +// Return sets up results that will be returned by Client.UpdateService +func (mmUpdateService *mClientMockUpdateService) Return(sp1 *mm_api.Service, err error) *ClientMock { + if mmUpdateService.mock.funcUpdateService != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by Set") + } + + if mmUpdateService.defaultExpectation == nil { + mmUpdateService.defaultExpectation = &ClientMockUpdateServiceExpectation{mock: mmUpdateService.mock} + } + mmUpdateService.defaultExpectation.results = &ClientMockUpdateServiceResults{sp1, err} + return mmUpdateService.mock +} + +// Set uses given function f to mock the Client.UpdateService method +func (mmUpdateService *mClientMockUpdateService) Set(f func(serviceId string, s mm_api.ServiceUpdate) (sp1 *mm_api.Service, err error)) *ClientMock { + if mmUpdateService.defaultExpectation != nil { + mmUpdateService.mock.t.Fatalf("Default expectation is already set for the Client.UpdateService method") + } + + if len(mmUpdateService.expectations) > 0 { + mmUpdateService.mock.t.Fatalf("Some expectations are already set for the Client.UpdateService method") + } + + mmUpdateService.mock.funcUpdateService = f + return mmUpdateService.mock +} + +// When sets expectation for the Client.UpdateService which will trigger the result defined by the following +// Then helper +func (mmUpdateService *mClientMockUpdateService) When(serviceId string, s mm_api.ServiceUpdate) *ClientMockUpdateServiceExpectation { + if mmUpdateService.mock.funcUpdateService != nil { + mmUpdateService.mock.t.Fatalf("ClientMock.UpdateService mock is already set by Set") + } + + expectation := &ClientMockUpdateServiceExpectation{ + mock: mmUpdateService.mock, + params: &ClientMockUpdateServiceParams{serviceId, s}, + } + mmUpdateService.expectations = append(mmUpdateService.expectations, expectation) + return expectation +} + +// Then sets up Client.UpdateService return parameters for the expectation previously defined by the When method +func (e *ClientMockUpdateServiceExpectation) Then(sp1 *mm_api.Service, err error) *ClientMock { + e.results = &ClientMockUpdateServiceResults{sp1, err} + return e.mock +} + +// Times sets number of times Client.UpdateService should be invoked +func (mmUpdateService *mClientMockUpdateService) Times(n uint64) *mClientMockUpdateService { + if n == 0 { + mmUpdateService.mock.t.Fatalf("Times of ClientMock.UpdateService mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateService.expectedInvocations, n) + return mmUpdateService +} + +func (mmUpdateService *mClientMockUpdateService) invocationsDone() bool { + if len(mmUpdateService.expectations) == 0 && mmUpdateService.defaultExpectation == nil && mmUpdateService.mock.funcUpdateService == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateService.mock.afterUpdateServiceCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateService.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateService implements api.Client +func (mmUpdateService *ClientMock) UpdateService(serviceId string, s mm_api.ServiceUpdate) (sp1 *mm_api.Service, err error) { + mm_atomic.AddUint64(&mmUpdateService.beforeUpdateServiceCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateService.afterUpdateServiceCounter, 1) + + if mmUpdateService.inspectFuncUpdateService != nil { + mmUpdateService.inspectFuncUpdateService(serviceId, s) + } + + mm_params := ClientMockUpdateServiceParams{serviceId, s} + + // Record call args + mmUpdateService.UpdateServiceMock.mutex.Lock() + mmUpdateService.UpdateServiceMock.callArgs = append(mmUpdateService.UpdateServiceMock.callArgs, &mm_params) + mmUpdateService.UpdateServiceMock.mutex.Unlock() + + for _, e := range mmUpdateService.UpdateServiceMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.err + } + } + + if mmUpdateService.UpdateServiceMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateService.UpdateServiceMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateService.UpdateServiceMock.defaultExpectation.params + mm_want_ptrs := mmUpdateService.UpdateServiceMock.defaultExpectation.paramPtrs + + mm_got := ClientMockUpdateServiceParams{serviceId, s} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.serviceId != nil && !minimock.Equal(*mm_want_ptrs.serviceId, mm_got.serviceId) { + mmUpdateService.t.Errorf("ClientMock.UpdateService got unexpected parameter serviceId, want: %#v, got: %#v%s\n", *mm_want_ptrs.serviceId, mm_got.serviceId, minimock.Diff(*mm_want_ptrs.serviceId, mm_got.serviceId)) + } + + if mm_want_ptrs.s != nil && !minimock.Equal(*mm_want_ptrs.s, mm_got.s) { + mmUpdateService.t.Errorf("ClientMock.UpdateService got unexpected parameter s, want: %#v, got: %#v%s\n", *mm_want_ptrs.s, mm_got.s, minimock.Diff(*mm_want_ptrs.s, mm_got.s)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateService.t.Errorf("ClientMock.UpdateService got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateService.UpdateServiceMock.defaultExpectation.results + if mm_results == nil { + mmUpdateService.t.Fatal("No results are set for the ClientMock.UpdateService") + } + return (*mm_results).sp1, (*mm_results).err + } + if mmUpdateService.funcUpdateService != nil { + return mmUpdateService.funcUpdateService(serviceId, s) + } + mmUpdateService.t.Fatalf("Unexpected call to ClientMock.UpdateService. %v %v", serviceId, s) + return +} + +// UpdateServiceAfterCounter returns a count of finished ClientMock.UpdateService invocations +func (mmUpdateService *ClientMock) UpdateServiceAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateService.afterUpdateServiceCounter) +} + +// UpdateServiceBeforeCounter returns a count of ClientMock.UpdateService invocations +func (mmUpdateService *ClientMock) UpdateServiceBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateService.beforeUpdateServiceCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.UpdateService. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateService *mClientMockUpdateService) Calls() []*ClientMockUpdateServiceParams { + mmUpdateService.mutex.RLock() + + argCopy := make([]*ClientMockUpdateServiceParams, len(mmUpdateService.callArgs)) + copy(argCopy, mmUpdateService.callArgs) + + mmUpdateService.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateServiceDone returns true if the count of the UpdateService invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockUpdateServiceDone() bool { + if m.UpdateServiceMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateServiceMock.invocationsDone() +} + +// MinimockUpdateServiceInspect logs each unmet expectation +func (m *ClientMock) MinimockUpdateServiceInspect() { + for _, e := range m.UpdateServiceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.UpdateService with params: %#v", *e.params) + } + } + + afterUpdateServiceCounter := mm_atomic.LoadUint64(&m.afterUpdateServiceCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateServiceMock.defaultExpectation != nil && afterUpdateServiceCounter < 1 { + if m.UpdateServiceMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.UpdateService") + } else { + m.t.Errorf("Expected call to ClientMock.UpdateService with params: %#v", *m.UpdateServiceMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateService != nil && afterUpdateServiceCounter < 1 { + m.t.Error("Expected call to ClientMock.UpdateService") + } + + if !m.UpdateServiceMock.invocationsDone() && afterUpdateServiceCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.UpdateService but found %d calls", + mm_atomic.LoadUint64(&m.UpdateServiceMock.expectedInvocations), afterUpdateServiceCounter) + } +} + +type mClientMockUpdateServicePassword struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockUpdateServicePasswordExpectation + expectations []*ClientMockUpdateServicePasswordExpectation + + callArgs []*ClientMockUpdateServicePasswordParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockUpdateServicePasswordExpectation specifies expectation struct of the Client.UpdateServicePassword +type ClientMockUpdateServicePasswordExpectation struct { + mock *ClientMock + params *ClientMockUpdateServicePasswordParams + paramPtrs *ClientMockUpdateServicePasswordParamPtrs + results *ClientMockUpdateServicePasswordResults + Counter uint64 +} + +// ClientMockUpdateServicePasswordParams contains parameters of the Client.UpdateServicePassword +type ClientMockUpdateServicePasswordParams struct { + serviceId string + u mm_api.ServicePasswordUpdate +} + +// ClientMockUpdateServicePasswordParamPtrs contains pointers to parameters of the Client.UpdateServicePassword +type ClientMockUpdateServicePasswordParamPtrs struct { + serviceId *string + u *mm_api.ServicePasswordUpdate +} + +// ClientMockUpdateServicePasswordResults contains results of the Client.UpdateServicePassword +type ClientMockUpdateServicePasswordResults struct { + sp1 *mm_api.ServicePasswordUpdateResult + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) Optional() *mClientMockUpdateServicePassword { + mmUpdateServicePassword.optional = true + return mmUpdateServicePassword +} + +// Expect sets up expected params for Client.UpdateServicePassword +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) Expect(serviceId string, u mm_api.ServicePasswordUpdate) *mClientMockUpdateServicePassword { + if mmUpdateServicePassword.mock.funcUpdateServicePassword != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by Set") + } + + if mmUpdateServicePassword.defaultExpectation == nil { + mmUpdateServicePassword.defaultExpectation = &ClientMockUpdateServicePasswordExpectation{} + } + + if mmUpdateServicePassword.defaultExpectation.paramPtrs != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by ExpectParams functions") + } + + mmUpdateServicePassword.defaultExpectation.params = &ClientMockUpdateServicePasswordParams{serviceId, u} + for _, e := range mmUpdateServicePassword.expectations { + if minimock.Equal(e.params, mmUpdateServicePassword.defaultExpectation.params) { + mmUpdateServicePassword.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateServicePassword.defaultExpectation.params) + } + } + + return mmUpdateServicePassword +} + +// ExpectServiceIdParam1 sets up expected param serviceId for Client.UpdateServicePassword +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) ExpectServiceIdParam1(serviceId string) *mClientMockUpdateServicePassword { + if mmUpdateServicePassword.mock.funcUpdateServicePassword != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by Set") + } + + if mmUpdateServicePassword.defaultExpectation == nil { + mmUpdateServicePassword.defaultExpectation = &ClientMockUpdateServicePasswordExpectation{} + } + + if mmUpdateServicePassword.defaultExpectation.params != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by Expect") + } + + if mmUpdateServicePassword.defaultExpectation.paramPtrs == nil { + mmUpdateServicePassword.defaultExpectation.paramPtrs = &ClientMockUpdateServicePasswordParamPtrs{} + } + mmUpdateServicePassword.defaultExpectation.paramPtrs.serviceId = &serviceId + + return mmUpdateServicePassword +} + +// ExpectUParam2 sets up expected param u for Client.UpdateServicePassword +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) ExpectUParam2(u mm_api.ServicePasswordUpdate) *mClientMockUpdateServicePassword { + if mmUpdateServicePassword.mock.funcUpdateServicePassword != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by Set") + } + + if mmUpdateServicePassword.defaultExpectation == nil { + mmUpdateServicePassword.defaultExpectation = &ClientMockUpdateServicePasswordExpectation{} + } + + if mmUpdateServicePassword.defaultExpectation.params != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by Expect") + } + + if mmUpdateServicePassword.defaultExpectation.paramPtrs == nil { + mmUpdateServicePassword.defaultExpectation.paramPtrs = &ClientMockUpdateServicePasswordParamPtrs{} + } + mmUpdateServicePassword.defaultExpectation.paramPtrs.u = &u + + return mmUpdateServicePassword +} + +// Inspect accepts an inspector function that has same arguments as the Client.UpdateServicePassword +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) Inspect(f func(serviceId string, u mm_api.ServicePasswordUpdate)) *mClientMockUpdateServicePassword { + if mmUpdateServicePassword.mock.inspectFuncUpdateServicePassword != nil { + mmUpdateServicePassword.mock.t.Fatalf("Inspect function is already set for ClientMock.UpdateServicePassword") + } + + mmUpdateServicePassword.mock.inspectFuncUpdateServicePassword = f + + return mmUpdateServicePassword +} + +// Return sets up results that will be returned by Client.UpdateServicePassword +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) Return(sp1 *mm_api.ServicePasswordUpdateResult, err error) *ClientMock { + if mmUpdateServicePassword.mock.funcUpdateServicePassword != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by Set") + } + + if mmUpdateServicePassword.defaultExpectation == nil { + mmUpdateServicePassword.defaultExpectation = &ClientMockUpdateServicePasswordExpectation{mock: mmUpdateServicePassword.mock} + } + mmUpdateServicePassword.defaultExpectation.results = &ClientMockUpdateServicePasswordResults{sp1, err} + return mmUpdateServicePassword.mock +} + +// Set uses given function f to mock the Client.UpdateServicePassword method +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) Set(f func(serviceId string, u mm_api.ServicePasswordUpdate) (sp1 *mm_api.ServicePasswordUpdateResult, err error)) *ClientMock { + if mmUpdateServicePassword.defaultExpectation != nil { + mmUpdateServicePassword.mock.t.Fatalf("Default expectation is already set for the Client.UpdateServicePassword method") + } + + if len(mmUpdateServicePassword.expectations) > 0 { + mmUpdateServicePassword.mock.t.Fatalf("Some expectations are already set for the Client.UpdateServicePassword method") + } + + mmUpdateServicePassword.mock.funcUpdateServicePassword = f + return mmUpdateServicePassword.mock +} + +// When sets expectation for the Client.UpdateServicePassword which will trigger the result defined by the following +// Then helper +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) When(serviceId string, u mm_api.ServicePasswordUpdate) *ClientMockUpdateServicePasswordExpectation { + if mmUpdateServicePassword.mock.funcUpdateServicePassword != nil { + mmUpdateServicePassword.mock.t.Fatalf("ClientMock.UpdateServicePassword mock is already set by Set") + } + + expectation := &ClientMockUpdateServicePasswordExpectation{ + mock: mmUpdateServicePassword.mock, + params: &ClientMockUpdateServicePasswordParams{serviceId, u}, + } + mmUpdateServicePassword.expectations = append(mmUpdateServicePassword.expectations, expectation) + return expectation +} + +// Then sets up Client.UpdateServicePassword return parameters for the expectation previously defined by the When method +func (e *ClientMockUpdateServicePasswordExpectation) Then(sp1 *mm_api.ServicePasswordUpdateResult, err error) *ClientMock { + e.results = &ClientMockUpdateServicePasswordResults{sp1, err} + return e.mock +} + +// Times sets number of times Client.UpdateServicePassword should be invoked +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) Times(n uint64) *mClientMockUpdateServicePassword { + if n == 0 { + mmUpdateServicePassword.mock.t.Fatalf("Times of ClientMock.UpdateServicePassword mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateServicePassword.expectedInvocations, n) + return mmUpdateServicePassword +} + +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) invocationsDone() bool { + if len(mmUpdateServicePassword.expectations) == 0 && mmUpdateServicePassword.defaultExpectation == nil && mmUpdateServicePassword.mock.funcUpdateServicePassword == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateServicePassword.mock.afterUpdateServicePasswordCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateServicePassword.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateServicePassword implements api.Client +func (mmUpdateServicePassword *ClientMock) UpdateServicePassword(serviceId string, u mm_api.ServicePasswordUpdate) (sp1 *mm_api.ServicePasswordUpdateResult, err error) { + mm_atomic.AddUint64(&mmUpdateServicePassword.beforeUpdateServicePasswordCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateServicePassword.afterUpdateServicePasswordCounter, 1) + + if mmUpdateServicePassword.inspectFuncUpdateServicePassword != nil { + mmUpdateServicePassword.inspectFuncUpdateServicePassword(serviceId, u) + } + + mm_params := ClientMockUpdateServicePasswordParams{serviceId, u} + + // Record call args + mmUpdateServicePassword.UpdateServicePasswordMock.mutex.Lock() + mmUpdateServicePassword.UpdateServicePasswordMock.callArgs = append(mmUpdateServicePassword.UpdateServicePasswordMock.callArgs, &mm_params) + mmUpdateServicePassword.UpdateServicePasswordMock.mutex.Unlock() + + for _, e := range mmUpdateServicePassword.UpdateServicePasswordMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.err + } + } + + if mmUpdateServicePassword.UpdateServicePasswordMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateServicePassword.UpdateServicePasswordMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateServicePassword.UpdateServicePasswordMock.defaultExpectation.params + mm_want_ptrs := mmUpdateServicePassword.UpdateServicePasswordMock.defaultExpectation.paramPtrs + + mm_got := ClientMockUpdateServicePasswordParams{serviceId, u} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.serviceId != nil && !minimock.Equal(*mm_want_ptrs.serviceId, mm_got.serviceId) { + mmUpdateServicePassword.t.Errorf("ClientMock.UpdateServicePassword got unexpected parameter serviceId, want: %#v, got: %#v%s\n", *mm_want_ptrs.serviceId, mm_got.serviceId, minimock.Diff(*mm_want_ptrs.serviceId, mm_got.serviceId)) + } + + if mm_want_ptrs.u != nil && !minimock.Equal(*mm_want_ptrs.u, mm_got.u) { + mmUpdateServicePassword.t.Errorf("ClientMock.UpdateServicePassword got unexpected parameter u, want: %#v, got: %#v%s\n", *mm_want_ptrs.u, mm_got.u, minimock.Diff(*mm_want_ptrs.u, mm_got.u)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateServicePassword.t.Errorf("ClientMock.UpdateServicePassword got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateServicePassword.UpdateServicePasswordMock.defaultExpectation.results + if mm_results == nil { + mmUpdateServicePassword.t.Fatal("No results are set for the ClientMock.UpdateServicePassword") + } + return (*mm_results).sp1, (*mm_results).err + } + if mmUpdateServicePassword.funcUpdateServicePassword != nil { + return mmUpdateServicePassword.funcUpdateServicePassword(serviceId, u) + } + mmUpdateServicePassword.t.Fatalf("Unexpected call to ClientMock.UpdateServicePassword. %v %v", serviceId, u) + return +} + +// UpdateServicePasswordAfterCounter returns a count of finished ClientMock.UpdateServicePassword invocations +func (mmUpdateServicePassword *ClientMock) UpdateServicePasswordAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateServicePassword.afterUpdateServicePasswordCounter) +} + +// UpdateServicePasswordBeforeCounter returns a count of ClientMock.UpdateServicePassword invocations +func (mmUpdateServicePassword *ClientMock) UpdateServicePasswordBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateServicePassword.beforeUpdateServicePasswordCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.UpdateServicePassword. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateServicePassword *mClientMockUpdateServicePassword) Calls() []*ClientMockUpdateServicePasswordParams { + mmUpdateServicePassword.mutex.RLock() + + argCopy := make([]*ClientMockUpdateServicePasswordParams, len(mmUpdateServicePassword.callArgs)) + copy(argCopy, mmUpdateServicePassword.callArgs) + + mmUpdateServicePassword.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateServicePasswordDone returns true if the count of the UpdateServicePassword invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockUpdateServicePasswordDone() bool { + if m.UpdateServicePasswordMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateServicePasswordMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateServicePasswordMock.invocationsDone() +} + +// MinimockUpdateServicePasswordInspect logs each unmet expectation +func (m *ClientMock) MinimockUpdateServicePasswordInspect() { + for _, e := range m.UpdateServicePasswordMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.UpdateServicePassword with params: %#v", *e.params) + } + } + + afterUpdateServicePasswordCounter := mm_atomic.LoadUint64(&m.afterUpdateServicePasswordCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateServicePasswordMock.defaultExpectation != nil && afterUpdateServicePasswordCounter < 1 { + if m.UpdateServicePasswordMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.UpdateServicePassword") + } else { + m.t.Errorf("Expected call to ClientMock.UpdateServicePassword with params: %#v", *m.UpdateServicePasswordMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateServicePassword != nil && afterUpdateServicePasswordCounter < 1 { + m.t.Error("Expected call to ClientMock.UpdateServicePassword") + } + + if !m.UpdateServicePasswordMock.invocationsDone() && afterUpdateServicePasswordCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.UpdateServicePassword but found %d calls", + mm_atomic.LoadUint64(&m.UpdateServicePasswordMock.expectedInvocations), afterUpdateServicePasswordCounter) + } +} + +type mClientMockUpdateServiceScaling struct { + optional bool + mock *ClientMock + defaultExpectation *ClientMockUpdateServiceScalingExpectation + expectations []*ClientMockUpdateServiceScalingExpectation + + callArgs []*ClientMockUpdateServiceScalingParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// ClientMockUpdateServiceScalingExpectation specifies expectation struct of the Client.UpdateServiceScaling +type ClientMockUpdateServiceScalingExpectation struct { + mock *ClientMock + params *ClientMockUpdateServiceScalingParams + paramPtrs *ClientMockUpdateServiceScalingParamPtrs + results *ClientMockUpdateServiceScalingResults + Counter uint64 +} + +// ClientMockUpdateServiceScalingParams contains parameters of the Client.UpdateServiceScaling +type ClientMockUpdateServiceScalingParams struct { + serviceId string + s mm_api.ServiceScalingUpdate +} + +// ClientMockUpdateServiceScalingParamPtrs contains pointers to parameters of the Client.UpdateServiceScaling +type ClientMockUpdateServiceScalingParamPtrs struct { + serviceId *string + s *mm_api.ServiceScalingUpdate +} + +// ClientMockUpdateServiceScalingResults contains results of the Client.UpdateServiceScaling +type ClientMockUpdateServiceScalingResults struct { + sp1 *mm_api.Service + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) Optional() *mClientMockUpdateServiceScaling { + mmUpdateServiceScaling.optional = true + return mmUpdateServiceScaling +} + +// Expect sets up expected params for Client.UpdateServiceScaling +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) Expect(serviceId string, s mm_api.ServiceScalingUpdate) *mClientMockUpdateServiceScaling { + if mmUpdateServiceScaling.mock.funcUpdateServiceScaling != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by Set") + } + + if mmUpdateServiceScaling.defaultExpectation == nil { + mmUpdateServiceScaling.defaultExpectation = &ClientMockUpdateServiceScalingExpectation{} + } + + if mmUpdateServiceScaling.defaultExpectation.paramPtrs != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by ExpectParams functions") + } + + mmUpdateServiceScaling.defaultExpectation.params = &ClientMockUpdateServiceScalingParams{serviceId, s} + for _, e := range mmUpdateServiceScaling.expectations { + if minimock.Equal(e.params, mmUpdateServiceScaling.defaultExpectation.params) { + mmUpdateServiceScaling.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateServiceScaling.defaultExpectation.params) + } + } + + return mmUpdateServiceScaling +} + +// ExpectServiceIdParam1 sets up expected param serviceId for Client.UpdateServiceScaling +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) ExpectServiceIdParam1(serviceId string) *mClientMockUpdateServiceScaling { + if mmUpdateServiceScaling.mock.funcUpdateServiceScaling != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by Set") + } + + if mmUpdateServiceScaling.defaultExpectation == nil { + mmUpdateServiceScaling.defaultExpectation = &ClientMockUpdateServiceScalingExpectation{} + } + + if mmUpdateServiceScaling.defaultExpectation.params != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by Expect") + } + + if mmUpdateServiceScaling.defaultExpectation.paramPtrs == nil { + mmUpdateServiceScaling.defaultExpectation.paramPtrs = &ClientMockUpdateServiceScalingParamPtrs{} + } + mmUpdateServiceScaling.defaultExpectation.paramPtrs.serviceId = &serviceId + + return mmUpdateServiceScaling +} + +// ExpectSParam2 sets up expected param s for Client.UpdateServiceScaling +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) ExpectSParam2(s mm_api.ServiceScalingUpdate) *mClientMockUpdateServiceScaling { + if mmUpdateServiceScaling.mock.funcUpdateServiceScaling != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by Set") + } + + if mmUpdateServiceScaling.defaultExpectation == nil { + mmUpdateServiceScaling.defaultExpectation = &ClientMockUpdateServiceScalingExpectation{} + } + + if mmUpdateServiceScaling.defaultExpectation.params != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by Expect") + } + + if mmUpdateServiceScaling.defaultExpectation.paramPtrs == nil { + mmUpdateServiceScaling.defaultExpectation.paramPtrs = &ClientMockUpdateServiceScalingParamPtrs{} + } + mmUpdateServiceScaling.defaultExpectation.paramPtrs.s = &s + + return mmUpdateServiceScaling +} + +// Inspect accepts an inspector function that has same arguments as the Client.UpdateServiceScaling +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) Inspect(f func(serviceId string, s mm_api.ServiceScalingUpdate)) *mClientMockUpdateServiceScaling { + if mmUpdateServiceScaling.mock.inspectFuncUpdateServiceScaling != nil { + mmUpdateServiceScaling.mock.t.Fatalf("Inspect function is already set for ClientMock.UpdateServiceScaling") + } + + mmUpdateServiceScaling.mock.inspectFuncUpdateServiceScaling = f + + return mmUpdateServiceScaling +} + +// Return sets up results that will be returned by Client.UpdateServiceScaling +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) Return(sp1 *mm_api.Service, err error) *ClientMock { + if mmUpdateServiceScaling.mock.funcUpdateServiceScaling != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by Set") + } + + if mmUpdateServiceScaling.defaultExpectation == nil { + mmUpdateServiceScaling.defaultExpectation = &ClientMockUpdateServiceScalingExpectation{mock: mmUpdateServiceScaling.mock} + } + mmUpdateServiceScaling.defaultExpectation.results = &ClientMockUpdateServiceScalingResults{sp1, err} + return mmUpdateServiceScaling.mock +} + +// Set uses given function f to mock the Client.UpdateServiceScaling method +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) Set(f func(serviceId string, s mm_api.ServiceScalingUpdate) (sp1 *mm_api.Service, err error)) *ClientMock { + if mmUpdateServiceScaling.defaultExpectation != nil { + mmUpdateServiceScaling.mock.t.Fatalf("Default expectation is already set for the Client.UpdateServiceScaling method") + } + + if len(mmUpdateServiceScaling.expectations) > 0 { + mmUpdateServiceScaling.mock.t.Fatalf("Some expectations are already set for the Client.UpdateServiceScaling method") + } + + mmUpdateServiceScaling.mock.funcUpdateServiceScaling = f + return mmUpdateServiceScaling.mock +} + +// When sets expectation for the Client.UpdateServiceScaling which will trigger the result defined by the following +// Then helper +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) When(serviceId string, s mm_api.ServiceScalingUpdate) *ClientMockUpdateServiceScalingExpectation { + if mmUpdateServiceScaling.mock.funcUpdateServiceScaling != nil { + mmUpdateServiceScaling.mock.t.Fatalf("ClientMock.UpdateServiceScaling mock is already set by Set") + } + + expectation := &ClientMockUpdateServiceScalingExpectation{ + mock: mmUpdateServiceScaling.mock, + params: &ClientMockUpdateServiceScalingParams{serviceId, s}, + } + mmUpdateServiceScaling.expectations = append(mmUpdateServiceScaling.expectations, expectation) + return expectation +} + +// Then sets up Client.UpdateServiceScaling return parameters for the expectation previously defined by the When method +func (e *ClientMockUpdateServiceScalingExpectation) Then(sp1 *mm_api.Service, err error) *ClientMock { + e.results = &ClientMockUpdateServiceScalingResults{sp1, err} + return e.mock +} + +// Times sets number of times Client.UpdateServiceScaling should be invoked +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) Times(n uint64) *mClientMockUpdateServiceScaling { + if n == 0 { + mmUpdateServiceScaling.mock.t.Fatalf("Times of ClientMock.UpdateServiceScaling mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateServiceScaling.expectedInvocations, n) + return mmUpdateServiceScaling +} + +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) invocationsDone() bool { + if len(mmUpdateServiceScaling.expectations) == 0 && mmUpdateServiceScaling.defaultExpectation == nil && mmUpdateServiceScaling.mock.funcUpdateServiceScaling == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateServiceScaling.mock.afterUpdateServiceScalingCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateServiceScaling.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateServiceScaling implements api.Client +func (mmUpdateServiceScaling *ClientMock) UpdateServiceScaling(serviceId string, s mm_api.ServiceScalingUpdate) (sp1 *mm_api.Service, err error) { + mm_atomic.AddUint64(&mmUpdateServiceScaling.beforeUpdateServiceScalingCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateServiceScaling.afterUpdateServiceScalingCounter, 1) + + if mmUpdateServiceScaling.inspectFuncUpdateServiceScaling != nil { + mmUpdateServiceScaling.inspectFuncUpdateServiceScaling(serviceId, s) + } + + mm_params := ClientMockUpdateServiceScalingParams{serviceId, s} + + // Record call args + mmUpdateServiceScaling.UpdateServiceScalingMock.mutex.Lock() + mmUpdateServiceScaling.UpdateServiceScalingMock.callArgs = append(mmUpdateServiceScaling.UpdateServiceScalingMock.callArgs, &mm_params) + mmUpdateServiceScaling.UpdateServiceScalingMock.mutex.Unlock() + + for _, e := range mmUpdateServiceScaling.UpdateServiceScalingMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.err + } + } + + if mmUpdateServiceScaling.UpdateServiceScalingMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateServiceScaling.UpdateServiceScalingMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateServiceScaling.UpdateServiceScalingMock.defaultExpectation.params + mm_want_ptrs := mmUpdateServiceScaling.UpdateServiceScalingMock.defaultExpectation.paramPtrs + + mm_got := ClientMockUpdateServiceScalingParams{serviceId, s} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.serviceId != nil && !minimock.Equal(*mm_want_ptrs.serviceId, mm_got.serviceId) { + mmUpdateServiceScaling.t.Errorf("ClientMock.UpdateServiceScaling got unexpected parameter serviceId, want: %#v, got: %#v%s\n", *mm_want_ptrs.serviceId, mm_got.serviceId, minimock.Diff(*mm_want_ptrs.serviceId, mm_got.serviceId)) + } + + if mm_want_ptrs.s != nil && !minimock.Equal(*mm_want_ptrs.s, mm_got.s) { + mmUpdateServiceScaling.t.Errorf("ClientMock.UpdateServiceScaling got unexpected parameter s, want: %#v, got: %#v%s\n", *mm_want_ptrs.s, mm_got.s, minimock.Diff(*mm_want_ptrs.s, mm_got.s)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateServiceScaling.t.Errorf("ClientMock.UpdateServiceScaling got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateServiceScaling.UpdateServiceScalingMock.defaultExpectation.results + if mm_results == nil { + mmUpdateServiceScaling.t.Fatal("No results are set for the ClientMock.UpdateServiceScaling") + } + return (*mm_results).sp1, (*mm_results).err + } + if mmUpdateServiceScaling.funcUpdateServiceScaling != nil { + return mmUpdateServiceScaling.funcUpdateServiceScaling(serviceId, s) + } + mmUpdateServiceScaling.t.Fatalf("Unexpected call to ClientMock.UpdateServiceScaling. %v %v", serviceId, s) + return +} + +// UpdateServiceScalingAfterCounter returns a count of finished ClientMock.UpdateServiceScaling invocations +func (mmUpdateServiceScaling *ClientMock) UpdateServiceScalingAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateServiceScaling.afterUpdateServiceScalingCounter) +} + +// UpdateServiceScalingBeforeCounter returns a count of ClientMock.UpdateServiceScaling invocations +func (mmUpdateServiceScaling *ClientMock) UpdateServiceScalingBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateServiceScaling.beforeUpdateServiceScalingCounter) +} + +// Calls returns a list of arguments used in each call to ClientMock.UpdateServiceScaling. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateServiceScaling *mClientMockUpdateServiceScaling) Calls() []*ClientMockUpdateServiceScalingParams { + mmUpdateServiceScaling.mutex.RLock() + + argCopy := make([]*ClientMockUpdateServiceScalingParams, len(mmUpdateServiceScaling.callArgs)) + copy(argCopy, mmUpdateServiceScaling.callArgs) + + mmUpdateServiceScaling.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateServiceScalingDone returns true if the count of the UpdateServiceScaling invocations corresponds +// the number of defined expectations +func (m *ClientMock) MinimockUpdateServiceScalingDone() bool { + if m.UpdateServiceScalingMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateServiceScalingMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateServiceScalingMock.invocationsDone() +} + +// MinimockUpdateServiceScalingInspect logs each unmet expectation +func (m *ClientMock) MinimockUpdateServiceScalingInspect() { + for _, e := range m.UpdateServiceScalingMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to ClientMock.UpdateServiceScaling with params: %#v", *e.params) + } + } + + afterUpdateServiceScalingCounter := mm_atomic.LoadUint64(&m.afterUpdateServiceScalingCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateServiceScalingMock.defaultExpectation != nil && afterUpdateServiceScalingCounter < 1 { + if m.UpdateServiceScalingMock.defaultExpectation.params == nil { + m.t.Error("Expected call to ClientMock.UpdateServiceScaling") + } else { + m.t.Errorf("Expected call to ClientMock.UpdateServiceScaling with params: %#v", *m.UpdateServiceScalingMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateServiceScaling != nil && afterUpdateServiceScalingCounter < 1 { + m.t.Error("Expected call to ClientMock.UpdateServiceScaling") + } + + if !m.UpdateServiceScalingMock.invocationsDone() && afterUpdateServiceScalingCounter > 0 { + m.t.Errorf("Expected %d calls to ClientMock.UpdateServiceScaling but found %d calls", + mm_atomic.LoadUint64(&m.UpdateServiceScalingMock.expectedInvocations), afterUpdateServiceScalingCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *ClientMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockCreateServiceInspect() + + m.MinimockDeleteServiceInspect() + + m.MinimockGetOrgPrivateEndpointConfigInspect() + + m.MinimockGetOrganizationPrivateEndpointsInspect() + + m.MinimockGetServiceInspect() + + m.MinimockGetServiceStatusCodeInspect() + + m.MinimockUpdateOrganizationPrivateEndpointsInspect() + + m.MinimockUpdateServiceInspect() + + m.MinimockUpdateServicePasswordInspect() + + m.MinimockUpdateServiceScalingInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *ClientMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *ClientMock) minimockDone() bool { + done := true + return done && + m.MinimockCreateServiceDone() && + m.MinimockDeleteServiceDone() && + m.MinimockGetOrgPrivateEndpointConfigDone() && + m.MinimockGetOrganizationPrivateEndpointsDone() && + m.MinimockGetServiceDone() && + m.MinimockGetServiceStatusCodeDone() && + m.MinimockUpdateOrganizationPrivateEndpointsDone() && + m.MinimockUpdateServiceDone() && + m.MinimockUpdateServicePasswordDone() && + m.MinimockUpdateServiceScalingDone() +} diff --git a/clickhouse/service.go b/clickhouse/service.go index d3329b49..ef5b13d4 100644 --- a/clickhouse/service.go +++ b/clickhouse/service.go @@ -56,7 +56,8 @@ type IpAccessModel struct { } func (s IpAccessModel) Equal(other IpAccessModel) bool { - return false + return s.Source.ValueString() == other.Source.ValueString() && + s.Description.ValueString() == other.Description.ValueString() } var privateEndpointConfigType = types.ObjectType{ diff --git a/clickhouse/service_test.go b/clickhouse/service_test.go new file mode 100644 index 00000000..339753ab --- /dev/null +++ b/clickhouse/service_test.go @@ -0,0 +1,428 @@ +package clickhouse + +import ( + "context" + "testing" + + "github.com/ClickHouse/terraform-provider-clickhouse/internal/api" + "github.com/ClickHouse/terraform-provider-clickhouse/internal/test" + + "github.com/gojuno/minimock/v3" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func TestServiceResource_syncServiceState(t *testing.T) { + state := getInitialState() + + tests := []struct { + name string + state ServiceResourceModel + response *api.Service + responseErr error + desiredState ServiceResourceModel + updateTimestamp bool + wantErr bool + }{ + { + name: "Updates name field in state", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Name = "newname" + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Name = types.StringValue("newname") + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update Endpoints field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Endpoints = []api.Endpoint{ + { + Protocol: "TCP", + Host: "a.b.c.d", + Port: 1234, + }, + } + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + var endpoints []attr.Value + obj, _ := types.ObjectValue(endpointObjectType.AttrTypes, map[string]attr.Value{ + "protocol": types.StringValue("TCP"), + "host": types.StringValue("a.b.c.d"), + "port": types.Int64Value(int64(1234)), + }) + + endpoints = append(endpoints, obj) + src.Endpoints, _ = types.ListValue(endpointObjectType, endpoints) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Updates provider field in state", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Provider = "newprovider" + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.CloudProvider = types.StringValue("newprovider") + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Updates region field in state", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Region = "newregion" + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Region = types.StringValue("newregion") + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Updates tier field in state", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Tier = "newtier" + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Tier = types.StringValue("newtier") + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Set IdleScaling field to true", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.IdleScaling = true + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.IdleScaling = types.BoolValue(true) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Set IdleScaling field to false", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.IdleScaling = false + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.IdleScaling = types.BoolValue(false) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update IpAccessList field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.IpAccessList = []api.IpAccess{ + { + Source: "0.0.0.0/0", + Description: "whitelist", + }, + } + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.IpAccessList = []IpAccessModel{ + { + Source: types.StringValue("0.0.0.0/0"), + Description: types.StringValue("whitelist"), + }, + } + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Updates MinTotalMemoryGb field when in production tier", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Tier = api.TierProduction + minTotalMemory := 10 + src.MinTotalMemoryGb = &minTotalMemory + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Tier = types.StringValue(api.TierProduction) + src.MinTotalMemoryGb = types.Int64Value(10) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Does not update MinTotalMemoryGb field when in development tier", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Tier = api.TierDevelopment + minTotalMemory := 10 + src.MinTotalMemoryGb = &minTotalMemory + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Tier = types.StringValue(api.TierDevelopment) + src.MinTotalMemoryGb = types.Int64{} + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Updates MaxTotalMemoryGb field when in production tier", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Tier = api.TierProduction + maxTotalMemory := 10 + src.MaxTotalMemoryGb = &maxTotalMemory + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Tier = types.StringValue(api.TierProduction) + src.MaxTotalMemoryGb = types.Int64Value(10) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Does not update MaxTotalMemoryGb field when in development tier", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Tier = api.TierDevelopment + maxTotalMemory := 10 + src.MaxTotalMemoryGb = &maxTotalMemory + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Tier = types.StringValue(api.TierDevelopment) + src.MaxTotalMemoryGb = types.Int64{} + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Updates NumReplicas field when in production tier", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Tier = api.TierProduction + replicas := 3 + src.NumReplicas = &replicas + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Tier = types.StringValue(api.TierProduction) + src.NumReplicas = types.Int64Value(3) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Does not update NumReplicas field when in development tier", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.Tier = api.TierDevelopment + replicas := 3 + src.NumReplicas = &replicas + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.Tier = types.StringValue(api.TierDevelopment) + src.NumReplicas = types.Int64{} + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update IdleTimeoutMinutes field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + timeout := 25 + src.IdleTimeoutMinutes = &timeout + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.IdleTimeoutMinutes = types.Int64Value(25) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update IAMRole field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.IAMRole = "newiamrole" + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.IAMRole = types.StringValue("newiamrole") + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update PrivateEndpointConfig field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.PrivateEndpointConfig = &api.ServicePrivateEndpointConfig{ + EndpointServiceId: "newendpointserviceid", + PrivateDnsHostname: "new.endpoint.service.hostname", + } + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.PrivateEndpointConfig, _ = types.ObjectValue(privateEndpointConfigType.AttrTypes, map[string]attr.Value{ + "endpoint_service_id": types.StringValue("newendpointserviceid"), + "private_dns_hostname": types.StringValue("new.endpoint.service.hostname"), + }) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update PrivateEndpointIds field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.PrivateEndpointIds = []string{ + "newendpointid", + } + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.PrivateEndpointIds, _ = types.ListValueFrom(context.Background(), types.StringType, []string{"newendpointid"}) + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update EncryptionKey field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.EncryptionKey = "newencryptionkey" + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.EncryptionKey = types.StringValue("newencryptionkey") + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + { + name: "Update EncryptionAssumedRoleIdentifier field", + state: state, + response: test.NewUpdater(getBaseResponse(state.ID.ValueString())).Update(func(src *api.Service) { + src.EncryptionAssumedRoleIdentifier = "newroleidentifier" + }).GetPtr(), + responseErr: nil, + desiredState: test.NewUpdater(state).Update(func(src *ServiceResourceModel) { + src.EncryptionAssumedRoleIdentifier = types.StringValue("newroleidentifier") + }).Get(), + updateTimestamp: false, + wantErr: false, + }, + } + + ctx := context.Background() + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mc := minimock.NewController(t) + + apiClientMock := NewClientMock(mc). + GetServiceMock. + Expect(tt.state.ID.ValueString()). + Return(tt.response, tt.responseErr) + + r := &ServiceResource{ + client: apiClientMock, + } + + err := r.syncServiceState(ctx, &tt.state, tt.updateTimestamp) + + if (err != nil) != tt.wantErr { + t.Errorf("%s error does not match:\ngot = %v\nwant = %v", tt.name, err, tt.wantErr) + } + + if !tt.state.Equals(tt.desiredState) { + t.Errorf("%s state does not match:\ngot = %v\nwant = %v\n", tt.name, tt.state, tt.desiredState) + } + }) + } +} + +func getInitialState() ServiceResourceModel { + uuid := "773bb8b4-34e8-4ecf-8e23-4f7e20aa14b3" + + endpoints, _ := types.ListValue(endpointObjectType, []attr.Value{}) + privateEndpointConfig, _ := types.ObjectValue(privateEndpointConfigType.AttrTypes, map[string]attr.Value{ + "endpoint_service_id": types.StringValue(""), + "private_dns_hostname": types.StringValue(""), + }) + privateEndpointIds, _ := types.ListValue(types.StringType, []attr.Value{}) + + state := ServiceResourceModel{ + ID: types.StringValue(uuid), + Name: types.StringValue(""), + Password: types.String{}, + PasswordHash: types.String{}, + DoubleSha1PasswordHash: types.String{}, + Endpoints: endpoints, + CloudProvider: types.StringValue(""), + Region: types.StringValue(""), + Tier: types.StringValue(""), + IdleScaling: types.BoolValue(false), + IpAccessList: make([]IpAccessModel, 0), + MinTotalMemoryGb: types.Int64{}, + MaxTotalMemoryGb: types.Int64{}, + NumReplicas: types.Int64{}, + IdleTimeoutMinutes: types.Int64{}, + IAMRole: types.StringValue(""), + LastUpdated: types.String{}, + PrivateEndpointConfig: privateEndpointConfig, + PrivateEndpointIds: privateEndpointIds, + EncryptionKey: types.StringValue(""), + EncryptionAssumedRoleIdentifier: types.StringValue(""), + } + + return state +} + +func getBaseResponse(id string) api.Service { + return api.Service{ + Id: id, + // Name: "newname", + // Provider: "", + // Region: "", + // Tier: "", + IdleScaling: false, + // IpAccessList: nil, + // MinTotalMemoryGb: nil, + // MaxTotalMemoryGb: nil, + // NumReplicas: nil, + // IdleTimeoutMinutes: nil, + // State: "", + // Endpoints: nil, + // IAMRole: "", + PrivateEndpointConfig: &api.ServicePrivateEndpointConfig{ + EndpointServiceId: "", + PrivateDnsHostname: "", + }, + // PrivateEndpointIds: nil, + // EncryptionKey: "", + // EncryptionAssumedRoleIdentifier: "", + } +} diff --git a/go.mod b/go.mod index 905f59d9..956e6c7f 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/ClickHouse/terraform-provider-clickhouse go 1.22.5 require ( + github.com/gojuno/minimock/v3 v3.3.13 github.com/google/go-cmp v0.6.0 github.com/hashicorp/terraform-plugin-docs v0.19.4 github.com/hashicorp/terraform-plugin-framework v1.10.0 @@ -21,6 +22,7 @@ require ( github.com/bgentry/speakeasy v0.1.0 // indirect github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect @@ -50,6 +52,7 @@ require ( github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect @@ -68,7 +71,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/grpc v1.63.2 // indirect google.golang.org/protobuf v1.34.0 // indirect - gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8cdda116..3a004e51 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+ github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/gojuno/minimock/v3 v3.3.13 h1:sXFO7RbB4JnZiKhgMO4BU4RLYcfhcOSepfiv4wPgGNY= +github.com/gojuno/minimock/v3 v3.3.13/go.mod h1:WtJbR+15lbzpUHoOFtT7Sv1rR885bFxoyHrzoMOmK/k= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= @@ -156,8 +158,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= @@ -228,8 +230,8 @@ google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDom google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=