package mocks // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. //go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.IArticleRepository -o ./mocks/i_article_repository_minimock.go -n IArticleRepositoryMock import ( "context" "sync" mm_atomic "sync/atomic" mm_time "time" "github.com/dmitriygnatenko/internal/models" "github.com/gojuno/minimock/v3" ) // IArticleRepositoryMock implements interfaces.IArticleRepository type IArticleRepositoryMock struct { t minimock.Tester funcAdd func(ctx context.Context, m models.Article) (i1 int, err error) inspectFuncAdd func(ctx context.Context, m models.Article) afterAddCounter uint64 beforeAddCounter uint64 AddMock mIArticleRepositoryMockAdd funcDelete func(ctx context.Context, ID int) (err error) inspectFuncDelete func(ctx context.Context, ID int) afterDeleteCounter uint64 beforeDeleteCounter uint64 DeleteMock mIArticleRepositoryMockDelete funcGetAll func(ctx context.Context) (aa1 []models.Article, err error) inspectFuncGetAll func(ctx context.Context) afterGetAllCounter uint64 beforeGetAllCounter uint64 GetAllMock mIArticleRepositoryMockGetAll funcGetAllPreview func(ctx context.Context) (aa1 []models.ArticlePreview, err error) inspectFuncGetAllPreview func(ctx context.Context) afterGetAllPreviewCounter uint64 beforeGetAllPreviewCounter uint64 GetAllPreviewMock mIArticleRepositoryMockGetAllPreview funcGetByID func(ctx context.Context, ID int) (ap1 *models.Article, err error) inspectFuncGetByID func(ctx context.Context, ID int) afterGetByIDCounter uint64 beforeGetByIDCounter uint64 GetByIDMock mIArticleRepositoryMockGetByID funcGetByURL func(ctx context.Context, url string) (ap1 *models.Article, err error) inspectFuncGetByURL func(ctx context.Context, url string) afterGetByURLCounter uint64 beforeGetByURLCounter uint64 GetByURLMock mIArticleRepositoryMockGetByURL funcGetPreviewByTagID func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error) inspectFuncGetPreviewByTagID func(ctx context.Context, tagID int) afterGetPreviewByTagIDCounter uint64 beforeGetPreviewByTagIDCounter uint64 GetPreviewByTagIDMock mIArticleRepositoryMockGetPreviewByTagID funcUpdate func(ctx context.Context, m models.Article) (err error) inspectFuncUpdate func(ctx context.Context, m models.Article) afterUpdateCounter uint64 beforeUpdateCounter uint64 UpdateMock mIArticleRepositoryMockUpdate } // NewIArticleRepositoryMock returns a mock for interfaces.IArticleRepository func NewIArticleRepositoryMock(t minimock.Tester) *IArticleRepositoryMock { m := &IArticleRepositoryMock{t: t} if controller, ok := t.(minimock.MockController); ok { controller.RegisterMocker(m) } m.AddMock = mIArticleRepositoryMockAdd{mock: m} m.AddMock.callArgs = []*IArticleRepositoryMockAddParams{} m.DeleteMock = mIArticleRepositoryMockDelete{mock: m} m.DeleteMock.callArgs = []*IArticleRepositoryMockDeleteParams{} m.GetAllMock = mIArticleRepositoryMockGetAll{mock: m} m.GetAllMock.callArgs = []*IArticleRepositoryMockGetAllParams{} m.GetAllPreviewMock = mIArticleRepositoryMockGetAllPreview{mock: m} m.GetAllPreviewMock.callArgs = []*IArticleRepositoryMockGetAllPreviewParams{} m.GetByIDMock = mIArticleRepositoryMockGetByID{mock: m} m.GetByIDMock.callArgs = []*IArticleRepositoryMockGetByIDParams{} m.GetByURLMock = mIArticleRepositoryMockGetByURL{mock: m} m.GetByURLMock.callArgs = []*IArticleRepositoryMockGetByURLParams{} m.GetPreviewByTagIDMock = mIArticleRepositoryMockGetPreviewByTagID{mock: m} m.GetPreviewByTagIDMock.callArgs = []*IArticleRepositoryMockGetPreviewByTagIDParams{} m.UpdateMock = mIArticleRepositoryMockUpdate{mock: m} m.UpdateMock.callArgs = []*IArticleRepositoryMockUpdateParams{} return m } type mIArticleRepositoryMockAdd struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockAddExpectation expectations []*IArticleRepositoryMockAddExpectation callArgs []*IArticleRepositoryMockAddParams mutex sync.RWMutex } // IArticleRepositoryMockAddExpectation specifies expectation struct of the IArticleRepository.Add type IArticleRepositoryMockAddExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockAddParams results *IArticleRepositoryMockAddResults Counter uint64 } // IArticleRepositoryMockAddParams contains parameters of the IArticleRepository.Add type IArticleRepositoryMockAddParams struct { ctx context.Context m models.Article } // IArticleRepositoryMockAddResults contains results of the IArticleRepository.Add type IArticleRepositoryMockAddResults struct { i1 int err error } // Expect sets up expected params for IArticleRepository.Add func (mmAdd *mIArticleRepositoryMockAdd) Expect(ctx context.Context, m models.Article) *mIArticleRepositoryMockAdd { if mmAdd.mock.funcAdd != nil { mmAdd.mock.t.Fatalf("IArticleRepositoryMock.Add mock is already set by Set") } if mmAdd.defaultExpectation == nil { mmAdd.defaultExpectation = &IArticleRepositoryMockAddExpectation{} } mmAdd.defaultExpectation.params = &IArticleRepositoryMockAddParams{ctx, m} for _, e := range mmAdd.expectations { if minimock.Equal(e.params, mmAdd.defaultExpectation.params) { mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params) } } return mmAdd } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.Add func (mmAdd *mIArticleRepositoryMockAdd) Inspect(f func(ctx context.Context, m models.Article)) *mIArticleRepositoryMockAdd { if mmAdd.mock.inspectFuncAdd != nil { mmAdd.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.Add") } mmAdd.mock.inspectFuncAdd = f return mmAdd } // Return sets up results that will be returned by IArticleRepository.Add func (mmAdd *mIArticleRepositoryMockAdd) Return(i1 int, err error) *IArticleRepositoryMock { if mmAdd.mock.funcAdd != nil { mmAdd.mock.t.Fatalf("IArticleRepositoryMock.Add mock is already set by Set") } if mmAdd.defaultExpectation == nil { mmAdd.defaultExpectation = &IArticleRepositoryMockAddExpectation{mock: mmAdd.mock} } mmAdd.defaultExpectation.results = &IArticleRepositoryMockAddResults{i1, err} return mmAdd.mock } //Set uses given function f to mock the IArticleRepository.Add method func (mmAdd *mIArticleRepositoryMockAdd) Set(f func(ctx context.Context, m models.Article) (i1 int, err error)) *IArticleRepositoryMock { if mmAdd.defaultExpectation != nil { mmAdd.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.Add method") } if len(mmAdd.expectations) > 0 { mmAdd.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.Add method") } mmAdd.mock.funcAdd = f return mmAdd.mock } // When sets expectation for the IArticleRepository.Add which will trigger the result defined by the following // Then helper func (mmAdd *mIArticleRepositoryMockAdd) When(ctx context.Context, m models.Article) *IArticleRepositoryMockAddExpectation { if mmAdd.mock.funcAdd != nil { mmAdd.mock.t.Fatalf("IArticleRepositoryMock.Add mock is already set by Set") } expectation := &IArticleRepositoryMockAddExpectation{ mock: mmAdd.mock, params: &IArticleRepositoryMockAddParams{ctx, m}, } mmAdd.expectations = append(mmAdd.expectations, expectation) return expectation } // Then sets up IArticleRepository.Add return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockAddExpectation) Then(i1 int, err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockAddResults{i1, err} return e.mock } // Add implements interfaces.IArticleRepository func (mmAdd *IArticleRepositoryMock) Add(ctx context.Context, m models.Article) (i1 int, err error) { mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1) defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1) if mmAdd.inspectFuncAdd != nil { mmAdd.inspectFuncAdd(ctx, m) } mm_params := &IArticleRepositoryMockAddParams{ctx, m} // Record call args mmAdd.AddMock.mutex.Lock() mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params) mmAdd.AddMock.mutex.Unlock() for _, e := range mmAdd.AddMock.expectations { if minimock.Equal(e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.i1, e.results.err } } if mmAdd.AddMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1) mm_want := mmAdd.AddMock.defaultExpectation.params mm_got := IArticleRepositoryMockAddParams{ctx, m} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmAdd.t.Errorf("IArticleRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmAdd.AddMock.defaultExpectation.results if mm_results == nil { mmAdd.t.Fatal("No results are set for the IArticleRepositoryMock.Add") } return (*mm_results).i1, (*mm_results).err } if mmAdd.funcAdd != nil { return mmAdd.funcAdd(ctx, m) } mmAdd.t.Fatalf("Unexpected call to IArticleRepositoryMock.Add. %v %v", ctx, m) return } // AddAfterCounter returns a count of finished IArticleRepositoryMock.Add invocations func (mmAdd *IArticleRepositoryMock) AddAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmAdd.afterAddCounter) } // AddBeforeCounter returns a count of IArticleRepositoryMock.Add invocations func (mmAdd *IArticleRepositoryMock) AddBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.Add. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmAdd *mIArticleRepositoryMockAdd) Calls() []*IArticleRepositoryMockAddParams { mmAdd.mutex.RLock() argCopy := make([]*IArticleRepositoryMockAddParams, len(mmAdd.callArgs)) copy(argCopy, mmAdd.callArgs) mmAdd.mutex.RUnlock() return argCopy } // MinimockAddDone returns true if the count of the Add invocations corresponds // the number of defined expectations func (m *IArticleRepositoryMock) MinimockAddDone() bool { for _, e := range m.AddMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 { return false } return true } // MinimockAddInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockAddInspect() { for _, e := range m.AddMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.Add with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 { if m.AddMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.Add") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.Add") } } type mIArticleRepositoryMockDelete struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockDeleteExpectation expectations []*IArticleRepositoryMockDeleteExpectation callArgs []*IArticleRepositoryMockDeleteParams mutex sync.RWMutex } // IArticleRepositoryMockDeleteExpectation specifies expectation struct of the IArticleRepository.Delete type IArticleRepositoryMockDeleteExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockDeleteParams results *IArticleRepositoryMockDeleteResults Counter uint64 } // IArticleRepositoryMockDeleteParams contains parameters of the IArticleRepository.Delete type IArticleRepositoryMockDeleteParams struct { ctx context.Context ID int } // IArticleRepositoryMockDeleteResults contains results of the IArticleRepository.Delete type IArticleRepositoryMockDeleteResults struct { err error } // Expect sets up expected params for IArticleRepository.Delete func (mmDelete *mIArticleRepositoryMockDelete) Expect(ctx context.Context, ID int) *mIArticleRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("IArticleRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &IArticleRepositoryMockDeleteExpectation{} } mmDelete.defaultExpectation.params = &IArticleRepositoryMockDeleteParams{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 } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.Delete func (mmDelete *mIArticleRepositoryMockDelete) Inspect(f func(ctx context.Context, ID int)) *mIArticleRepositoryMockDelete { if mmDelete.mock.inspectFuncDelete != nil { mmDelete.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.Delete") } mmDelete.mock.inspectFuncDelete = f return mmDelete } // Return sets up results that will be returned by IArticleRepository.Delete func (mmDelete *mIArticleRepositoryMockDelete) Return(err error) *IArticleRepositoryMock { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("IArticleRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &IArticleRepositoryMockDeleteExpectation{mock: mmDelete.mock} } mmDelete.defaultExpectation.results = &IArticleRepositoryMockDeleteResults{err} return mmDelete.mock } //Set uses given function f to mock the IArticleRepository.Delete method func (mmDelete *mIArticleRepositoryMockDelete) Set(f func(ctx context.Context, ID int) (err error)) *IArticleRepositoryMock { if mmDelete.defaultExpectation != nil { mmDelete.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.Delete method") } if len(mmDelete.expectations) > 0 { mmDelete.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.Delete method") } mmDelete.mock.funcDelete = f return mmDelete.mock } // When sets expectation for the IArticleRepository.Delete which will trigger the result defined by the following // Then helper func (mmDelete *mIArticleRepositoryMockDelete) When(ctx context.Context, ID int) *IArticleRepositoryMockDeleteExpectation { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("IArticleRepositoryMock.Delete mock is already set by Set") } expectation := &IArticleRepositoryMockDeleteExpectation{ mock: mmDelete.mock, params: &IArticleRepositoryMockDeleteParams{ctx, ID}, } mmDelete.expectations = append(mmDelete.expectations, expectation) return expectation } // Then sets up IArticleRepository.Delete return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockDeleteExpectation) Then(err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockDeleteResults{err} return e.mock } // Delete implements interfaces.IArticleRepository func (mmDelete *IArticleRepositoryMock) Delete(ctx context.Context, ID int) (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 := &IArticleRepositoryMockDeleteParams{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_got := IArticleRepositoryMockDeleteParams{ctx, ID} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmDelete.t.Errorf("IArticleRepositoryMock.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 IArticleRepositoryMock.Delete") } return (*mm_results).err } if mmDelete.funcDelete != nil { return mmDelete.funcDelete(ctx, ID) } mmDelete.t.Fatalf("Unexpected call to IArticleRepositoryMock.Delete. %v %v", ctx, ID) return } // DeleteAfterCounter returns a count of finished IArticleRepositoryMock.Delete invocations func (mmDelete *IArticleRepositoryMock) DeleteAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter) } // DeleteBeforeCounter returns a count of IArticleRepositoryMock.Delete invocations func (mmDelete *IArticleRepositoryMock) DeleteBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.Delete. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmDelete *mIArticleRepositoryMockDelete) Calls() []*IArticleRepositoryMockDeleteParams { mmDelete.mutex.RLock() argCopy := make([]*IArticleRepositoryMockDeleteParams, 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 *IArticleRepositoryMock) MinimockDeleteDone() bool { for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 { return false } return true } // MinimockDeleteInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockDeleteInspect() { for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.Delete with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 { if m.DeleteMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.Delete") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.Delete") } } type mIArticleRepositoryMockGetAll struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockGetAllExpectation expectations []*IArticleRepositoryMockGetAllExpectation callArgs []*IArticleRepositoryMockGetAllParams mutex sync.RWMutex } // IArticleRepositoryMockGetAllExpectation specifies expectation struct of the IArticleRepository.GetAll type IArticleRepositoryMockGetAllExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockGetAllParams results *IArticleRepositoryMockGetAllResults Counter uint64 } // IArticleRepositoryMockGetAllParams contains parameters of the IArticleRepository.GetAll type IArticleRepositoryMockGetAllParams struct { ctx context.Context } // IArticleRepositoryMockGetAllResults contains results of the IArticleRepository.GetAll type IArticleRepositoryMockGetAllResults struct { aa1 []models.Article err error } // Expect sets up expected params for IArticleRepository.GetAll func (mmGetAll *mIArticleRepositoryMockGetAll) Expect(ctx context.Context) *mIArticleRepositoryMockGetAll { if mmGetAll.mock.funcGetAll != nil { mmGetAll.mock.t.Fatalf("IArticleRepositoryMock.GetAll mock is already set by Set") } if mmGetAll.defaultExpectation == nil { mmGetAll.defaultExpectation = &IArticleRepositoryMockGetAllExpectation{} } mmGetAll.defaultExpectation.params = &IArticleRepositoryMockGetAllParams{ctx} for _, e := range mmGetAll.expectations { if minimock.Equal(e.params, mmGetAll.defaultExpectation.params) { mmGetAll.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAll.defaultExpectation.params) } } return mmGetAll } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.GetAll func (mmGetAll *mIArticleRepositoryMockGetAll) Inspect(f func(ctx context.Context)) *mIArticleRepositoryMockGetAll { if mmGetAll.mock.inspectFuncGetAll != nil { mmGetAll.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.GetAll") } mmGetAll.mock.inspectFuncGetAll = f return mmGetAll } // Return sets up results that will be returned by IArticleRepository.GetAll func (mmGetAll *mIArticleRepositoryMockGetAll) Return(aa1 []models.Article, err error) *IArticleRepositoryMock { if mmGetAll.mock.funcGetAll != nil { mmGetAll.mock.t.Fatalf("IArticleRepositoryMock.GetAll mock is already set by Set") } if mmGetAll.defaultExpectation == nil { mmGetAll.defaultExpectation = &IArticleRepositoryMockGetAllExpectation{mock: mmGetAll.mock} } mmGetAll.defaultExpectation.results = &IArticleRepositoryMockGetAllResults{aa1, err} return mmGetAll.mock } //Set uses given function f to mock the IArticleRepository.GetAll method func (mmGetAll *mIArticleRepositoryMockGetAll) Set(f func(ctx context.Context) (aa1 []models.Article, err error)) *IArticleRepositoryMock { if mmGetAll.defaultExpectation != nil { mmGetAll.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.GetAll method") } if len(mmGetAll.expectations) > 0 { mmGetAll.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.GetAll method") } mmGetAll.mock.funcGetAll = f return mmGetAll.mock } // When sets expectation for the IArticleRepository.GetAll which will trigger the result defined by the following // Then helper func (mmGetAll *mIArticleRepositoryMockGetAll) When(ctx context.Context) *IArticleRepositoryMockGetAllExpectation { if mmGetAll.mock.funcGetAll != nil { mmGetAll.mock.t.Fatalf("IArticleRepositoryMock.GetAll mock is already set by Set") } expectation := &IArticleRepositoryMockGetAllExpectation{ mock: mmGetAll.mock, params: &IArticleRepositoryMockGetAllParams{ctx}, } mmGetAll.expectations = append(mmGetAll.expectations, expectation) return expectation } // Then sets up IArticleRepository.GetAll return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockGetAllExpectation) Then(aa1 []models.Article, err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockGetAllResults{aa1, err} return e.mock } // GetAll implements interfaces.IArticleRepository func (mmGetAll *IArticleRepositoryMock) GetAll(ctx context.Context) (aa1 []models.Article, err error) { mm_atomic.AddUint64(&mmGetAll.beforeGetAllCounter, 1) defer mm_atomic.AddUint64(&mmGetAll.afterGetAllCounter, 1) if mmGetAll.inspectFuncGetAll != nil { mmGetAll.inspectFuncGetAll(ctx) } mm_params := &IArticleRepositoryMockGetAllParams{ctx} // Record call args mmGetAll.GetAllMock.mutex.Lock() mmGetAll.GetAllMock.callArgs = append(mmGetAll.GetAllMock.callArgs, mm_params) mmGetAll.GetAllMock.mutex.Unlock() for _, e := range mmGetAll.GetAllMock.expectations { if minimock.Equal(e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.aa1, e.results.err } } if mmGetAll.GetAllMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmGetAll.GetAllMock.defaultExpectation.Counter, 1) mm_want := mmGetAll.GetAllMock.defaultExpectation.params mm_got := IArticleRepositoryMockGetAllParams{ctx} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetAll.t.Errorf("IArticleRepositoryMock.GetAll got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmGetAll.GetAllMock.defaultExpectation.results if mm_results == nil { mmGetAll.t.Fatal("No results are set for the IArticleRepositoryMock.GetAll") } return (*mm_results).aa1, (*mm_results).err } if mmGetAll.funcGetAll != nil { return mmGetAll.funcGetAll(ctx) } mmGetAll.t.Fatalf("Unexpected call to IArticleRepositoryMock.GetAll. %v", ctx) return } // GetAllAfterCounter returns a count of finished IArticleRepositoryMock.GetAll invocations func (mmGetAll *IArticleRepositoryMock) GetAllAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter) } // GetAllBeforeCounter returns a count of IArticleRepositoryMock.GetAll invocations func (mmGetAll *IArticleRepositoryMock) GetAllBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.GetAll. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetAll *mIArticleRepositoryMockGetAll) Calls() []*IArticleRepositoryMockGetAllParams { mmGetAll.mutex.RLock() argCopy := make([]*IArticleRepositoryMockGetAllParams, len(mmGetAll.callArgs)) copy(argCopy, mmGetAll.callArgs) mmGetAll.mutex.RUnlock() return argCopy } // MinimockGetAllDone returns true if the count of the GetAll invocations corresponds // the number of defined expectations func (m *IArticleRepositoryMock) MinimockGetAllDone() bool { for _, e := range m.GetAllMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 { return false } return true } // MinimockGetAllInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockGetAllInspect() { for _, e := range m.GetAllMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.GetAll with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 { if m.GetAllMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.GetAll") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.GetAll with params: %#v", *m.GetAllMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.GetAll") } } type mIArticleRepositoryMockGetAllPreview struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockGetAllPreviewExpectation expectations []*IArticleRepositoryMockGetAllPreviewExpectation callArgs []*IArticleRepositoryMockGetAllPreviewParams mutex sync.RWMutex } // IArticleRepositoryMockGetAllPreviewExpectation specifies expectation struct of the IArticleRepository.GetAllPreview type IArticleRepositoryMockGetAllPreviewExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockGetAllPreviewParams results *IArticleRepositoryMockGetAllPreviewResults Counter uint64 } // IArticleRepositoryMockGetAllPreviewParams contains parameters of the IArticleRepository.GetAllPreview type IArticleRepositoryMockGetAllPreviewParams struct { ctx context.Context } // IArticleRepositoryMockGetAllPreviewResults contains results of the IArticleRepository.GetAllPreview type IArticleRepositoryMockGetAllPreviewResults struct { aa1 []models.ArticlePreview err error } // Expect sets up expected params for IArticleRepository.GetAllPreview func (mmGetAllPreview *mIArticleRepositoryMockGetAllPreview) Expect(ctx context.Context) *mIArticleRepositoryMockGetAllPreview { if mmGetAllPreview.mock.funcGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("IArticleRepositoryMock.GetAllPreview mock is already set by Set") } if mmGetAllPreview.defaultExpectation == nil { mmGetAllPreview.defaultExpectation = &IArticleRepositoryMockGetAllPreviewExpectation{} } mmGetAllPreview.defaultExpectation.params = &IArticleRepositoryMockGetAllPreviewParams{ctx} for _, e := range mmGetAllPreview.expectations { if minimock.Equal(e.params, mmGetAllPreview.defaultExpectation.params) { mmGetAllPreview.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllPreview.defaultExpectation.params) } } return mmGetAllPreview } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.GetAllPreview func (mmGetAllPreview *mIArticleRepositoryMockGetAllPreview) Inspect(f func(ctx context.Context)) *mIArticleRepositoryMockGetAllPreview { if mmGetAllPreview.mock.inspectFuncGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.GetAllPreview") } mmGetAllPreview.mock.inspectFuncGetAllPreview = f return mmGetAllPreview } // Return sets up results that will be returned by IArticleRepository.GetAllPreview func (mmGetAllPreview *mIArticleRepositoryMockGetAllPreview) Return(aa1 []models.ArticlePreview, err error) *IArticleRepositoryMock { if mmGetAllPreview.mock.funcGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("IArticleRepositoryMock.GetAllPreview mock is already set by Set") } if mmGetAllPreview.defaultExpectation == nil { mmGetAllPreview.defaultExpectation = &IArticleRepositoryMockGetAllPreviewExpectation{mock: mmGetAllPreview.mock} } mmGetAllPreview.defaultExpectation.results = &IArticleRepositoryMockGetAllPreviewResults{aa1, err} return mmGetAllPreview.mock } //Set uses given function f to mock the IArticleRepository.GetAllPreview method func (mmGetAllPreview *mIArticleRepositoryMockGetAllPreview) Set(f func(ctx context.Context) (aa1 []models.ArticlePreview, err error)) *IArticleRepositoryMock { if mmGetAllPreview.defaultExpectation != nil { mmGetAllPreview.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.GetAllPreview method") } if len(mmGetAllPreview.expectations) > 0 { mmGetAllPreview.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.GetAllPreview method") } mmGetAllPreview.mock.funcGetAllPreview = f return mmGetAllPreview.mock } // When sets expectation for the IArticleRepository.GetAllPreview which will trigger the result defined by the following // Then helper func (mmGetAllPreview *mIArticleRepositoryMockGetAllPreview) When(ctx context.Context) *IArticleRepositoryMockGetAllPreviewExpectation { if mmGetAllPreview.mock.funcGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("IArticleRepositoryMock.GetAllPreview mock is already set by Set") } expectation := &IArticleRepositoryMockGetAllPreviewExpectation{ mock: mmGetAllPreview.mock, params: &IArticleRepositoryMockGetAllPreviewParams{ctx}, } mmGetAllPreview.expectations = append(mmGetAllPreview.expectations, expectation) return expectation } // Then sets up IArticleRepository.GetAllPreview return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockGetAllPreviewExpectation) Then(aa1 []models.ArticlePreview, err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockGetAllPreviewResults{aa1, err} return e.mock } // GetAllPreview implements interfaces.IArticleRepository func (mmGetAllPreview *IArticleRepositoryMock) GetAllPreview(ctx context.Context) (aa1 []models.ArticlePreview, err error) { mm_atomic.AddUint64(&mmGetAllPreview.beforeGetAllPreviewCounter, 1) defer mm_atomic.AddUint64(&mmGetAllPreview.afterGetAllPreviewCounter, 1) if mmGetAllPreview.inspectFuncGetAllPreview != nil { mmGetAllPreview.inspectFuncGetAllPreview(ctx) } mm_params := &IArticleRepositoryMockGetAllPreviewParams{ctx} // Record call args mmGetAllPreview.GetAllPreviewMock.mutex.Lock() mmGetAllPreview.GetAllPreviewMock.callArgs = append(mmGetAllPreview.GetAllPreviewMock.callArgs, mm_params) mmGetAllPreview.GetAllPreviewMock.mutex.Unlock() for _, e := range mmGetAllPreview.GetAllPreviewMock.expectations { if minimock.Equal(e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.aa1, e.results.err } } if mmGetAllPreview.GetAllPreviewMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmGetAllPreview.GetAllPreviewMock.defaultExpectation.Counter, 1) mm_want := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.params mm_got := IArticleRepositoryMockGetAllPreviewParams{ctx} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetAllPreview.t.Errorf("IArticleRepositoryMock.GetAllPreview got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.results if mm_results == nil { mmGetAllPreview.t.Fatal("No results are set for the IArticleRepositoryMock.GetAllPreview") } return (*mm_results).aa1, (*mm_results).err } if mmGetAllPreview.funcGetAllPreview != nil { return mmGetAllPreview.funcGetAllPreview(ctx) } mmGetAllPreview.t.Fatalf("Unexpected call to IArticleRepositoryMock.GetAllPreview. %v", ctx) return } // GetAllPreviewAfterCounter returns a count of finished IArticleRepositoryMock.GetAllPreview invocations func (mmGetAllPreview *IArticleRepositoryMock) GetAllPreviewAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAllPreview.afterGetAllPreviewCounter) } // GetAllPreviewBeforeCounter returns a count of IArticleRepositoryMock.GetAllPreview invocations func (mmGetAllPreview *IArticleRepositoryMock) GetAllPreviewBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAllPreview.beforeGetAllPreviewCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.GetAllPreview. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetAllPreview *mIArticleRepositoryMockGetAllPreview) Calls() []*IArticleRepositoryMockGetAllPreviewParams { mmGetAllPreview.mutex.RLock() argCopy := make([]*IArticleRepositoryMockGetAllPreviewParams, len(mmGetAllPreview.callArgs)) copy(argCopy, mmGetAllPreview.callArgs) mmGetAllPreview.mutex.RUnlock() return argCopy } // MinimockGetAllPreviewDone returns true if the count of the GetAllPreview invocations corresponds // the number of defined expectations func (m *IArticleRepositoryMock) MinimockGetAllPreviewDone() bool { for _, e := range m.GetAllPreviewMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.GetAllPreviewMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcGetAllPreview != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 { return false } return true } // MinimockGetAllPreviewInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockGetAllPreviewInspect() { for _, e := range m.GetAllPreviewMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.GetAllPreview with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.GetAllPreviewMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 { if m.GetAllPreviewMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.GetAllPreview") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.GetAllPreview with params: %#v", *m.GetAllPreviewMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcGetAllPreview != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.GetAllPreview") } } type mIArticleRepositoryMockGetByID struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockGetByIDExpectation expectations []*IArticleRepositoryMockGetByIDExpectation callArgs []*IArticleRepositoryMockGetByIDParams mutex sync.RWMutex } // IArticleRepositoryMockGetByIDExpectation specifies expectation struct of the IArticleRepository.GetByID type IArticleRepositoryMockGetByIDExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockGetByIDParams results *IArticleRepositoryMockGetByIDResults Counter uint64 } // IArticleRepositoryMockGetByIDParams contains parameters of the IArticleRepository.GetByID type IArticleRepositoryMockGetByIDParams struct { ctx context.Context ID int } // IArticleRepositoryMockGetByIDResults contains results of the IArticleRepository.GetByID type IArticleRepositoryMockGetByIDResults struct { ap1 *models.Article err error } // Expect sets up expected params for IArticleRepository.GetByID func (mmGetByID *mIArticleRepositoryMockGetByID) Expect(ctx context.Context, ID int) *mIArticleRepositoryMockGetByID { if mmGetByID.mock.funcGetByID != nil { mmGetByID.mock.t.Fatalf("IArticleRepositoryMock.GetByID mock is already set by Set") } if mmGetByID.defaultExpectation == nil { mmGetByID.defaultExpectation = &IArticleRepositoryMockGetByIDExpectation{} } mmGetByID.defaultExpectation.params = &IArticleRepositoryMockGetByIDParams{ctx, ID} for _, e := range mmGetByID.expectations { if minimock.Equal(e.params, mmGetByID.defaultExpectation.params) { mmGetByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByID.defaultExpectation.params) } } return mmGetByID } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.GetByID func (mmGetByID *mIArticleRepositoryMockGetByID) Inspect(f func(ctx context.Context, ID int)) *mIArticleRepositoryMockGetByID { if mmGetByID.mock.inspectFuncGetByID != nil { mmGetByID.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.GetByID") } mmGetByID.mock.inspectFuncGetByID = f return mmGetByID } // Return sets up results that will be returned by IArticleRepository.GetByID func (mmGetByID *mIArticleRepositoryMockGetByID) Return(ap1 *models.Article, err error) *IArticleRepositoryMock { if mmGetByID.mock.funcGetByID != nil { mmGetByID.mock.t.Fatalf("IArticleRepositoryMock.GetByID mock is already set by Set") } if mmGetByID.defaultExpectation == nil { mmGetByID.defaultExpectation = &IArticleRepositoryMockGetByIDExpectation{mock: mmGetByID.mock} } mmGetByID.defaultExpectation.results = &IArticleRepositoryMockGetByIDResults{ap1, err} return mmGetByID.mock } //Set uses given function f to mock the IArticleRepository.GetByID method func (mmGetByID *mIArticleRepositoryMockGetByID) Set(f func(ctx context.Context, ID int) (ap1 *models.Article, err error)) *IArticleRepositoryMock { if mmGetByID.defaultExpectation != nil { mmGetByID.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.GetByID method") } if len(mmGetByID.expectations) > 0 { mmGetByID.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.GetByID method") } mmGetByID.mock.funcGetByID = f return mmGetByID.mock } // When sets expectation for the IArticleRepository.GetByID which will trigger the result defined by the following // Then helper func (mmGetByID *mIArticleRepositoryMockGetByID) When(ctx context.Context, ID int) *IArticleRepositoryMockGetByIDExpectation { if mmGetByID.mock.funcGetByID != nil { mmGetByID.mock.t.Fatalf("IArticleRepositoryMock.GetByID mock is already set by Set") } expectation := &IArticleRepositoryMockGetByIDExpectation{ mock: mmGetByID.mock, params: &IArticleRepositoryMockGetByIDParams{ctx, ID}, } mmGetByID.expectations = append(mmGetByID.expectations, expectation) return expectation } // Then sets up IArticleRepository.GetByID return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockGetByIDExpectation) Then(ap1 *models.Article, err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockGetByIDResults{ap1, err} return e.mock } // GetByID implements interfaces.IArticleRepository func (mmGetByID *IArticleRepositoryMock) GetByID(ctx context.Context, ID int) (ap1 *models.Article, err error) { mm_atomic.AddUint64(&mmGetByID.beforeGetByIDCounter, 1) defer mm_atomic.AddUint64(&mmGetByID.afterGetByIDCounter, 1) if mmGetByID.inspectFuncGetByID != nil { mmGetByID.inspectFuncGetByID(ctx, ID) } mm_params := &IArticleRepositoryMockGetByIDParams{ctx, ID} // Record call args mmGetByID.GetByIDMock.mutex.Lock() mmGetByID.GetByIDMock.callArgs = append(mmGetByID.GetByIDMock.callArgs, mm_params) mmGetByID.GetByIDMock.mutex.Unlock() for _, e := range mmGetByID.GetByIDMock.expectations { if minimock.Equal(e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.ap1, e.results.err } } if mmGetByID.GetByIDMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmGetByID.GetByIDMock.defaultExpectation.Counter, 1) mm_want := mmGetByID.GetByIDMock.defaultExpectation.params mm_got := IArticleRepositoryMockGetByIDParams{ctx, ID} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetByID.t.Errorf("IArticleRepositoryMock.GetByID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmGetByID.GetByIDMock.defaultExpectation.results if mm_results == nil { mmGetByID.t.Fatal("No results are set for the IArticleRepositoryMock.GetByID") } return (*mm_results).ap1, (*mm_results).err } if mmGetByID.funcGetByID != nil { return mmGetByID.funcGetByID(ctx, ID) } mmGetByID.t.Fatalf("Unexpected call to IArticleRepositoryMock.GetByID. %v %v", ctx, ID) return } // GetByIDAfterCounter returns a count of finished IArticleRepositoryMock.GetByID invocations func (mmGetByID *IArticleRepositoryMock) GetByIDAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByID.afterGetByIDCounter) } // GetByIDBeforeCounter returns a count of IArticleRepositoryMock.GetByID invocations func (mmGetByID *IArticleRepositoryMock) GetByIDBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByID.beforeGetByIDCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.GetByID. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetByID *mIArticleRepositoryMockGetByID) Calls() []*IArticleRepositoryMockGetByIDParams { mmGetByID.mutex.RLock() argCopy := make([]*IArticleRepositoryMockGetByIDParams, len(mmGetByID.callArgs)) copy(argCopy, mmGetByID.callArgs) mmGetByID.mutex.RUnlock() return argCopy } // MinimockGetByIDDone returns true if the count of the GetByID invocations corresponds // the number of defined expectations func (m *IArticleRepositoryMock) MinimockGetByIDDone() bool { for _, e := range m.GetByIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 { return false } return true } // MinimockGetByIDInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockGetByIDInspect() { for _, e := range m.GetByIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.GetByID with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 { if m.GetByIDMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.GetByID") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.GetByID with params: %#v", *m.GetByIDMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.GetByID") } } type mIArticleRepositoryMockGetByURL struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockGetByURLExpectation expectations []*IArticleRepositoryMockGetByURLExpectation callArgs []*IArticleRepositoryMockGetByURLParams mutex sync.RWMutex } // IArticleRepositoryMockGetByURLExpectation specifies expectation struct of the IArticleRepository.GetByURL type IArticleRepositoryMockGetByURLExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockGetByURLParams results *IArticleRepositoryMockGetByURLResults Counter uint64 } // IArticleRepositoryMockGetByURLParams contains parameters of the IArticleRepository.GetByURL type IArticleRepositoryMockGetByURLParams struct { ctx context.Context url string } // IArticleRepositoryMockGetByURLResults contains results of the IArticleRepository.GetByURL type IArticleRepositoryMockGetByURLResults struct { ap1 *models.Article err error } // Expect sets up expected params for IArticleRepository.GetByURL func (mmGetByURL *mIArticleRepositoryMockGetByURL) Expect(ctx context.Context, url string) *mIArticleRepositoryMockGetByURL { if mmGetByURL.mock.funcGetByURL != nil { mmGetByURL.mock.t.Fatalf("IArticleRepositoryMock.GetByURL mock is already set by Set") } if mmGetByURL.defaultExpectation == nil { mmGetByURL.defaultExpectation = &IArticleRepositoryMockGetByURLExpectation{} } mmGetByURL.defaultExpectation.params = &IArticleRepositoryMockGetByURLParams{ctx, url} for _, e := range mmGetByURL.expectations { if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) { mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params) } } return mmGetByURL } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.GetByURL func (mmGetByURL *mIArticleRepositoryMockGetByURL) Inspect(f func(ctx context.Context, url string)) *mIArticleRepositoryMockGetByURL { if mmGetByURL.mock.inspectFuncGetByURL != nil { mmGetByURL.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.GetByURL") } mmGetByURL.mock.inspectFuncGetByURL = f return mmGetByURL } // Return sets up results that will be returned by IArticleRepository.GetByURL func (mmGetByURL *mIArticleRepositoryMockGetByURL) Return(ap1 *models.Article, err error) *IArticleRepositoryMock { if mmGetByURL.mock.funcGetByURL != nil { mmGetByURL.mock.t.Fatalf("IArticleRepositoryMock.GetByURL mock is already set by Set") } if mmGetByURL.defaultExpectation == nil { mmGetByURL.defaultExpectation = &IArticleRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock} } mmGetByURL.defaultExpectation.results = &IArticleRepositoryMockGetByURLResults{ap1, err} return mmGetByURL.mock } //Set uses given function f to mock the IArticleRepository.GetByURL method func (mmGetByURL *mIArticleRepositoryMockGetByURL) Set(f func(ctx context.Context, url string) (ap1 *models.Article, err error)) *IArticleRepositoryMock { if mmGetByURL.defaultExpectation != nil { mmGetByURL.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.GetByURL method") } if len(mmGetByURL.expectations) > 0 { mmGetByURL.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.GetByURL method") } mmGetByURL.mock.funcGetByURL = f return mmGetByURL.mock } // When sets expectation for the IArticleRepository.GetByURL which will trigger the result defined by the following // Then helper func (mmGetByURL *mIArticleRepositoryMockGetByURL) When(ctx context.Context, url string) *IArticleRepositoryMockGetByURLExpectation { if mmGetByURL.mock.funcGetByURL != nil { mmGetByURL.mock.t.Fatalf("IArticleRepositoryMock.GetByURL mock is already set by Set") } expectation := &IArticleRepositoryMockGetByURLExpectation{ mock: mmGetByURL.mock, params: &IArticleRepositoryMockGetByURLParams{ctx, url}, } mmGetByURL.expectations = append(mmGetByURL.expectations, expectation) return expectation } // Then sets up IArticleRepository.GetByURL return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockGetByURLExpectation) Then(ap1 *models.Article, err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockGetByURLResults{ap1, err} return e.mock } // GetByURL implements interfaces.IArticleRepository func (mmGetByURL *IArticleRepositoryMock) GetByURL(ctx context.Context, url string) (ap1 *models.Article, err error) { mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1) defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1) if mmGetByURL.inspectFuncGetByURL != nil { mmGetByURL.inspectFuncGetByURL(ctx, url) } mm_params := &IArticleRepositoryMockGetByURLParams{ctx, url} // Record call args mmGetByURL.GetByURLMock.mutex.Lock() mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, mm_params) mmGetByURL.GetByURLMock.mutex.Unlock() for _, e := range mmGetByURL.GetByURLMock.expectations { if minimock.Equal(e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.ap1, e.results.err } } if mmGetByURL.GetByURLMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1) mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params mm_got := IArticleRepositoryMockGetByURLParams{ctx, url} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetByURL.t.Errorf("IArticleRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results if mm_results == nil { mmGetByURL.t.Fatal("No results are set for the IArticleRepositoryMock.GetByURL") } return (*mm_results).ap1, (*mm_results).err } if mmGetByURL.funcGetByURL != nil { return mmGetByURL.funcGetByURL(ctx, url) } mmGetByURL.t.Fatalf("Unexpected call to IArticleRepositoryMock.GetByURL. %v %v", ctx, url) return } // GetByURLAfterCounter returns a count of finished IArticleRepositoryMock.GetByURL invocations func (mmGetByURL *IArticleRepositoryMock) GetByURLAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter) } // GetByURLBeforeCounter returns a count of IArticleRepositoryMock.GetByURL invocations func (mmGetByURL *IArticleRepositoryMock) GetByURLBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.GetByURL. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetByURL *mIArticleRepositoryMockGetByURL) Calls() []*IArticleRepositoryMockGetByURLParams { mmGetByURL.mutex.RLock() argCopy := make([]*IArticleRepositoryMockGetByURLParams, len(mmGetByURL.callArgs)) copy(argCopy, mmGetByURL.callArgs) mmGetByURL.mutex.RUnlock() return argCopy } // MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds // the number of defined expectations func (m *IArticleRepositoryMock) MinimockGetByURLDone() bool { for _, e := range m.GetByURLMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 { return false } return true } // MinimockGetByURLInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockGetByURLInspect() { for _, e := range m.GetByURLMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.GetByURL with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 { if m.GetByURLMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.GetByURL") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.GetByURL") } } type mIArticleRepositoryMockGetPreviewByTagID struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockGetPreviewByTagIDExpectation expectations []*IArticleRepositoryMockGetPreviewByTagIDExpectation callArgs []*IArticleRepositoryMockGetPreviewByTagIDParams mutex sync.RWMutex } // IArticleRepositoryMockGetPreviewByTagIDExpectation specifies expectation struct of the IArticleRepository.GetPreviewByTagID type IArticleRepositoryMockGetPreviewByTagIDExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockGetPreviewByTagIDParams results *IArticleRepositoryMockGetPreviewByTagIDResults Counter uint64 } // IArticleRepositoryMockGetPreviewByTagIDParams contains parameters of the IArticleRepository.GetPreviewByTagID type IArticleRepositoryMockGetPreviewByTagIDParams struct { ctx context.Context tagID int } // IArticleRepositoryMockGetPreviewByTagIDResults contains results of the IArticleRepository.GetPreviewByTagID type IArticleRepositoryMockGetPreviewByTagIDResults struct { aa1 []models.ArticlePreview err error } // Expect sets up expected params for IArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mIArticleRepositoryMockGetPreviewByTagID) Expect(ctx context.Context, tagID int) *mIArticleRepositoryMockGetPreviewByTagID { if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("IArticleRepositoryMock.GetPreviewByTagID mock is already set by Set") } if mmGetPreviewByTagID.defaultExpectation == nil { mmGetPreviewByTagID.defaultExpectation = &IArticleRepositoryMockGetPreviewByTagIDExpectation{} } mmGetPreviewByTagID.defaultExpectation.params = &IArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID} for _, e := range mmGetPreviewByTagID.expectations { if minimock.Equal(e.params, mmGetPreviewByTagID.defaultExpectation.params) { mmGetPreviewByTagID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetPreviewByTagID.defaultExpectation.params) } } return mmGetPreviewByTagID } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mIArticleRepositoryMockGetPreviewByTagID) Inspect(f func(ctx context.Context, tagID int)) *mIArticleRepositoryMockGetPreviewByTagID { if mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.GetPreviewByTagID") } mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID = f return mmGetPreviewByTagID } // Return sets up results that will be returned by IArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mIArticleRepositoryMockGetPreviewByTagID) Return(aa1 []models.ArticlePreview, err error) *IArticleRepositoryMock { if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("IArticleRepositoryMock.GetPreviewByTagID mock is already set by Set") } if mmGetPreviewByTagID.defaultExpectation == nil { mmGetPreviewByTagID.defaultExpectation = &IArticleRepositoryMockGetPreviewByTagIDExpectation{mock: mmGetPreviewByTagID.mock} } mmGetPreviewByTagID.defaultExpectation.results = &IArticleRepositoryMockGetPreviewByTagIDResults{aa1, err} return mmGetPreviewByTagID.mock } //Set uses given function f to mock the IArticleRepository.GetPreviewByTagID method func (mmGetPreviewByTagID *mIArticleRepositoryMockGetPreviewByTagID) Set(f func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)) *IArticleRepositoryMock { if mmGetPreviewByTagID.defaultExpectation != nil { mmGetPreviewByTagID.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.GetPreviewByTagID method") } if len(mmGetPreviewByTagID.expectations) > 0 { mmGetPreviewByTagID.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.GetPreviewByTagID method") } mmGetPreviewByTagID.mock.funcGetPreviewByTagID = f return mmGetPreviewByTagID.mock } // When sets expectation for the IArticleRepository.GetPreviewByTagID which will trigger the result defined by the following // Then helper func (mmGetPreviewByTagID *mIArticleRepositoryMockGetPreviewByTagID) When(ctx context.Context, tagID int) *IArticleRepositoryMockGetPreviewByTagIDExpectation { if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("IArticleRepositoryMock.GetPreviewByTagID mock is already set by Set") } expectation := &IArticleRepositoryMockGetPreviewByTagIDExpectation{ mock: mmGetPreviewByTagID.mock, params: &IArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}, } mmGetPreviewByTagID.expectations = append(mmGetPreviewByTagID.expectations, expectation) return expectation } // Then sets up IArticleRepository.GetPreviewByTagID return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockGetPreviewByTagIDExpectation) Then(aa1 []models.ArticlePreview, err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockGetPreviewByTagIDResults{aa1, err} return e.mock } // GetPreviewByTagID implements interfaces.IArticleRepository func (mmGetPreviewByTagID *IArticleRepositoryMock) GetPreviewByTagID(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error) { mm_atomic.AddUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter, 1) defer mm_atomic.AddUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter, 1) if mmGetPreviewByTagID.inspectFuncGetPreviewByTagID != nil { mmGetPreviewByTagID.inspectFuncGetPreviewByTagID(ctx, tagID) } mm_params := &IArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID} // Record call args mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Lock() mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs = append(mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs, mm_params) mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Unlock() for _, e := range mmGetPreviewByTagID.GetPreviewByTagIDMock.expectations { if minimock.Equal(e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.aa1, e.results.err } } if mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.Counter, 1) mm_want := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.params mm_got := IArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetPreviewByTagID.t.Errorf("IArticleRepositoryMock.GetPreviewByTagID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.results if mm_results == nil { mmGetPreviewByTagID.t.Fatal("No results are set for the IArticleRepositoryMock.GetPreviewByTagID") } return (*mm_results).aa1, (*mm_results).err } if mmGetPreviewByTagID.funcGetPreviewByTagID != nil { return mmGetPreviewByTagID.funcGetPreviewByTagID(ctx, tagID) } mmGetPreviewByTagID.t.Fatalf("Unexpected call to IArticleRepositoryMock.GetPreviewByTagID. %v %v", ctx, tagID) return } // GetPreviewByTagIDAfterCounter returns a count of finished IArticleRepositoryMock.GetPreviewByTagID invocations func (mmGetPreviewByTagID *IArticleRepositoryMock) GetPreviewByTagIDAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter) } // GetPreviewByTagIDBeforeCounter returns a count of IArticleRepositoryMock.GetPreviewByTagID invocations func (mmGetPreviewByTagID *IArticleRepositoryMock) GetPreviewByTagIDBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.GetPreviewByTagID. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetPreviewByTagID *mIArticleRepositoryMockGetPreviewByTagID) Calls() []*IArticleRepositoryMockGetPreviewByTagIDParams { mmGetPreviewByTagID.mutex.RLock() argCopy := make([]*IArticleRepositoryMockGetPreviewByTagIDParams, len(mmGetPreviewByTagID.callArgs)) copy(argCopy, mmGetPreviewByTagID.callArgs) mmGetPreviewByTagID.mutex.RUnlock() return argCopy } // MinimockGetPreviewByTagIDDone returns true if the count of the GetPreviewByTagID invocations corresponds // the number of defined expectations func (m *IArticleRepositoryMock) MinimockGetPreviewByTagIDDone() bool { for _, e := range m.GetPreviewByTagIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.GetPreviewByTagIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcGetPreviewByTagID != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 { return false } return true } // MinimockGetPreviewByTagIDInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockGetPreviewByTagIDInspect() { for _, e := range m.GetPreviewByTagIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.GetPreviewByTagID with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.GetPreviewByTagIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 { if m.GetPreviewByTagIDMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.GetPreviewByTagID") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.GetPreviewByTagID with params: %#v", *m.GetPreviewByTagIDMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcGetPreviewByTagID != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.GetPreviewByTagID") } } type mIArticleRepositoryMockUpdate struct { mock *IArticleRepositoryMock defaultExpectation *IArticleRepositoryMockUpdateExpectation expectations []*IArticleRepositoryMockUpdateExpectation callArgs []*IArticleRepositoryMockUpdateParams mutex sync.RWMutex } // IArticleRepositoryMockUpdateExpectation specifies expectation struct of the IArticleRepository.Update type IArticleRepositoryMockUpdateExpectation struct { mock *IArticleRepositoryMock params *IArticleRepositoryMockUpdateParams results *IArticleRepositoryMockUpdateResults Counter uint64 } // IArticleRepositoryMockUpdateParams contains parameters of the IArticleRepository.Update type IArticleRepositoryMockUpdateParams struct { ctx context.Context m models.Article } // IArticleRepositoryMockUpdateResults contains results of the IArticleRepository.Update type IArticleRepositoryMockUpdateResults struct { err error } // Expect sets up expected params for IArticleRepository.Update func (mmUpdate *mIArticleRepositoryMockUpdate) Expect(ctx context.Context, m models.Article) *mIArticleRepositoryMockUpdate { if mmUpdate.mock.funcUpdate != nil { mmUpdate.mock.t.Fatalf("IArticleRepositoryMock.Update mock is already set by Set") } if mmUpdate.defaultExpectation == nil { mmUpdate.defaultExpectation = &IArticleRepositoryMockUpdateExpectation{} } mmUpdate.defaultExpectation.params = &IArticleRepositoryMockUpdateParams{ctx, m} for _, e := range mmUpdate.expectations { if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) { mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params) } } return mmUpdate } // Inspect accepts an inspector function that has same arguments as the IArticleRepository.Update func (mmUpdate *mIArticleRepositoryMockUpdate) Inspect(f func(ctx context.Context, m models.Article)) *mIArticleRepositoryMockUpdate { if mmUpdate.mock.inspectFuncUpdate != nil { mmUpdate.mock.t.Fatalf("Inspect function is already set for IArticleRepositoryMock.Update") } mmUpdate.mock.inspectFuncUpdate = f return mmUpdate } // Return sets up results that will be returned by IArticleRepository.Update func (mmUpdate *mIArticleRepositoryMockUpdate) Return(err error) *IArticleRepositoryMock { if mmUpdate.mock.funcUpdate != nil { mmUpdate.mock.t.Fatalf("IArticleRepositoryMock.Update mock is already set by Set") } if mmUpdate.defaultExpectation == nil { mmUpdate.defaultExpectation = &IArticleRepositoryMockUpdateExpectation{mock: mmUpdate.mock} } mmUpdate.defaultExpectation.results = &IArticleRepositoryMockUpdateResults{err} return mmUpdate.mock } //Set uses given function f to mock the IArticleRepository.Update method func (mmUpdate *mIArticleRepositoryMockUpdate) Set(f func(ctx context.Context, m models.Article) (err error)) *IArticleRepositoryMock { if mmUpdate.defaultExpectation != nil { mmUpdate.mock.t.Fatalf("Default expectation is already set for the IArticleRepository.Update method") } if len(mmUpdate.expectations) > 0 { mmUpdate.mock.t.Fatalf("Some expectations are already set for the IArticleRepository.Update method") } mmUpdate.mock.funcUpdate = f return mmUpdate.mock } // When sets expectation for the IArticleRepository.Update which will trigger the result defined by the following // Then helper func (mmUpdate *mIArticleRepositoryMockUpdate) When(ctx context.Context, m models.Article) *IArticleRepositoryMockUpdateExpectation { if mmUpdate.mock.funcUpdate != nil { mmUpdate.mock.t.Fatalf("IArticleRepositoryMock.Update mock is already set by Set") } expectation := &IArticleRepositoryMockUpdateExpectation{ mock: mmUpdate.mock, params: &IArticleRepositoryMockUpdateParams{ctx, m}, } mmUpdate.expectations = append(mmUpdate.expectations, expectation) return expectation } // Then sets up IArticleRepository.Update return parameters for the expectation previously defined by the When method func (e *IArticleRepositoryMockUpdateExpectation) Then(err error) *IArticleRepositoryMock { e.results = &IArticleRepositoryMockUpdateResults{err} return e.mock } // Update implements interfaces.IArticleRepository func (mmUpdate *IArticleRepositoryMock) Update(ctx context.Context, m models.Article) (err error) { mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1) defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1) if mmUpdate.inspectFuncUpdate != nil { mmUpdate.inspectFuncUpdate(ctx, m) } mm_params := &IArticleRepositoryMockUpdateParams{ctx, m} // Record call args mmUpdate.UpdateMock.mutex.Lock() mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, mm_params) mmUpdate.UpdateMock.mutex.Unlock() for _, e := range mmUpdate.UpdateMock.expectations { if minimock.Equal(e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.err } } if mmUpdate.UpdateMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1) mm_want := mmUpdate.UpdateMock.defaultExpectation.params mm_got := IArticleRepositoryMockUpdateParams{ctx, m} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmUpdate.t.Errorf("IArticleRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmUpdate.UpdateMock.defaultExpectation.results if mm_results == nil { mmUpdate.t.Fatal("No results are set for the IArticleRepositoryMock.Update") } return (*mm_results).err } if mmUpdate.funcUpdate != nil { return mmUpdate.funcUpdate(ctx, m) } mmUpdate.t.Fatalf("Unexpected call to IArticleRepositoryMock.Update. %v %v", ctx, m) return } // UpdateAfterCounter returns a count of finished IArticleRepositoryMock.Update invocations func (mmUpdate *IArticleRepositoryMock) UpdateAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter) } // UpdateBeforeCounter returns a count of IArticleRepositoryMock.Update invocations func (mmUpdate *IArticleRepositoryMock) UpdateBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter) } // Calls returns a list of arguments used in each call to IArticleRepositoryMock.Update. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmUpdate *mIArticleRepositoryMockUpdate) Calls() []*IArticleRepositoryMockUpdateParams { mmUpdate.mutex.RLock() argCopy := make([]*IArticleRepositoryMockUpdateParams, len(mmUpdate.callArgs)) copy(argCopy, mmUpdate.callArgs) mmUpdate.mutex.RUnlock() return argCopy } // MinimockUpdateDone returns true if the count of the Update invocations corresponds // the number of defined expectations func (m *IArticleRepositoryMock) MinimockUpdateDone() bool { for _, e := range m.UpdateMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } // if default expectation was set then invocations count should be greater than zero if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 { return false } // if func was set then invocations count should be greater than zero if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 { return false } return true } // MinimockUpdateInspect logs each unmet expectation func (m *IArticleRepositoryMock) MinimockUpdateInspect() { for _, e := range m.UpdateMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to IArticleRepositoryMock.Update with params: %#v", *e.params) } } // if default expectation was set then invocations count should be greater than zero if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 { if m.UpdateMock.defaultExpectation.params == nil { m.t.Error("Expected call to IArticleRepositoryMock.Update") } else { m.t.Errorf("Expected call to IArticleRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 { m.t.Error("Expected call to IArticleRepositoryMock.Update") } } // MinimockFinish checks that all mocked methods have been called the expected number of times func (m *IArticleRepositoryMock) MinimockFinish() { if !m.minimockDone() { m.MinimockAddInspect() m.MinimockDeleteInspect() m.MinimockGetAllInspect() m.MinimockGetAllPreviewInspect() m.MinimockGetByIDInspect() m.MinimockGetByURLInspect() m.MinimockGetPreviewByTagIDInspect() m.MinimockUpdateInspect() m.t.FailNow() } } // MinimockWait waits for all mocked methods to be called the expected number of times func (m *IArticleRepositoryMock) 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 *IArticleRepositoryMock) minimockDone() bool { done := true return done && m.MinimockAddDone() && m.MinimockDeleteDone() && m.MinimockGetAllDone() && m.MinimockGetAllPreviewDone() && m.MinimockGetByIDDone() && m.MinimockGetByURLDone() && m.MinimockGetPreviewByTagIDDone() && m.MinimockUpdateDone() }