package mocks // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. //go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.ArticleRepository -o ./mocks/article_repository_minimock.go -n ArticleRepositoryMock import ( "context" "sync" mm_atomic "sync/atomic" mm_time "time" "github.com/dmitriygnatenko/internal/models" "github.com/gojuno/minimock/v3" ) // ArticleRepositoryMock implements interfaces.ArticleRepository type ArticleRepositoryMock 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 mArticleRepositoryMockAdd funcDelete func(ctx context.Context, ID int) (err error) inspectFuncDelete func(ctx context.Context, ID int) afterDeleteCounter uint64 beforeDeleteCounter uint64 DeleteMock mArticleRepositoryMockDelete funcGetAll func(ctx context.Context) (aa1 []models.Article, err error) inspectFuncGetAll func(ctx context.Context) afterGetAllCounter uint64 beforeGetAllCounter uint64 GetAllMock mArticleRepositoryMockGetAll funcGetAllPreview func(ctx context.Context) (aa1 []models.ArticlePreview, err error) inspectFuncGetAllPreview func(ctx context.Context) afterGetAllPreviewCounter uint64 beforeGetAllPreviewCounter uint64 GetAllPreviewMock mArticleRepositoryMockGetAllPreview funcGetByID func(ctx context.Context, ID int) (ap1 *models.Article, err error) inspectFuncGetByID func(ctx context.Context, ID int) afterGetByIDCounter uint64 beforeGetByIDCounter uint64 GetByIDMock mArticleRepositoryMockGetByID funcGetByURL func(ctx context.Context, url string) (ap1 *models.Article, err error) inspectFuncGetByURL func(ctx context.Context, url string) afterGetByURLCounter uint64 beforeGetByURLCounter uint64 GetByURLMock mArticleRepositoryMockGetByURL funcGetPreviewByTagID func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error) inspectFuncGetPreviewByTagID func(ctx context.Context, tagID int) afterGetPreviewByTagIDCounter uint64 beforeGetPreviewByTagIDCounter uint64 GetPreviewByTagIDMock mArticleRepositoryMockGetPreviewByTagID funcUpdate func(ctx context.Context, m models.Article) (err error) inspectFuncUpdate func(ctx context.Context, m models.Article) afterUpdateCounter uint64 beforeUpdateCounter uint64 UpdateMock mArticleRepositoryMockUpdate } // NewArticleRepositoryMock returns a mock for interfaces.ArticleRepository func NewArticleRepositoryMock(t minimock.Tester) *ArticleRepositoryMock { m := &ArticleRepositoryMock{t: t} if controller, ok := t.(minimock.MockController); ok { controller.RegisterMocker(m) } m.AddMock = mArticleRepositoryMockAdd{mock: m} m.AddMock.callArgs = []*ArticleRepositoryMockAddParams{} m.DeleteMock = mArticleRepositoryMockDelete{mock: m} m.DeleteMock.callArgs = []*ArticleRepositoryMockDeleteParams{} m.GetAllMock = mArticleRepositoryMockGetAll{mock: m} m.GetAllMock.callArgs = []*ArticleRepositoryMockGetAllParams{} m.GetAllPreviewMock = mArticleRepositoryMockGetAllPreview{mock: m} m.GetAllPreviewMock.callArgs = []*ArticleRepositoryMockGetAllPreviewParams{} m.GetByIDMock = mArticleRepositoryMockGetByID{mock: m} m.GetByIDMock.callArgs = []*ArticleRepositoryMockGetByIDParams{} m.GetByURLMock = mArticleRepositoryMockGetByURL{mock: m} m.GetByURLMock.callArgs = []*ArticleRepositoryMockGetByURLParams{} m.GetPreviewByTagIDMock = mArticleRepositoryMockGetPreviewByTagID{mock: m} m.GetPreviewByTagIDMock.callArgs = []*ArticleRepositoryMockGetPreviewByTagIDParams{} m.UpdateMock = mArticleRepositoryMockUpdate{mock: m} m.UpdateMock.callArgs = []*ArticleRepositoryMockUpdateParams{} return m } type mArticleRepositoryMockAdd struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockAddExpectation expectations []*ArticleRepositoryMockAddExpectation callArgs []*ArticleRepositoryMockAddParams mutex sync.RWMutex } // ArticleRepositoryMockAddExpectation specifies expectation struct of the ArticleRepository.Add type ArticleRepositoryMockAddExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockAddParams results *ArticleRepositoryMockAddResults Counter uint64 } // ArticleRepositoryMockAddParams contains parameters of the ArticleRepository.Add type ArticleRepositoryMockAddParams struct { ctx context.Context m models.Article } // ArticleRepositoryMockAddResults contains results of the ArticleRepository.Add type ArticleRepositoryMockAddResults struct { i1 int err error } // Expect sets up expected params for ArticleRepository.Add func (mmAdd *mArticleRepositoryMockAdd) Expect(ctx context.Context, m models.Article) *mArticleRepositoryMockAdd { if mmAdd.mock.funcAdd != nil { mmAdd.mock.t.Fatalf("ArticleRepositoryMock.Add mock is already set by Set") } if mmAdd.defaultExpectation == nil { mmAdd.defaultExpectation = &ArticleRepositoryMockAddExpectation{} } mmAdd.defaultExpectation.params = &ArticleRepositoryMockAddParams{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 ArticleRepository.Add func (mmAdd *mArticleRepositoryMockAdd) Inspect(f func(ctx context.Context, m models.Article)) *mArticleRepositoryMockAdd { if mmAdd.mock.inspectFuncAdd != nil { mmAdd.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.Add") } mmAdd.mock.inspectFuncAdd = f return mmAdd } // Return sets up results that will be returned by ArticleRepository.Add func (mmAdd *mArticleRepositoryMockAdd) Return(i1 int, err error) *ArticleRepositoryMock { if mmAdd.mock.funcAdd != nil { mmAdd.mock.t.Fatalf("ArticleRepositoryMock.Add mock is already set by Set") } if mmAdd.defaultExpectation == nil { mmAdd.defaultExpectation = &ArticleRepositoryMockAddExpectation{mock: mmAdd.mock} } mmAdd.defaultExpectation.results = &ArticleRepositoryMockAddResults{i1, err} return mmAdd.mock } // Set uses given function f to mock the ArticleRepository.Add method func (mmAdd *mArticleRepositoryMockAdd) Set(f func(ctx context.Context, m models.Article) (i1 int, err error)) *ArticleRepositoryMock { if mmAdd.defaultExpectation != nil { mmAdd.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.Add method") } if len(mmAdd.expectations) > 0 { mmAdd.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.Add method") } mmAdd.mock.funcAdd = f return mmAdd.mock } // When sets expectation for the ArticleRepository.Add which will trigger the result defined by the following // Then helper func (mmAdd *mArticleRepositoryMockAdd) When(ctx context.Context, m models.Article) *ArticleRepositoryMockAddExpectation { if mmAdd.mock.funcAdd != nil { mmAdd.mock.t.Fatalf("ArticleRepositoryMock.Add mock is already set by Set") } expectation := &ArticleRepositoryMockAddExpectation{ mock: mmAdd.mock, params: &ArticleRepositoryMockAddParams{ctx, m}, } mmAdd.expectations = append(mmAdd.expectations, expectation) return expectation } // Then sets up ArticleRepository.Add return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockAddExpectation) Then(i1 int, err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockAddResults{i1, err} return e.mock } // Add implements interfaces.ArticleRepository func (mmAdd *ArticleRepositoryMock) 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 := &ArticleRepositoryMockAddParams{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 := ArticleRepositoryMockAddParams{ctx, m} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmAdd.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.Add") } return (*mm_results).i1, (*mm_results).err } if mmAdd.funcAdd != nil { return mmAdd.funcAdd(ctx, m) } mmAdd.t.Fatalf("Unexpected call to ArticleRepositoryMock.Add. %v %v", ctx, m) return } // AddAfterCounter returns a count of finished ArticleRepositoryMock.Add invocations func (mmAdd *ArticleRepositoryMock) AddAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmAdd.afterAddCounter) } // AddBeforeCounter returns a count of ArticleRepositoryMock.Add invocations func (mmAdd *ArticleRepositoryMock) AddBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.Add. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmAdd *mArticleRepositoryMockAdd) Calls() []*ArticleRepositoryMockAddParams { mmAdd.mutex.RLock() argCopy := make([]*ArticleRepositoryMockAddParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockAddInspect() { for _, e := range m.AddMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.Add") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.Add") } } type mArticleRepositoryMockDelete struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockDeleteExpectation expectations []*ArticleRepositoryMockDeleteExpectation callArgs []*ArticleRepositoryMockDeleteParams mutex sync.RWMutex } // ArticleRepositoryMockDeleteExpectation specifies expectation struct of the ArticleRepository.Delete type ArticleRepositoryMockDeleteExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockDeleteParams results *ArticleRepositoryMockDeleteResults Counter uint64 } // ArticleRepositoryMockDeleteParams contains parameters of the ArticleRepository.Delete type ArticleRepositoryMockDeleteParams struct { ctx context.Context ID int } // ArticleRepositoryMockDeleteResults contains results of the ArticleRepository.Delete type ArticleRepositoryMockDeleteResults struct { err error } // Expect sets up expected params for ArticleRepository.Delete func (mmDelete *mArticleRepositoryMockDelete) Expect(ctx context.Context, ID int) *mArticleRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ArticleRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &ArticleRepositoryMockDeleteExpectation{} } mmDelete.defaultExpectation.params = &ArticleRepositoryMockDeleteParams{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 ArticleRepository.Delete func (mmDelete *mArticleRepositoryMockDelete) Inspect(f func(ctx context.Context, ID int)) *mArticleRepositoryMockDelete { if mmDelete.mock.inspectFuncDelete != nil { mmDelete.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.Delete") } mmDelete.mock.inspectFuncDelete = f return mmDelete } // Return sets up results that will be returned by ArticleRepository.Delete func (mmDelete *mArticleRepositoryMockDelete) Return(err error) *ArticleRepositoryMock { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ArticleRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &ArticleRepositoryMockDeleteExpectation{mock: mmDelete.mock} } mmDelete.defaultExpectation.results = &ArticleRepositoryMockDeleteResults{err} return mmDelete.mock } // Set uses given function f to mock the ArticleRepository.Delete method func (mmDelete *mArticleRepositoryMockDelete) Set(f func(ctx context.Context, ID int) (err error)) *ArticleRepositoryMock { if mmDelete.defaultExpectation != nil { mmDelete.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.Delete method") } if len(mmDelete.expectations) > 0 { mmDelete.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.Delete method") } mmDelete.mock.funcDelete = f return mmDelete.mock } // When sets expectation for the ArticleRepository.Delete which will trigger the result defined by the following // Then helper func (mmDelete *mArticleRepositoryMockDelete) When(ctx context.Context, ID int) *ArticleRepositoryMockDeleteExpectation { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("ArticleRepositoryMock.Delete mock is already set by Set") } expectation := &ArticleRepositoryMockDeleteExpectation{ mock: mmDelete.mock, params: &ArticleRepositoryMockDeleteParams{ctx, ID}, } mmDelete.expectations = append(mmDelete.expectations, expectation) return expectation } // Then sets up ArticleRepository.Delete return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockDeleteExpectation) Then(err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockDeleteResults{err} return e.mock } // Delete implements interfaces.ArticleRepository func (mmDelete *ArticleRepositoryMock) 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 := &ArticleRepositoryMockDeleteParams{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 := ArticleRepositoryMockDeleteParams{ctx, ID} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmDelete.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.Delete") } return (*mm_results).err } if mmDelete.funcDelete != nil { return mmDelete.funcDelete(ctx, ID) } mmDelete.t.Fatalf("Unexpected call to ArticleRepositoryMock.Delete. %v %v", ctx, ID) return } // DeleteAfterCounter returns a count of finished ArticleRepositoryMock.Delete invocations func (mmDelete *ArticleRepositoryMock) DeleteAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter) } // DeleteBeforeCounter returns a count of ArticleRepositoryMock.Delete invocations func (mmDelete *ArticleRepositoryMock) DeleteBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.Delete. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmDelete *mArticleRepositoryMockDelete) Calls() []*ArticleRepositoryMockDeleteParams { mmDelete.mutex.RLock() argCopy := make([]*ArticleRepositoryMockDeleteParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockDeleteInspect() { for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.Delete") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.Delete") } } type mArticleRepositoryMockGetAll struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetAllExpectation expectations []*ArticleRepositoryMockGetAllExpectation callArgs []*ArticleRepositoryMockGetAllParams mutex sync.RWMutex } // ArticleRepositoryMockGetAllExpectation specifies expectation struct of the ArticleRepository.GetAll type ArticleRepositoryMockGetAllExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetAllParams results *ArticleRepositoryMockGetAllResults Counter uint64 } // ArticleRepositoryMockGetAllParams contains parameters of the ArticleRepository.GetAll type ArticleRepositoryMockGetAllParams struct { ctx context.Context } // ArticleRepositoryMockGetAllResults contains results of the ArticleRepository.GetAll type ArticleRepositoryMockGetAllResults struct { aa1 []models.Article err error } // Expect sets up expected params for ArticleRepository.GetAll func (mmGetAll *mArticleRepositoryMockGetAll) Expect(ctx context.Context) *mArticleRepositoryMockGetAll { if mmGetAll.mock.funcGetAll != nil { mmGetAll.mock.t.Fatalf("ArticleRepositoryMock.GetAll mock is already set by Set") } if mmGetAll.defaultExpectation == nil { mmGetAll.defaultExpectation = &ArticleRepositoryMockGetAllExpectation{} } mmGetAll.defaultExpectation.params = &ArticleRepositoryMockGetAllParams{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 ArticleRepository.GetAll func (mmGetAll *mArticleRepositoryMockGetAll) Inspect(f func(ctx context.Context)) *mArticleRepositoryMockGetAll { if mmGetAll.mock.inspectFuncGetAll != nil { mmGetAll.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetAll") } mmGetAll.mock.inspectFuncGetAll = f return mmGetAll } // Return sets up results that will be returned by ArticleRepository.GetAll func (mmGetAll *mArticleRepositoryMockGetAll) Return(aa1 []models.Article, err error) *ArticleRepositoryMock { if mmGetAll.mock.funcGetAll != nil { mmGetAll.mock.t.Fatalf("ArticleRepositoryMock.GetAll mock is already set by Set") } if mmGetAll.defaultExpectation == nil { mmGetAll.defaultExpectation = &ArticleRepositoryMockGetAllExpectation{mock: mmGetAll.mock} } mmGetAll.defaultExpectation.results = &ArticleRepositoryMockGetAllResults{aa1, err} return mmGetAll.mock } // Set uses given function f to mock the ArticleRepository.GetAll method func (mmGetAll *mArticleRepositoryMockGetAll) Set(f func(ctx context.Context) (aa1 []models.Article, err error)) *ArticleRepositoryMock { if mmGetAll.defaultExpectation != nil { mmGetAll.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetAll method") } if len(mmGetAll.expectations) > 0 { mmGetAll.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetAll method") } mmGetAll.mock.funcGetAll = f return mmGetAll.mock } // When sets expectation for the ArticleRepository.GetAll which will trigger the result defined by the following // Then helper func (mmGetAll *mArticleRepositoryMockGetAll) When(ctx context.Context) *ArticleRepositoryMockGetAllExpectation { if mmGetAll.mock.funcGetAll != nil { mmGetAll.mock.t.Fatalf("ArticleRepositoryMock.GetAll mock is already set by Set") } expectation := &ArticleRepositoryMockGetAllExpectation{ mock: mmGetAll.mock, params: &ArticleRepositoryMockGetAllParams{ctx}, } mmGetAll.expectations = append(mmGetAll.expectations, expectation) return expectation } // Then sets up ArticleRepository.GetAll return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockGetAllExpectation) Then(aa1 []models.Article, err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockGetAllResults{aa1, err} return e.mock } // GetAll implements interfaces.ArticleRepository func (mmGetAll *ArticleRepositoryMock) 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 := &ArticleRepositoryMockGetAllParams{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 := ArticleRepositoryMockGetAllParams{ctx} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetAll.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.GetAll") } return (*mm_results).aa1, (*mm_results).err } if mmGetAll.funcGetAll != nil { return mmGetAll.funcGetAll(ctx) } mmGetAll.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetAll. %v", ctx) return } // GetAllAfterCounter returns a count of finished ArticleRepositoryMock.GetAll invocations func (mmGetAll *ArticleRepositoryMock) GetAllAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter) } // GetAllBeforeCounter returns a count of ArticleRepositoryMock.GetAll invocations func (mmGetAll *ArticleRepositoryMock) GetAllBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetAll. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetAll *mArticleRepositoryMockGetAll) Calls() []*ArticleRepositoryMockGetAllParams { mmGetAll.mutex.RLock() argCopy := make([]*ArticleRepositoryMockGetAllParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockGetAllInspect() { for _, e := range m.GetAllMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetAll") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetAll") } } type mArticleRepositoryMockGetAllPreview struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetAllPreviewExpectation expectations []*ArticleRepositoryMockGetAllPreviewExpectation callArgs []*ArticleRepositoryMockGetAllPreviewParams mutex sync.RWMutex } // ArticleRepositoryMockGetAllPreviewExpectation specifies expectation struct of the ArticleRepository.GetAllPreview type ArticleRepositoryMockGetAllPreviewExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetAllPreviewParams results *ArticleRepositoryMockGetAllPreviewResults Counter uint64 } // ArticleRepositoryMockGetAllPreviewParams contains parameters of the ArticleRepository.GetAllPreview type ArticleRepositoryMockGetAllPreviewParams struct { ctx context.Context } // ArticleRepositoryMockGetAllPreviewResults contains results of the ArticleRepository.GetAllPreview type ArticleRepositoryMockGetAllPreviewResults struct { aa1 []models.ArticlePreview err error } // Expect sets up expected params for ArticleRepository.GetAllPreview func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Expect(ctx context.Context) *mArticleRepositoryMockGetAllPreview { if mmGetAllPreview.mock.funcGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set") } if mmGetAllPreview.defaultExpectation == nil { mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{} } mmGetAllPreview.defaultExpectation.params = &ArticleRepositoryMockGetAllPreviewParams{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 ArticleRepository.GetAllPreview func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Inspect(f func(ctx context.Context)) *mArticleRepositoryMockGetAllPreview { if mmGetAllPreview.mock.inspectFuncGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetAllPreview") } mmGetAllPreview.mock.inspectFuncGetAllPreview = f return mmGetAllPreview } // Return sets up results that will be returned by ArticleRepository.GetAllPreview func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock { if mmGetAllPreview.mock.funcGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set") } if mmGetAllPreview.defaultExpectation == nil { mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{mock: mmGetAllPreview.mock} } mmGetAllPreview.defaultExpectation.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err} return mmGetAllPreview.mock } // Set uses given function f to mock the ArticleRepository.GetAllPreview method func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Set(f func(ctx context.Context) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock { if mmGetAllPreview.defaultExpectation != nil { mmGetAllPreview.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetAllPreview method") } if len(mmGetAllPreview.expectations) > 0 { mmGetAllPreview.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetAllPreview method") } mmGetAllPreview.mock.funcGetAllPreview = f return mmGetAllPreview.mock } // When sets expectation for the ArticleRepository.GetAllPreview which will trigger the result defined by the following // Then helper func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) When(ctx context.Context) *ArticleRepositoryMockGetAllPreviewExpectation { if mmGetAllPreview.mock.funcGetAllPreview != nil { mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set") } expectation := &ArticleRepositoryMockGetAllPreviewExpectation{ mock: mmGetAllPreview.mock, params: &ArticleRepositoryMockGetAllPreviewParams{ctx}, } mmGetAllPreview.expectations = append(mmGetAllPreview.expectations, expectation) return expectation } // Then sets up ArticleRepository.GetAllPreview return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockGetAllPreviewExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err} return e.mock } // GetAllPreview implements interfaces.ArticleRepository func (mmGetAllPreview *ArticleRepositoryMock) 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 := &ArticleRepositoryMockGetAllPreviewParams{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 := ArticleRepositoryMockGetAllPreviewParams{ctx} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetAllPreview.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.GetAllPreview") } return (*mm_results).aa1, (*mm_results).err } if mmGetAllPreview.funcGetAllPreview != nil { return mmGetAllPreview.funcGetAllPreview(ctx) } mmGetAllPreview.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetAllPreview. %v", ctx) return } // GetAllPreviewAfterCounter returns a count of finished ArticleRepositoryMock.GetAllPreview invocations func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAllPreview.afterGetAllPreviewCounter) } // GetAllPreviewBeforeCounter returns a count of ArticleRepositoryMock.GetAllPreview invocations func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetAllPreview.beforeGetAllPreviewCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetAllPreview. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Calls() []*ArticleRepositoryMockGetAllPreviewParams { mmGetAllPreview.mutex.RLock() argCopy := make([]*ArticleRepositoryMockGetAllPreviewParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockGetAllPreviewInspect() { for _, e := range m.GetAllPreviewMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetAllPreview") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetAllPreview") } } type mArticleRepositoryMockGetByID struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetByIDExpectation expectations []*ArticleRepositoryMockGetByIDExpectation callArgs []*ArticleRepositoryMockGetByIDParams mutex sync.RWMutex } // ArticleRepositoryMockGetByIDExpectation specifies expectation struct of the ArticleRepository.GetByID type ArticleRepositoryMockGetByIDExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetByIDParams results *ArticleRepositoryMockGetByIDResults Counter uint64 } // ArticleRepositoryMockGetByIDParams contains parameters of the ArticleRepository.GetByID type ArticleRepositoryMockGetByIDParams struct { ctx context.Context ID int } // ArticleRepositoryMockGetByIDResults contains results of the ArticleRepository.GetByID type ArticleRepositoryMockGetByIDResults struct { ap1 *models.Article err error } // Expect sets up expected params for ArticleRepository.GetByID func (mmGetByID *mArticleRepositoryMockGetByID) Expect(ctx context.Context, ID int) *mArticleRepositoryMockGetByID { if mmGetByID.mock.funcGetByID != nil { mmGetByID.mock.t.Fatalf("ArticleRepositoryMock.GetByID mock is already set by Set") } if mmGetByID.defaultExpectation == nil { mmGetByID.defaultExpectation = &ArticleRepositoryMockGetByIDExpectation{} } mmGetByID.defaultExpectation.params = &ArticleRepositoryMockGetByIDParams{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 ArticleRepository.GetByID func (mmGetByID *mArticleRepositoryMockGetByID) Inspect(f func(ctx context.Context, ID int)) *mArticleRepositoryMockGetByID { if mmGetByID.mock.inspectFuncGetByID != nil { mmGetByID.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetByID") } mmGetByID.mock.inspectFuncGetByID = f return mmGetByID } // Return sets up results that will be returned by ArticleRepository.GetByID func (mmGetByID *mArticleRepositoryMockGetByID) Return(ap1 *models.Article, err error) *ArticleRepositoryMock { if mmGetByID.mock.funcGetByID != nil { mmGetByID.mock.t.Fatalf("ArticleRepositoryMock.GetByID mock is already set by Set") } if mmGetByID.defaultExpectation == nil { mmGetByID.defaultExpectation = &ArticleRepositoryMockGetByIDExpectation{mock: mmGetByID.mock} } mmGetByID.defaultExpectation.results = &ArticleRepositoryMockGetByIDResults{ap1, err} return mmGetByID.mock } // Set uses given function f to mock the ArticleRepository.GetByID method func (mmGetByID *mArticleRepositoryMockGetByID) Set(f func(ctx context.Context, ID int) (ap1 *models.Article, err error)) *ArticleRepositoryMock { if mmGetByID.defaultExpectation != nil { mmGetByID.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetByID method") } if len(mmGetByID.expectations) > 0 { mmGetByID.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetByID method") } mmGetByID.mock.funcGetByID = f return mmGetByID.mock } // When sets expectation for the ArticleRepository.GetByID which will trigger the result defined by the following // Then helper func (mmGetByID *mArticleRepositoryMockGetByID) When(ctx context.Context, ID int) *ArticleRepositoryMockGetByIDExpectation { if mmGetByID.mock.funcGetByID != nil { mmGetByID.mock.t.Fatalf("ArticleRepositoryMock.GetByID mock is already set by Set") } expectation := &ArticleRepositoryMockGetByIDExpectation{ mock: mmGetByID.mock, params: &ArticleRepositoryMockGetByIDParams{ctx, ID}, } mmGetByID.expectations = append(mmGetByID.expectations, expectation) return expectation } // Then sets up ArticleRepository.GetByID return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockGetByIDExpectation) Then(ap1 *models.Article, err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockGetByIDResults{ap1, err} return e.mock } // GetByID implements interfaces.ArticleRepository func (mmGetByID *ArticleRepositoryMock) 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 := &ArticleRepositoryMockGetByIDParams{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 := ArticleRepositoryMockGetByIDParams{ctx, ID} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetByID.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.GetByID") } return (*mm_results).ap1, (*mm_results).err } if mmGetByID.funcGetByID != nil { return mmGetByID.funcGetByID(ctx, ID) } mmGetByID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetByID. %v %v", ctx, ID) return } // GetByIDAfterCounter returns a count of finished ArticleRepositoryMock.GetByID invocations func (mmGetByID *ArticleRepositoryMock) GetByIDAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByID.afterGetByIDCounter) } // GetByIDBeforeCounter returns a count of ArticleRepositoryMock.GetByID invocations func (mmGetByID *ArticleRepositoryMock) GetByIDBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByID.beforeGetByIDCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetByID. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetByID *mArticleRepositoryMockGetByID) Calls() []*ArticleRepositoryMockGetByIDParams { mmGetByID.mutex.RLock() argCopy := make([]*ArticleRepositoryMockGetByIDParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockGetByIDInspect() { for _, e := range m.GetByIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetByID") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetByID") } } type mArticleRepositoryMockGetByURL struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetByURLExpectation expectations []*ArticleRepositoryMockGetByURLExpectation callArgs []*ArticleRepositoryMockGetByURLParams mutex sync.RWMutex } // ArticleRepositoryMockGetByURLExpectation specifies expectation struct of the ArticleRepository.GetByURL type ArticleRepositoryMockGetByURLExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetByURLParams results *ArticleRepositoryMockGetByURLResults Counter uint64 } // ArticleRepositoryMockGetByURLParams contains parameters of the ArticleRepository.GetByURL type ArticleRepositoryMockGetByURLParams struct { ctx context.Context url string } // ArticleRepositoryMockGetByURLResults contains results of the ArticleRepository.GetByURL type ArticleRepositoryMockGetByURLResults struct { ap1 *models.Article err error } // Expect sets up expected params for ArticleRepository.GetByURL func (mmGetByURL *mArticleRepositoryMockGetByURL) Expect(ctx context.Context, url string) *mArticleRepositoryMockGetByURL { if mmGetByURL.mock.funcGetByURL != nil { mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set") } if mmGetByURL.defaultExpectation == nil { mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{} } mmGetByURL.defaultExpectation.params = &ArticleRepositoryMockGetByURLParams{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 ArticleRepository.GetByURL func (mmGetByURL *mArticleRepositoryMockGetByURL) Inspect(f func(ctx context.Context, url string)) *mArticleRepositoryMockGetByURL { if mmGetByURL.mock.inspectFuncGetByURL != nil { mmGetByURL.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetByURL") } mmGetByURL.mock.inspectFuncGetByURL = f return mmGetByURL } // Return sets up results that will be returned by ArticleRepository.GetByURL func (mmGetByURL *mArticleRepositoryMockGetByURL) Return(ap1 *models.Article, err error) *ArticleRepositoryMock { if mmGetByURL.mock.funcGetByURL != nil { mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set") } if mmGetByURL.defaultExpectation == nil { mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock} } mmGetByURL.defaultExpectation.results = &ArticleRepositoryMockGetByURLResults{ap1, err} return mmGetByURL.mock } // Set uses given function f to mock the ArticleRepository.GetByURL method func (mmGetByURL *mArticleRepositoryMockGetByURL) Set(f func(ctx context.Context, url string) (ap1 *models.Article, err error)) *ArticleRepositoryMock { if mmGetByURL.defaultExpectation != nil { mmGetByURL.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetByURL method") } if len(mmGetByURL.expectations) > 0 { mmGetByURL.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetByURL method") } mmGetByURL.mock.funcGetByURL = f return mmGetByURL.mock } // When sets expectation for the ArticleRepository.GetByURL which will trigger the result defined by the following // Then helper func (mmGetByURL *mArticleRepositoryMockGetByURL) When(ctx context.Context, url string) *ArticleRepositoryMockGetByURLExpectation { if mmGetByURL.mock.funcGetByURL != nil { mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set") } expectation := &ArticleRepositoryMockGetByURLExpectation{ mock: mmGetByURL.mock, params: &ArticleRepositoryMockGetByURLParams{ctx, url}, } mmGetByURL.expectations = append(mmGetByURL.expectations, expectation) return expectation } // Then sets up ArticleRepository.GetByURL return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockGetByURLExpectation) Then(ap1 *models.Article, err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockGetByURLResults{ap1, err} return e.mock } // GetByURL implements interfaces.ArticleRepository func (mmGetByURL *ArticleRepositoryMock) 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 := &ArticleRepositoryMockGetByURLParams{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 := ArticleRepositoryMockGetByURLParams{ctx, url} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetByURL.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.GetByURL") } return (*mm_results).ap1, (*mm_results).err } if mmGetByURL.funcGetByURL != nil { return mmGetByURL.funcGetByURL(ctx, url) } mmGetByURL.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetByURL. %v %v", ctx, url) return } // GetByURLAfterCounter returns a count of finished ArticleRepositoryMock.GetByURL invocations func (mmGetByURL *ArticleRepositoryMock) GetByURLAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter) } // GetByURLBeforeCounter returns a count of ArticleRepositoryMock.GetByURL invocations func (mmGetByURL *ArticleRepositoryMock) GetByURLBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetByURL. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetByURL *mArticleRepositoryMockGetByURL) Calls() []*ArticleRepositoryMockGetByURLParams { mmGetByURL.mutex.RLock() argCopy := make([]*ArticleRepositoryMockGetByURLParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockGetByURLInspect() { for _, e := range m.GetByURLMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetByURL") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetByURL") } } type mArticleRepositoryMockGetPreviewByTagID struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetPreviewByTagIDExpectation expectations []*ArticleRepositoryMockGetPreviewByTagIDExpectation callArgs []*ArticleRepositoryMockGetPreviewByTagIDParams mutex sync.RWMutex } // ArticleRepositoryMockGetPreviewByTagIDExpectation specifies expectation struct of the ArticleRepository.GetPreviewByTagID type ArticleRepositoryMockGetPreviewByTagIDExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetPreviewByTagIDParams results *ArticleRepositoryMockGetPreviewByTagIDResults Counter uint64 } // ArticleRepositoryMockGetPreviewByTagIDParams contains parameters of the ArticleRepository.GetPreviewByTagID type ArticleRepositoryMockGetPreviewByTagIDParams struct { ctx context.Context tagID int } // ArticleRepositoryMockGetPreviewByTagIDResults contains results of the ArticleRepository.GetPreviewByTagID type ArticleRepositoryMockGetPreviewByTagIDResults struct { aa1 []models.ArticlePreview err error } // Expect sets up expected params for ArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Expect(ctx context.Context, tagID int) *mArticleRepositoryMockGetPreviewByTagID { if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set") } if mmGetPreviewByTagID.defaultExpectation == nil { mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{} } mmGetPreviewByTagID.defaultExpectation.params = &ArticleRepositoryMockGetPreviewByTagIDParams{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 ArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Inspect(f func(ctx context.Context, tagID int)) *mArticleRepositoryMockGetPreviewByTagID { if mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetPreviewByTagID") } mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID = f return mmGetPreviewByTagID } // Return sets up results that will be returned by ArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock { if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set") } if mmGetPreviewByTagID.defaultExpectation == nil { mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{mock: mmGetPreviewByTagID.mock} } mmGetPreviewByTagID.defaultExpectation.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err} return mmGetPreviewByTagID.mock } // Set uses given function f to mock the ArticleRepository.GetPreviewByTagID method func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Set(f func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock { if mmGetPreviewByTagID.defaultExpectation != nil { mmGetPreviewByTagID.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetPreviewByTagID method") } if len(mmGetPreviewByTagID.expectations) > 0 { mmGetPreviewByTagID.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetPreviewByTagID method") } mmGetPreviewByTagID.mock.funcGetPreviewByTagID = f return mmGetPreviewByTagID.mock } // When sets expectation for the ArticleRepository.GetPreviewByTagID which will trigger the result defined by the following // Then helper func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) When(ctx context.Context, tagID int) *ArticleRepositoryMockGetPreviewByTagIDExpectation { if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil { mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set") } expectation := &ArticleRepositoryMockGetPreviewByTagIDExpectation{ mock: mmGetPreviewByTagID.mock, params: &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}, } mmGetPreviewByTagID.expectations = append(mmGetPreviewByTagID.expectations, expectation) return expectation } // Then sets up ArticleRepository.GetPreviewByTagID return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockGetPreviewByTagIDExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err} return e.mock } // GetPreviewByTagID implements interfaces.ArticleRepository func (mmGetPreviewByTagID *ArticleRepositoryMock) 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 := &ArticleRepositoryMockGetPreviewByTagIDParams{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 := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.GetPreviewByTagID") } return (*mm_results).aa1, (*mm_results).err } if mmGetPreviewByTagID.funcGetPreviewByTagID != nil { return mmGetPreviewByTagID.funcGetPreviewByTagID(ctx, tagID) } mmGetPreviewByTagID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetPreviewByTagID. %v %v", ctx, tagID) return } // GetPreviewByTagIDAfterCounter returns a count of finished ArticleRepositoryMock.GetPreviewByTagID invocations func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter) } // GetPreviewByTagIDBeforeCounter returns a count of ArticleRepositoryMock.GetPreviewByTagID invocations func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetPreviewByTagID. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Calls() []*ArticleRepositoryMockGetPreviewByTagIDParams { mmGetPreviewByTagID.mutex.RLock() argCopy := make([]*ArticleRepositoryMockGetPreviewByTagIDParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockGetPreviewByTagIDInspect() { for _, e := range m.GetPreviewByTagIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetPreviewByTagID") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.GetPreviewByTagID") } } type mArticleRepositoryMockUpdate struct { mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockUpdateExpectation expectations []*ArticleRepositoryMockUpdateExpectation callArgs []*ArticleRepositoryMockUpdateParams mutex sync.RWMutex } // ArticleRepositoryMockUpdateExpectation specifies expectation struct of the ArticleRepository.Update type ArticleRepositoryMockUpdateExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockUpdateParams results *ArticleRepositoryMockUpdateResults Counter uint64 } // ArticleRepositoryMockUpdateParams contains parameters of the ArticleRepository.Update type ArticleRepositoryMockUpdateParams struct { ctx context.Context m models.Article } // ArticleRepositoryMockUpdateResults contains results of the ArticleRepository.Update type ArticleRepositoryMockUpdateResults struct { err error } // Expect sets up expected params for ArticleRepository.Update func (mmUpdate *mArticleRepositoryMockUpdate) Expect(ctx context.Context, m models.Article) *mArticleRepositoryMockUpdate { if mmUpdate.mock.funcUpdate != nil { mmUpdate.mock.t.Fatalf("ArticleRepositoryMock.Update mock is already set by Set") } if mmUpdate.defaultExpectation == nil { mmUpdate.defaultExpectation = &ArticleRepositoryMockUpdateExpectation{} } mmUpdate.defaultExpectation.params = &ArticleRepositoryMockUpdateParams{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 ArticleRepository.Update func (mmUpdate *mArticleRepositoryMockUpdate) Inspect(f func(ctx context.Context, m models.Article)) *mArticleRepositoryMockUpdate { if mmUpdate.mock.inspectFuncUpdate != nil { mmUpdate.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.Update") } mmUpdate.mock.inspectFuncUpdate = f return mmUpdate } // Return sets up results that will be returned by ArticleRepository.Update func (mmUpdate *mArticleRepositoryMockUpdate) Return(err error) *ArticleRepositoryMock { if mmUpdate.mock.funcUpdate != nil { mmUpdate.mock.t.Fatalf("ArticleRepositoryMock.Update mock is already set by Set") } if mmUpdate.defaultExpectation == nil { mmUpdate.defaultExpectation = &ArticleRepositoryMockUpdateExpectation{mock: mmUpdate.mock} } mmUpdate.defaultExpectation.results = &ArticleRepositoryMockUpdateResults{err} return mmUpdate.mock } // Set uses given function f to mock the ArticleRepository.Update method func (mmUpdate *mArticleRepositoryMockUpdate) Set(f func(ctx context.Context, m models.Article) (err error)) *ArticleRepositoryMock { if mmUpdate.defaultExpectation != nil { mmUpdate.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.Update method") } if len(mmUpdate.expectations) > 0 { mmUpdate.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.Update method") } mmUpdate.mock.funcUpdate = f return mmUpdate.mock } // When sets expectation for the ArticleRepository.Update which will trigger the result defined by the following // Then helper func (mmUpdate *mArticleRepositoryMockUpdate) When(ctx context.Context, m models.Article) *ArticleRepositoryMockUpdateExpectation { if mmUpdate.mock.funcUpdate != nil { mmUpdate.mock.t.Fatalf("ArticleRepositoryMock.Update mock is already set by Set") } expectation := &ArticleRepositoryMockUpdateExpectation{ mock: mmUpdate.mock, params: &ArticleRepositoryMockUpdateParams{ctx, m}, } mmUpdate.expectations = append(mmUpdate.expectations, expectation) return expectation } // Then sets up ArticleRepository.Update return parameters for the expectation previously defined by the When method func (e *ArticleRepositoryMockUpdateExpectation) Then(err error) *ArticleRepositoryMock { e.results = &ArticleRepositoryMockUpdateResults{err} return e.mock } // Update implements interfaces.ArticleRepository func (mmUpdate *ArticleRepositoryMock) 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 := &ArticleRepositoryMockUpdateParams{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 := ArticleRepositoryMockUpdateParams{ctx, m} if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmUpdate.t.Errorf("ArticleRepositoryMock.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 ArticleRepositoryMock.Update") } return (*mm_results).err } if mmUpdate.funcUpdate != nil { return mmUpdate.funcUpdate(ctx, m) } mmUpdate.t.Fatalf("Unexpected call to ArticleRepositoryMock.Update. %v %v", ctx, m) return } // UpdateAfterCounter returns a count of finished ArticleRepositoryMock.Update invocations func (mmUpdate *ArticleRepositoryMock) UpdateAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter) } // UpdateBeforeCounter returns a count of ArticleRepositoryMock.Update invocations func (mmUpdate *ArticleRepositoryMock) UpdateBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter) } // Calls returns a list of arguments used in each call to ArticleRepositoryMock.Update. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmUpdate *mArticleRepositoryMockUpdate) Calls() []*ArticleRepositoryMockUpdateParams { mmUpdate.mutex.RLock() argCopy := make([]*ArticleRepositoryMockUpdateParams, 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) MinimockUpdateInspect() { for _, e := range m.UpdateMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.Update") } else { m.t.Errorf("Expected call to ArticleRepositoryMock.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 ArticleRepositoryMock.Update") } } // MinimockFinish checks that all mocked methods have been called the expected number of times func (m *ArticleRepositoryMock) 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 *ArticleRepositoryMock) 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 *ArticleRepositoryMock) minimockDone() bool { done := true return done && m.MinimockAddDone() && m.MinimockDeleteDone() && m.MinimockGetAllDone() && m.MinimockGetAllPreviewDone() && m.MinimockGetByIDDone() && m.MinimockGetByURLDone() && m.MinimockGetPreviewByTagIDDone() && m.MinimockUpdateDone() }