// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT. package mocks //go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler.ArticleRepository -o article_repository_minimock.go -n ArticleRepositoryMock -p mocks import ( "context" "sync" mm_atomic "sync/atomic" mm_time "time" "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models" "github.com/gojuno/minimock/v3" ) // ArticleRepositoryMock implements handler.ArticleRepository type ArticleRepositoryMock struct { t minimock.Tester finishOnce sync.Once funcGetAllPreview func(ctx context.Context) (aa1 []models.ArticlePreview, err error) inspectFuncGetAllPreview func(ctx context.Context) afterGetAllPreviewCounter uint64 beforeGetAllPreviewCounter uint64 GetAllPreviewMock mArticleRepositoryMockGetAllPreview 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 uint64) (aa1 []models.ArticlePreview, err error) inspectFuncGetPreviewByTagID func(ctx context.Context, tagID uint64) afterGetPreviewByTagIDCounter uint64 beforeGetPreviewByTagIDCounter uint64 GetPreviewByTagIDMock mArticleRepositoryMockGetPreviewByTagID } // NewArticleRepositoryMock returns a mock for handler.ArticleRepository func NewArticleRepositoryMock(t minimock.Tester) *ArticleRepositoryMock { m := &ArticleRepositoryMock{t: t} if controller, ok := t.(minimock.MockController); ok { controller.RegisterMocker(m) } m.GetAllPreviewMock = mArticleRepositoryMockGetAllPreview{mock: m} m.GetAllPreviewMock.callArgs = []*ArticleRepositoryMockGetAllPreviewParams{} m.GetByURLMock = mArticleRepositoryMockGetByURL{mock: m} m.GetByURLMock.callArgs = []*ArticleRepositoryMockGetByURLParams{} m.GetPreviewByTagIDMock = mArticleRepositoryMockGetPreviewByTagID{mock: m} m.GetPreviewByTagIDMock.callArgs = []*ArticleRepositoryMockGetPreviewByTagIDParams{} t.Cleanup(m.MinimockFinish) return m } type mArticleRepositoryMockGetAllPreview struct { optional bool mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetAllPreviewExpectation expectations []*ArticleRepositoryMockGetAllPreviewExpectation callArgs []*ArticleRepositoryMockGetAllPreviewParams mutex sync.RWMutex expectedInvocations uint64 } // ArticleRepositoryMockGetAllPreviewExpectation specifies expectation struct of the ArticleRepository.GetAllPreview type ArticleRepositoryMockGetAllPreviewExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetAllPreviewParams paramPtrs *ArticleRepositoryMockGetAllPreviewParamPtrs results *ArticleRepositoryMockGetAllPreviewResults Counter uint64 } // ArticleRepositoryMockGetAllPreviewParams contains parameters of the ArticleRepository.GetAllPreview type ArticleRepositoryMockGetAllPreviewParams struct { ctx context.Context } // ArticleRepositoryMockGetAllPreviewParamPtrs contains pointers to parameters of the ArticleRepository.GetAllPreview type ArticleRepositoryMockGetAllPreviewParamPtrs struct { ctx *context.Context } // ArticleRepositoryMockGetAllPreviewResults contains results of the ArticleRepository.GetAllPreview type ArticleRepositoryMockGetAllPreviewResults struct { aa1 []models.ArticlePreview err error } // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning // the test will fail minimock's automatic final call check if the mocked method was not called at least once. // Optional() makes method check to work in '0 or more' mode. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to // catch the problems when the expected method call is totally skipped during test run. func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Optional() *mArticleRepositoryMockGetAllPreview { mmGetAllPreview.optional = true return mmGetAllPreview } // 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{} } if mmGetAllPreview.defaultExpectation.paramPtrs != nil { mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by ExpectParams functions") } 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 } // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetAllPreview func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) ExpectCtxParam1(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{} } if mmGetAllPreview.defaultExpectation.params != nil { mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Expect") } if mmGetAllPreview.defaultExpectation.paramPtrs == nil { mmGetAllPreview.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetAllPreviewParamPtrs{} } mmGetAllPreview.defaultExpectation.paramPtrs.ctx = &ctx 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 } // Times sets number of times ArticleRepository.GetAllPreview should be invoked func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Times(n uint64) *mArticleRepositoryMockGetAllPreview { if n == 0 { mmGetAllPreview.mock.t.Fatalf("Times of ArticleRepositoryMock.GetAllPreview mock can not be zero") } mm_atomic.StoreUint64(&mmGetAllPreview.expectedInvocations, n) return mmGetAllPreview } func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) invocationsDone() bool { if len(mmGetAllPreview.expectations) == 0 && mmGetAllPreview.defaultExpectation == nil && mmGetAllPreview.mock.funcGetAllPreview == nil { return true } totalInvocations := mm_atomic.LoadUint64(&mmGetAllPreview.mock.afterGetAllPreviewCounter) expectedInvocations := mm_atomic.LoadUint64(&mmGetAllPreview.expectedInvocations) return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) } // GetAllPreview implements handler.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_want_ptrs := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.paramPtrs mm_got := ArticleRepositoryMockGetAllPreviewParams{ctx} if mm_want_ptrs != nil { if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { mmGetAllPreview.t.Errorf("ArticleRepositoryMock.GetAllPreview got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) } } else 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 { if m.GetAllPreviewMock.optional { // Optional methods provide '0 or more' call count restriction. return true } for _, e := range m.GetAllPreviewMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } return m.GetAllPreviewMock.invocationsDone() } // 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) } } afterGetAllPreviewCounter := mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) // if default expectation was set then invocations count should be greater than zero if m.GetAllPreviewMock.defaultExpectation != nil && 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 && afterGetAllPreviewCounter < 1 { m.t.Error("Expected call to ArticleRepositoryMock.GetAllPreview") } if !m.GetAllPreviewMock.invocationsDone() && afterGetAllPreviewCounter > 0 { m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetAllPreview but found %d calls", mm_atomic.LoadUint64(&m.GetAllPreviewMock.expectedInvocations), afterGetAllPreviewCounter) } } type mArticleRepositoryMockGetByURL struct { optional bool mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetByURLExpectation expectations []*ArticleRepositoryMockGetByURLExpectation callArgs []*ArticleRepositoryMockGetByURLParams mutex sync.RWMutex expectedInvocations uint64 } // ArticleRepositoryMockGetByURLExpectation specifies expectation struct of the ArticleRepository.GetByURL type ArticleRepositoryMockGetByURLExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetByURLParams paramPtrs *ArticleRepositoryMockGetByURLParamPtrs results *ArticleRepositoryMockGetByURLResults Counter uint64 } // ArticleRepositoryMockGetByURLParams contains parameters of the ArticleRepository.GetByURL type ArticleRepositoryMockGetByURLParams struct { ctx context.Context url string } // ArticleRepositoryMockGetByURLParamPtrs contains pointers to parameters of the ArticleRepository.GetByURL type ArticleRepositoryMockGetByURLParamPtrs struct { ctx *context.Context url *string } // ArticleRepositoryMockGetByURLResults contains results of the ArticleRepository.GetByURL type ArticleRepositoryMockGetByURLResults struct { ap1 *models.Article err error } // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning // the test will fail minimock's automatic final call check if the mocked method was not called at least once. // Optional() makes method check to work in '0 or more' mode. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to // catch the problems when the expected method call is totally skipped during test run. func (mmGetByURL *mArticleRepositoryMockGetByURL) Optional() *mArticleRepositoryMockGetByURL { mmGetByURL.optional = true return mmGetByURL } // 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{} } if mmGetByURL.defaultExpectation.paramPtrs != nil { mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by ExpectParams functions") } 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 } // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetByURL func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectCtxParam1(ctx context.Context) *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{} } if mmGetByURL.defaultExpectation.params != nil { mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect") } if mmGetByURL.defaultExpectation.paramPtrs == nil { mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{} } mmGetByURL.defaultExpectation.paramPtrs.ctx = &ctx return mmGetByURL } // ExpectUrlParam2 sets up expected param url for ArticleRepository.GetByURL func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectUrlParam2(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{} } if mmGetByURL.defaultExpectation.params != nil { mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect") } if mmGetByURL.defaultExpectation.paramPtrs == nil { mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{} } mmGetByURL.defaultExpectation.paramPtrs.url = &url 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 } // Times sets number of times ArticleRepository.GetByURL should be invoked func (mmGetByURL *mArticleRepositoryMockGetByURL) Times(n uint64) *mArticleRepositoryMockGetByURL { if n == 0 { mmGetByURL.mock.t.Fatalf("Times of ArticleRepositoryMock.GetByURL mock can not be zero") } mm_atomic.StoreUint64(&mmGetByURL.expectedInvocations, n) return mmGetByURL } func (mmGetByURL *mArticleRepositoryMockGetByURL) invocationsDone() bool { if len(mmGetByURL.expectations) == 0 && mmGetByURL.defaultExpectation == nil && mmGetByURL.mock.funcGetByURL == nil { return true } totalInvocations := mm_atomic.LoadUint64(&mmGetByURL.mock.afterGetByURLCounter) expectedInvocations := mm_atomic.LoadUint64(&mmGetByURL.expectedInvocations) return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) } // GetByURL implements handler.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_want_ptrs := mmGetByURL.GetByURLMock.defaultExpectation.paramPtrs mm_got := ArticleRepositoryMockGetByURLParams{ctx, url} if mm_want_ptrs != nil { if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) } if mm_want_ptrs.url != nil && !minimock.Equal(*mm_want_ptrs.url, mm_got.url) { mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameter url, want: %#v, got: %#v%s\n", *mm_want_ptrs.url, mm_got.url, minimock.Diff(*mm_want_ptrs.url, mm_got.url)) } } else 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 { if m.GetByURLMock.optional { // Optional methods provide '0 or more' call count restriction. return true } for _, e := range m.GetByURLMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } return m.GetByURLMock.invocationsDone() } // 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) } } afterGetByURLCounter := mm_atomic.LoadUint64(&m.afterGetByURLCounter) // if default expectation was set then invocations count should be greater than zero if m.GetByURLMock.defaultExpectation != nil && 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 && afterGetByURLCounter < 1 { m.t.Error("Expected call to ArticleRepositoryMock.GetByURL") } if !m.GetByURLMock.invocationsDone() && afterGetByURLCounter > 0 { m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetByURL but found %d calls", mm_atomic.LoadUint64(&m.GetByURLMock.expectedInvocations), afterGetByURLCounter) } } type mArticleRepositoryMockGetPreviewByTagID struct { optional bool mock *ArticleRepositoryMock defaultExpectation *ArticleRepositoryMockGetPreviewByTagIDExpectation expectations []*ArticleRepositoryMockGetPreviewByTagIDExpectation callArgs []*ArticleRepositoryMockGetPreviewByTagIDParams mutex sync.RWMutex expectedInvocations uint64 } // ArticleRepositoryMockGetPreviewByTagIDExpectation specifies expectation struct of the ArticleRepository.GetPreviewByTagID type ArticleRepositoryMockGetPreviewByTagIDExpectation struct { mock *ArticleRepositoryMock params *ArticleRepositoryMockGetPreviewByTagIDParams paramPtrs *ArticleRepositoryMockGetPreviewByTagIDParamPtrs results *ArticleRepositoryMockGetPreviewByTagIDResults Counter uint64 } // ArticleRepositoryMockGetPreviewByTagIDParams contains parameters of the ArticleRepository.GetPreviewByTagID type ArticleRepositoryMockGetPreviewByTagIDParams struct { ctx context.Context tagID uint64 } // ArticleRepositoryMockGetPreviewByTagIDParamPtrs contains pointers to parameters of the ArticleRepository.GetPreviewByTagID type ArticleRepositoryMockGetPreviewByTagIDParamPtrs struct { ctx *context.Context tagID *uint64 } // ArticleRepositoryMockGetPreviewByTagIDResults contains results of the ArticleRepository.GetPreviewByTagID type ArticleRepositoryMockGetPreviewByTagIDResults struct { aa1 []models.ArticlePreview err error } // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning // the test will fail minimock's automatic final call check if the mocked method was not called at least once. // Optional() makes method check to work in '0 or more' mode. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to // catch the problems when the expected method call is totally skipped during test run. func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Optional() *mArticleRepositoryMockGetPreviewByTagID { mmGetPreviewByTagID.optional = true return mmGetPreviewByTagID } // Expect sets up expected params for ArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Expect(ctx context.Context, tagID uint64) *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{} } if mmGetPreviewByTagID.defaultExpectation.paramPtrs != nil { mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by ExpectParams functions") } 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 } // ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectCtxParam1(ctx context.Context) *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{} } if mmGetPreviewByTagID.defaultExpectation.params != nil { mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect") } if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil { mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{} } mmGetPreviewByTagID.defaultExpectation.paramPtrs.ctx = &ctx return mmGetPreviewByTagID } // ExpectTagIDParam2 sets up expected param tagID for ArticleRepository.GetPreviewByTagID func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectTagIDParam2(tagID uint64) *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{} } if mmGetPreviewByTagID.defaultExpectation.params != nil { mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect") } if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil { mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{} } mmGetPreviewByTagID.defaultExpectation.paramPtrs.tagID = &tagID 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 uint64)) *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 uint64) (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 uint64) *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 } // Times sets number of times ArticleRepository.GetPreviewByTagID should be invoked func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Times(n uint64) *mArticleRepositoryMockGetPreviewByTagID { if n == 0 { mmGetPreviewByTagID.mock.t.Fatalf("Times of ArticleRepositoryMock.GetPreviewByTagID mock can not be zero") } mm_atomic.StoreUint64(&mmGetPreviewByTagID.expectedInvocations, n) return mmGetPreviewByTagID } func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) invocationsDone() bool { if len(mmGetPreviewByTagID.expectations) == 0 && mmGetPreviewByTagID.defaultExpectation == nil && mmGetPreviewByTagID.mock.funcGetPreviewByTagID == nil { return true } totalInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.mock.afterGetPreviewByTagIDCounter) expectedInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.expectedInvocations) return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) } // GetPreviewByTagID implements handler.ArticleRepository func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagID(ctx context.Context, tagID uint64) (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_want_ptrs := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.paramPtrs mm_got := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID} if mm_want_ptrs != nil { if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) } if mm_want_ptrs.tagID != nil && !minimock.Equal(*mm_want_ptrs.tagID, mm_got.tagID) { mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameter tagID, want: %#v, got: %#v%s\n", *mm_want_ptrs.tagID, mm_got.tagID, minimock.Diff(*mm_want_ptrs.tagID, mm_got.tagID)) } } else 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 { if m.GetPreviewByTagIDMock.optional { // Optional methods provide '0 or more' call count restriction. return true } for _, e := range m.GetPreviewByTagIDMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } return m.GetPreviewByTagIDMock.invocationsDone() } // 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) } } afterGetPreviewByTagIDCounter := mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) // if default expectation was set then invocations count should be greater than zero if m.GetPreviewByTagIDMock.defaultExpectation != nil && 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 && afterGetPreviewByTagIDCounter < 1 { m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID") } if !m.GetPreviewByTagIDMock.invocationsDone() && afterGetPreviewByTagIDCounter > 0 { m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetPreviewByTagID but found %d calls", mm_atomic.LoadUint64(&m.GetPreviewByTagIDMock.expectedInvocations), afterGetPreviewByTagIDCounter) } } // MinimockFinish checks that all mocked methods have been called the expected number of times func (m *ArticleRepositoryMock) MinimockFinish() { m.finishOnce.Do(func() { if !m.minimockDone() { m.MinimockGetAllPreviewInspect() m.MinimockGetByURLInspect() m.MinimockGetPreviewByTagIDInspect() } }) } // 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.MinimockGetAllPreviewDone() && m.MinimockGetByURLDone() && m.MinimockGetPreviewByTagIDDone() }