// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT. package mocks //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place.PlaceImageRepository -o place_image_repository_minimock.go -n PlaceImageRepositoryMock -p mocks import ( "context" "database/sql" "sync" mm_atomic "sync/atomic" mm_time "time" "git.dmitriygnatenko.ru/dima/homethings/internal/models" "github.com/gojuno/minimock/v3" ) // PlaceImageRepositoryMock implements place.PlaceImageRepository type PlaceImageRepositoryMock struct { t minimock.Tester finishOnce sync.Once funcDelete func(ctx context.Context, imageID int, tx *sql.Tx) (err error) inspectFuncDelete func(ctx context.Context, imageID int, tx *sql.Tx) afterDeleteCounter uint64 beforeDeleteCounter uint64 DeleteMock mPlaceImageRepositoryMockDelete funcGetByPlaceID func(ctx context.Context, placeID int) (ia1 []models.Image, err error) inspectFuncGetByPlaceID func(ctx context.Context, placeID int) afterGetByPlaceIDCounter uint64 beforeGetByPlaceIDCounter uint64 GetByPlaceIDMock mPlaceImageRepositoryMockGetByPlaceID } // NewPlaceImageRepositoryMock returns a mock for place.PlaceImageRepository func NewPlaceImageRepositoryMock(t minimock.Tester) *PlaceImageRepositoryMock { m := &PlaceImageRepositoryMock{t: t} if controller, ok := t.(minimock.MockController); ok { controller.RegisterMocker(m) } m.DeleteMock = mPlaceImageRepositoryMockDelete{mock: m} m.DeleteMock.callArgs = []*PlaceImageRepositoryMockDeleteParams{} m.GetByPlaceIDMock = mPlaceImageRepositoryMockGetByPlaceID{mock: m} m.GetByPlaceIDMock.callArgs = []*PlaceImageRepositoryMockGetByPlaceIDParams{} t.Cleanup(m.MinimockFinish) return m } type mPlaceImageRepositoryMockDelete struct { optional bool mock *PlaceImageRepositoryMock defaultExpectation *PlaceImageRepositoryMockDeleteExpectation expectations []*PlaceImageRepositoryMockDeleteExpectation callArgs []*PlaceImageRepositoryMockDeleteParams mutex sync.RWMutex expectedInvocations uint64 } // PlaceImageRepositoryMockDeleteExpectation specifies expectation struct of the PlaceImageRepository.Delete type PlaceImageRepositoryMockDeleteExpectation struct { mock *PlaceImageRepositoryMock params *PlaceImageRepositoryMockDeleteParams paramPtrs *PlaceImageRepositoryMockDeleteParamPtrs results *PlaceImageRepositoryMockDeleteResults Counter uint64 } // PlaceImageRepositoryMockDeleteParams contains parameters of the PlaceImageRepository.Delete type PlaceImageRepositoryMockDeleteParams struct { ctx context.Context imageID int tx *sql.Tx } // PlaceImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the PlaceImageRepository.Delete type PlaceImageRepositoryMockDeleteParamPtrs struct { ctx *context.Context imageID *int tx **sql.Tx } // PlaceImageRepositoryMockDeleteResults contains results of the PlaceImageRepository.Delete type PlaceImageRepositoryMockDeleteResults 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 *mPlaceImageRepositoryMockDelete) Optional() *mPlaceImageRepositoryMockDelete { mmDelete.optional = true return mmDelete } // Expect sets up expected params for PlaceImageRepository.Delete func (mmDelete *mPlaceImageRepositoryMockDelete) Expect(ctx context.Context, imageID int, tx *sql.Tx) *mPlaceImageRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.paramPtrs != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by ExpectParams functions") } mmDelete.defaultExpectation.params = &PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx} 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 PlaceImageRepository.Delete func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.params != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect") } if mmDelete.defaultExpectation.paramPtrs == nil { mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{} } mmDelete.defaultExpectation.paramPtrs.ctx = &ctx return mmDelete } // ExpectImageIDParam2 sets up expected param imageID for PlaceImageRepository.Delete func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectImageIDParam2(imageID int) *mPlaceImageRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.params != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect") } if mmDelete.defaultExpectation.paramPtrs == nil { mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{} } mmDelete.defaultExpectation.paramPtrs.imageID = &imageID return mmDelete } // ExpectTxParam3 sets up expected param tx for PlaceImageRepository.Delete func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mPlaceImageRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.params != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect") } if mmDelete.defaultExpectation.paramPtrs == nil { mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{} } mmDelete.defaultExpectation.paramPtrs.tx = &tx return mmDelete } // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.Delete func (mmDelete *mPlaceImageRepositoryMockDelete) Inspect(f func(ctx context.Context, imageID int, tx *sql.Tx)) *mPlaceImageRepositoryMockDelete { if mmDelete.mock.inspectFuncDelete != nil { mmDelete.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.Delete") } mmDelete.mock.inspectFuncDelete = f return mmDelete } // Return sets up results that will be returned by PlaceImageRepository.Delete func (mmDelete *mPlaceImageRepositoryMockDelete) Return(err error) *PlaceImageRepositoryMock { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{mock: mmDelete.mock} } mmDelete.defaultExpectation.results = &PlaceImageRepositoryMockDeleteResults{err} return mmDelete.mock } // Set uses given function f to mock the PlaceImageRepository.Delete method func (mmDelete *mPlaceImageRepositoryMockDelete) Set(f func(ctx context.Context, imageID int, tx *sql.Tx) (err error)) *PlaceImageRepositoryMock { if mmDelete.defaultExpectation != nil { mmDelete.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.Delete method") } if len(mmDelete.expectations) > 0 { mmDelete.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.Delete method") } mmDelete.mock.funcDelete = f return mmDelete.mock } // When sets expectation for the PlaceImageRepository.Delete which will trigger the result defined by the following // Then helper func (mmDelete *mPlaceImageRepositoryMockDelete) When(ctx context.Context, imageID int, tx *sql.Tx) *PlaceImageRepositoryMockDeleteExpectation { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set") } expectation := &PlaceImageRepositoryMockDeleteExpectation{ mock: mmDelete.mock, params: &PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx}, } mmDelete.expectations = append(mmDelete.expectations, expectation) return expectation } // Then sets up PlaceImageRepository.Delete return parameters for the expectation previously defined by the When method func (e *PlaceImageRepositoryMockDeleteExpectation) Then(err error) *PlaceImageRepositoryMock { e.results = &PlaceImageRepositoryMockDeleteResults{err} return e.mock } // Times sets number of times PlaceImageRepository.Delete should be invoked func (mmDelete *mPlaceImageRepositoryMockDelete) Times(n uint64) *mPlaceImageRepositoryMockDelete { if n == 0 { mmDelete.mock.t.Fatalf("Times of PlaceImageRepositoryMock.Delete mock can not be zero") } mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n) return mmDelete } func (mmDelete *mPlaceImageRepositoryMockDelete) 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.PlaceImageRepository func (mmDelete *PlaceImageRepositoryMock) Delete(ctx context.Context, imageID int, tx *sql.Tx) (err error) { mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1) defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1) if mmDelete.inspectFuncDelete != nil { mmDelete.inspectFuncDelete(ctx, imageID, tx) } mm_params := PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx} // 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 := PlaceImageRepositoryMockDeleteParams{ctx, imageID, tx} if mm_want_ptrs != nil { if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { mmDelete.t.Errorf("PlaceImageRepositoryMock.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.imageID != nil && !minimock.Equal(*mm_want_ptrs.imageID, mm_got.imageID) { mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameter imageID, want: %#v, got: %#v%s\n", *mm_want_ptrs.imageID, mm_got.imageID, minimock.Diff(*mm_want_ptrs.imageID, mm_got.imageID)) } if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) { mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx)) } } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmDelete.t.Errorf("PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Delete") } return (*mm_results).err } if mmDelete.funcDelete != nil { return mmDelete.funcDelete(ctx, imageID, tx) } mmDelete.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.Delete. %v %v %v", ctx, imageID, tx) return } // DeleteAfterCounter returns a count of finished PlaceImageRepositoryMock.Delete invocations func (mmDelete *PlaceImageRepositoryMock) DeleteAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter) } // DeleteBeforeCounter returns a count of PlaceImageRepositoryMock.Delete invocations func (mmDelete *PlaceImageRepositoryMock) DeleteBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter) } // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.Delete. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmDelete *mPlaceImageRepositoryMockDelete) Calls() []*PlaceImageRepositoryMockDeleteParams { mmDelete.mutex.RLock() argCopy := make([]*PlaceImageRepositoryMockDeleteParams, 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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) MinimockDeleteInspect() { for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Delete") } else { m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Delete") } if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 { m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.Delete but found %d calls", mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter) } } type mPlaceImageRepositoryMockGetByPlaceID struct { optional bool mock *PlaceImageRepositoryMock defaultExpectation *PlaceImageRepositoryMockGetByPlaceIDExpectation expectations []*PlaceImageRepositoryMockGetByPlaceIDExpectation callArgs []*PlaceImageRepositoryMockGetByPlaceIDParams mutex sync.RWMutex expectedInvocations uint64 } // PlaceImageRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the PlaceImageRepository.GetByPlaceID type PlaceImageRepositoryMockGetByPlaceIDExpectation struct { mock *PlaceImageRepositoryMock params *PlaceImageRepositoryMockGetByPlaceIDParams paramPtrs *PlaceImageRepositoryMockGetByPlaceIDParamPtrs results *PlaceImageRepositoryMockGetByPlaceIDResults Counter uint64 } // PlaceImageRepositoryMockGetByPlaceIDParams contains parameters of the PlaceImageRepository.GetByPlaceID type PlaceImageRepositoryMockGetByPlaceIDParams struct { ctx context.Context placeID int } // PlaceImageRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the PlaceImageRepository.GetByPlaceID type PlaceImageRepositoryMockGetByPlaceIDParamPtrs struct { ctx *context.Context placeID *int } // PlaceImageRepositoryMockGetByPlaceIDResults contains results of the PlaceImageRepository.GetByPlaceID type PlaceImageRepositoryMockGetByPlaceIDResults struct { ia1 []models.Image 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 *mPlaceImageRepositoryMockGetByPlaceID) Optional() *mPlaceImageRepositoryMockGetByPlaceID { mmGetByPlaceID.optional = true return mmGetByPlaceID } // Expect sets up expected params for PlaceImageRepository.GetByPlaceID func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mPlaceImageRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{} } if mmGetByPlaceID.defaultExpectation.paramPtrs != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions") } mmGetByPlaceID.defaultExpectation.params = &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID} 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 PlaceImageRepository.GetByPlaceID func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{} } if mmGetByPlaceID.defaultExpectation.params != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Expect") } if mmGetByPlaceID.defaultExpectation.paramPtrs == nil { mmGetByPlaceID.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetByPlaceIDParamPtrs{} } mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx return mmGetByPlaceID } // ExpectPlaceIDParam2 sets up expected param placeID for PlaceImageRepository.GetByPlaceID func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(placeID int) *mPlaceImageRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{} } if mmGetByPlaceID.defaultExpectation.params != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Expect") } if mmGetByPlaceID.defaultExpectation.paramPtrs == nil { mmGetByPlaceID.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetByPlaceIDParamPtrs{} } mmGetByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID return mmGetByPlaceID } // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.GetByPlaceID func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mPlaceImageRepositoryMockGetByPlaceID { if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.GetByPlaceID") } mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f return mmGetByPlaceID } // Return sets up results that will be returned by PlaceImageRepository.GetByPlaceID func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Return(ia1 []models.Image, err error) *PlaceImageRepositoryMock { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set") } if mmGetByPlaceID.defaultExpectation == nil { mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock} } mmGetByPlaceID.defaultExpectation.results = &PlaceImageRepositoryMockGetByPlaceIDResults{ia1, err} return mmGetByPlaceID.mock } // Set uses given function f to mock the PlaceImageRepository.GetByPlaceID method func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ia1 []models.Image, err error)) *PlaceImageRepositoryMock { if mmGetByPlaceID.defaultExpectation != nil { mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.GetByPlaceID method") } if len(mmGetByPlaceID.expectations) > 0 { mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.GetByPlaceID method") } mmGetByPlaceID.mock.funcGetByPlaceID = f return mmGetByPlaceID.mock } // When sets expectation for the PlaceImageRepository.GetByPlaceID which will trigger the result defined by the following // Then helper func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *PlaceImageRepositoryMockGetByPlaceIDExpectation { if mmGetByPlaceID.mock.funcGetByPlaceID != nil { mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set") } expectation := &PlaceImageRepositoryMockGetByPlaceIDExpectation{ mock: mmGetByPlaceID.mock, params: &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID}, } mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation) return expectation } // Then sets up PlaceImageRepository.GetByPlaceID return parameters for the expectation previously defined by the When method func (e *PlaceImageRepositoryMockGetByPlaceIDExpectation) Then(ia1 []models.Image, err error) *PlaceImageRepositoryMock { e.results = &PlaceImageRepositoryMockGetByPlaceIDResults{ia1, err} return e.mock } // Times sets number of times PlaceImageRepository.GetByPlaceID should be invoked func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Times(n uint64) *mPlaceImageRepositoryMockGetByPlaceID { if n == 0 { mmGetByPlaceID.mock.t.Fatalf("Times of PlaceImageRepositoryMock.GetByPlaceID mock can not be zero") } mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n) return mmGetByPlaceID } func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) 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.PlaceImageRepository func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ia1 []models.Image, err error) { mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1) defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1) if mmGetByPlaceID.inspectFuncGetByPlaceID != nil { mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID) } mm_params := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID} // 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.ia1, 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 := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, placeID} if mm_want_ptrs != nil { if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.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.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) { mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.GetByPlaceID got unexpected parameter placeID, want: %#v, got: %#v%s\n", *mm_want_ptrs.placeID, mm_got.placeID, minimock.Diff(*mm_want_ptrs.placeID, mm_got.placeID)) } } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.GetByPlaceID") } return (*mm_results).ia1, (*mm_results).err } if mmGetByPlaceID.funcGetByPlaceID != nil { return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID) } mmGetByPlaceID.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.GetByPlaceID. %v %v", ctx, placeID) return } // GetByPlaceIDAfterCounter returns a count of finished PlaceImageRepositoryMock.GetByPlaceID invocations func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceIDAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter) } // GetByPlaceIDBeforeCounter returns a count of PlaceImageRepositoryMock.GetByPlaceID invocations func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceIDBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter) } // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.GetByPlaceID. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Calls() []*PlaceImageRepositoryMockGetByPlaceIDParams { mmGetByPlaceID.mutex.RLock() argCopy := make([]*PlaceImageRepositoryMockGetByPlaceIDParams, 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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) MinimockGetByPlaceIDInspect() { for _, e := range m.GetByPlaceIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.GetByPlaceID") } else { m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.GetByPlaceID") } if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 { m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) minimockDone() bool { done := true return done && m.MinimockDeleteDone() && m.MinimockGetByPlaceIDDone() }