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