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