123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089 |
- // Code generated by http://github.com/gojuno/minimock (v3.3.13). 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, lang models.LanguageID) (aa1 []models.ArticlePreview, err error)
- inspectFuncGetAllPreview func(ctx context.Context, lang models.LanguageID)
- 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, lang models.LanguageID) (aa1 []models.ArticlePreview, err error)
- inspectFuncGetPreviewByTagID func(ctx context.Context, tagID uint64, lang models.LanguageID)
- 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
- lang models.LanguageID
- }
- // ArticleRepositoryMockGetAllPreviewParamPtrs contains pointers to parameters of the ArticleRepository.GetAllPreview
- type ArticleRepositoryMockGetAllPreviewParamPtrs struct {
- ctx *context.Context
- lang *models.LanguageID
- }
- // 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, lang models.LanguageID) *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, lang}
- 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
- }
- // ExpectLangParam2 sets up expected param lang for ArticleRepository.GetAllPreview
- func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) ExpectLangParam2(lang models.LanguageID) *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.lang = &lang
- return mmGetAllPreview
- }
- // Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetAllPreview
- func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Inspect(f func(ctx context.Context, lang models.LanguageID)) *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, lang models.LanguageID) (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, lang models.LanguageID) *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, lang},
- }
- 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, lang models.LanguageID) (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, lang)
- }
- mm_params := ArticleRepositoryMockGetAllPreviewParams{ctx, lang}
- // 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, lang}
- 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))
- }
- if mm_want_ptrs.lang != nil && !minimock.Equal(*mm_want_ptrs.lang, mm_got.lang) {
- mmGetAllPreview.t.Errorf("ArticleRepositoryMock.GetAllPreview got unexpected parameter lang, want: %#v, got: %#v%s\n", *mm_want_ptrs.lang, mm_got.lang, minimock.Diff(*mm_want_ptrs.lang, mm_got.lang))
- }
- } 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, lang)
- }
- mmGetAllPreview.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetAllPreview. %v %v", ctx, lang)
- 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
- lang models.LanguageID
- }
- // ArticleRepositoryMockGetPreviewByTagIDParamPtrs contains pointers to parameters of the ArticleRepository.GetPreviewByTagID
- type ArticleRepositoryMockGetPreviewByTagIDParamPtrs struct {
- ctx *context.Context
- tagID *uint64
- lang *models.LanguageID
- }
- // 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, lang models.LanguageID) *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, lang}
- 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
- }
- // ExpectLangParam3 sets up expected param lang for ArticleRepository.GetPreviewByTagID
- func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectLangParam3(lang models.LanguageID) *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.lang = &lang
- 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, lang models.LanguageID)) *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, lang models.LanguageID) (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, lang models.LanguageID) *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, lang},
- }
- 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, lang models.LanguageID) (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, lang)
- }
- mm_params := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID, lang}
- // 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, lang}
- 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))
- }
- if mm_want_ptrs.lang != nil && !minimock.Equal(*mm_want_ptrs.lang, mm_got.lang) {
- mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameter lang, want: %#v, got: %#v%s\n", *mm_want_ptrs.lang, mm_got.lang, minimock.Diff(*mm_want_ptrs.lang, mm_got.lang))
- }
- } 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, lang)
- }
- mmGetPreviewByTagID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetPreviewByTagID. %v %v %v", ctx, tagID, lang)
- 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()
- }
|