// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT. package mocks //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place.ThingRepository -o thing_repository_minimock.go -n ThingRepositoryMock -p mocks import ( "context" "sync" mm_atomic "sync/atomic" mm_time "time" "git.dmitriygnatenko.ru/dima/homethings/internal/models" "github.com/gojuno/minimock/v3" ) // ThingRepositoryMock implements place.ThingRepository type ThingRepositoryMock struct { t minimock.Tester finishOnce sync.Once funcDelete func(ctx context.Context, id uint64) (err error) inspectFuncDelete func(ctx context.Context, id uint64) afterDeleteCounter uint64 beforeDeleteCounter uint64 DeleteMock mThingRepositoryMockDelete funcGetByPlaceID func(ctx context.Context, id uint64) (ta1 []models.Thing, err error) inspectFuncGetByPlaceID func(ctx context.Context, id uint64) afterGetByPlaceIDCounter uint64 beforeGetByPlaceIDCounter uint64 GetByPlaceIDMock mThingRepositoryMockGetByPlaceID } // NewThingRepositoryMock returns a mock for place.ThingRepository func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock { m := &ThingRepositoryMock{t: t} if controller, ok := t.(minimock.MockController); ok { controller.RegisterMocker(m) } m.DeleteMock = mThingRepositoryMockDelete{mock: m} m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{} m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m} m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{} t.Cleanup(m.MinimockFinish) return m } type mThingRepositoryMockDelete struct { optional bool mock *ThingRepositoryMock defaultExpectation *ThingRepositoryMockDeleteExpectation expectations []*ThingRepositoryMockDeleteExpectation callArgs []*ThingRepositoryMockDeleteParams mutex sync.RWMutex expectedInvocations uint64 } // ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete type ThingRepositoryMockDeleteExpectation struct { mock *ThingRepositoryMock params *ThingRepositoryMockDeleteParams paramPtrs *ThingRepositoryMockDeleteParamPtrs results *ThingRepositoryMockDeleteResults Counter uint64 } // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete type ThingRepositoryMockDeleteParams struct { ctx context.Context id uint64 } // ThingRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingRepository.Delete type ThingRepositoryMockDeleteParamPtrs struct { ctx *context.Context id *uint64 } // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete type ThingRepositoryMockDeleteResults struct { 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 (mmDelete *mThingRepositoryMockDelete) Optional() *mThingRepositoryMockDelete { mmDelete.optional = true return mmDelete } // Expect sets up expected params for ThingRepository.Delete func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.paramPtrs != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by ExpectParams functions") } mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, id} for _, e := range mmDelete.expectations { if minimock.Equal(e.params, mmDelete.defaultExpectation.params) { mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params) } } return mmDelete } // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Delete func (mmDelete *mThingRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.params != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect") } if mmDelete.defaultExpectation.paramPtrs == nil { mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{} } mmDelete.defaultExpectation.paramPtrs.ctx = &ctx return mmDelete } // ExpectIdParam2 sets up expected param id for ThingRepository.Delete func (mmDelete *mThingRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.params != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect") } if mmDelete.defaultExpectation.paramPtrs == nil { mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{} } mmDelete.defaultExpectation.paramPtrs.id = &id return mmDelete } // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockDelete { if mmDelete.mock.inspectFuncDelete != nil { mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete") } mmDelete.mock.inspectFuncDelete = f return mmDelete } // Return sets up results that will be returned by ThingRepository.Delete func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock} } mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err} return mmDelete.mock } // Set uses given function f to mock the ThingRepository.Delete method func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingRepositoryMock { if mmDelete.defaultExpectation != nil { mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method") } if len(mmDelete.expectations) > 0 { mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method") } mmDelete.mock.funcDelete = f return mmDelete.mock } // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following // Then helper func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingRepositoryMockDeleteExpectation { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set") } expectation := &ThingRepositoryMockDeleteExpectation{ mock: mmDelete.mock, params: &ThingRepositoryMockDeleteParams{ctx, id}, } mmDelete.expectations = append(mmDelete.expectations, expectation) return expectation } // Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock { e.results = &ThingRepositoryMockDeleteResults{err} return e.mock } // Times sets number of times ThingRepository.Delete should be invoked func (mmDelete *mThingRepositoryMockDelete) Times(n uint64) *mThingRepositoryMockDelete { if n == 0 { mmDelete.mock.t.Fatalf("Times of ThingRepositoryMock.Delete mock can not be zero") } mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n) return mmDelete } func (mmDelete *mThingRepositoryMockDelete) invocationsDone() bool { if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil { return true } totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter) expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations) return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) } // Delete implements place.ThingRepository func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, id uint64) (err error) { mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1) defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1) if mmDelete.inspectFuncDelete != nil { mmDelete.inspectFuncDelete(ctx, id) } mm_params := ThingRepositoryMockDeleteParams{ctx, id} // Record call args mmDelete.DeleteMock.mutex.Lock() mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params) mmDelete.DeleteMock.mutex.Unlock() for _, e := range mmDelete.DeleteMock.expectations { if minimock.Equal(*e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.err } } if mmDelete.DeleteMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1) mm_want := mmDelete.DeleteMock.defaultExpectation.params mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs mm_got := ThingRepositoryMockDeleteParams{ctx, id} if mm_want_ptrs != nil { if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) } if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) { mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id)) } } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmDelete.DeleteMock.defaultExpectation.results if mm_results == nil { mmDelete.t.Fatal("No results are set for the ThingRepositoryMock.Delete") } return (*mm_results).err } if mmDelete.funcDelete != nil { return mmDelete.funcDelete(ctx, id) } mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v", ctx, id) return } // DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter) } // DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter) } // Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams { mmDelete.mutex.RLock() argCopy := make([]*ThingRepositoryMockDeleteParams, len(mmDelete.callArgs)) copy(argCopy, mmDelete.callArgs) mmDelete.mutex.RUnlock() return argCopy } // MinimockDeleteDone returns true if the count of the Delete invocations corresponds // the number of defined expectations func (m *ThingRepositoryMock) MinimockDeleteDone() bool { if m.DeleteMock.optional { // Optional methods provide '0 or more' call count restriction. return true } for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } return m.DeleteMock.invocationsDone() } // MinimockDeleteInspect logs each unmet expectation func (m *ThingRepositoryMock) MinimockDeleteInspect() { for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *e.params) } } afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter) // if default expectation was set then invocations count should be greater than zero if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 { if m.DeleteMock.defaultExpectation.params == nil { m.t.Error("Expected call to ThingRepositoryMock.Delete") } else { m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcDelete != nil && afterDeleteCounter < 1 { m.t.Error("Expected call to ThingRepositoryMock.Delete") } if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 { m.t.Errorf("Expected %d calls to ThingRepositoryMock.Delete but found %d calls", mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter) } } type mThingRepositoryMockGetByPlaceID struct { optional bool mock *ThingRepositoryMock defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation expectations []*ThingRepositoryMockGetByPlaceIDExpectation callArgs []*ThingRepositoryMockGetByPlaceIDParams mutex sync.RWMutex expectedInvocations uint64 } // ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID type ThingRepositoryMockGetByPlaceIDExpectation struct { mock *ThingRepositoryMock params *ThingRepositoryMockGetByPlaceIDParams paramPtrs *ThingRepositoryMockGetByPlaceIDParamPtrs results *ThingRepositoryMockGetByPlaceIDResults Counter uint64 } // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID type ThingRepositoryMockGetByPlaceIDParams struct { ctx context.Context id uint64 } // ThingRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetByPlaceID type ThingRepositoryMockGetByPlaceIDParamPtrs struct { ctx *context.Context id *uint64 } // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID type ThingRepositoryMockGetByPlaceIDResults struct { ta1 []models.Thing 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 (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Optional() *mThingRepositoryMockGetByPlaceID { mmGetByPlaceID.optional = true return mmGetByPlaceID } // Expect sets up expected params for ThingRepository.GetByPlaceID func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{} } if mmGetByPlaceID.defaultExpectation.paramPtrs != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions") } mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, id} for _, e := range mmGetByPlaceID.expectations { if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) { mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params) } } return mmGetByPlaceID } // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetByPlaceID func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{} } if mmGetByPlaceID.defaultExpectation.params != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect") } if mmGetByPlaceID.defaultExpectation.paramPtrs == nil { mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{} } mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx return mmGetByPlaceID } // ExpectIdParam2 sets up expected param id for ThingRepository.GetByPlaceID func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{} } if mmGetByPlaceID.defaultExpectation.params != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect") } if mmGetByPlaceID.defaultExpectation.paramPtrs == nil { mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{} } mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id return mmGetByPlaceID } // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID") } mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f return mmGetByPlaceID } // Return sets up results that will be returned by ThingRepository.GetByPlaceID func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock} } mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err} return mmGetByPlaceID.mock } // Set uses given function f to mock the ThingRepository.GetByPlaceID method func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)) *ThingRepositoryMock { if mmGetByPlaceID.defaultExpectation != nil { mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method") } if len(mmGetByPlaceID.expectations) > 0 { mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method") } mmGetByPlaceID.mock.funcGetByPlaceID = f return mmGetByPlaceID.mock } // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following // Then helper func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingRepositoryMockGetByPlaceIDExpectation { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set") } expectation := &ThingRepositoryMockGetByPlaceIDExpectation{ mock: mmGetByPlaceID.mock, params: &ThingRepositoryMockGetByPlaceIDParams{ctx, id}, } mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation) return expectation } // Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock { e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err} return e.mock } // Times sets number of times ThingRepository.GetByPlaceID should be invoked func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Times(n uint64) *mThingRepositoryMockGetByPlaceID { if n == 0 { mmGetByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetByPlaceID mock can not be zero") } mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n) return mmGetByPlaceID } func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) invocationsDone() bool { if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil { return true } totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter) expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations) return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) } // GetByPlaceID implements place.ThingRepository func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ta1 []models.Thing, err error) { mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1) defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1) if mmGetByPlaceID.inspectFuncGetByPlaceID != nil { mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id) } mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, id} // Record call args mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock() mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params) mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock() for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations { if minimock.Equal(*e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.ta1, e.results.err } } if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1) mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, id} if mm_want_ptrs != nil { if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) } if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) { mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id)) } } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results if mm_results == nil { mmGetByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetByPlaceID") } return (*mm_results).ta1, (*mm_results).err } if mmGetByPlaceID.funcGetByPlaceID != nil { return mmGetByPlaceID.funcGetByPlaceID(ctx, id) } mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, id) return } // GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter) } // GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter) } // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams { mmGetByPlaceID.mutex.RLock() argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs)) copy(argCopy, mmGetByPlaceID.callArgs) mmGetByPlaceID.mutex.RUnlock() return argCopy } // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds // the number of defined expectations func (m *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool { if m.GetByPlaceIDMock.optional { // Optional methods provide '0 or more' call count restriction. return true } for _, e := range m.GetByPlaceIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } return m.GetByPlaceIDMock.invocationsDone() } // MinimockGetByPlaceIDInspect logs each unmet expectation func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() { for _, e := range m.GetByPlaceIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params) } } afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) // if default expectation was set then invocations count should be greater than zero if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 { if m.GetByPlaceIDMock.defaultExpectation.params == nil { m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID") } else { m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 { m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID") } if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 { m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetByPlaceID but found %d calls", mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter) } } // MinimockFinish checks that all mocked methods have been called the expected number of times func (m *ThingRepositoryMock) MinimockFinish() { m.finishOnce.Do(func() { if !m.minimockDone() { m.MinimockDeleteInspect() m.MinimockGetByPlaceIDInspect() } }) } // MinimockWait waits for all mocked methods to be called the expected number of times func (m *ThingRepositoryMock) 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 *ThingRepositoryMock) minimockDone() bool { done := true return done && m.MinimockDeleteDone() && m.MinimockGetByPlaceIDDone() }