1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752 |
- // Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
- package mocks
- //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place.PlaceRepository -o place_repository_minimock.go -n PlaceRepositoryMock -p mocks
- import (
- "context"
- "database/sql"
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "git.dmitriygnatenko.ru/dima/homethings/internal/models"
- "github.com/gojuno/minimock/v3"
- )
- // PlaceRepositoryMock implements place.PlaceRepository
- type PlaceRepositoryMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcAdd func(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) (i1 int, err error)
- inspectFuncAdd func(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mPlaceRepositoryMockAdd
- funcBeginTx func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)
- inspectFuncBeginTx func(ctx context.Context, level sql.IsolationLevel)
- afterBeginTxCounter uint64
- beforeBeginTxCounter uint64
- BeginTxMock mPlaceRepositoryMockBeginTx
- funcCommitTx func(tx *sql.Tx) (err error)
- inspectFuncCommitTx func(tx *sql.Tx)
- afterCommitTxCounter uint64
- beforeCommitTxCounter uint64
- CommitTxMock mPlaceRepositoryMockCommitTx
- funcDelete func(ctx context.Context, placeID int, tx *sql.Tx) (err error)
- inspectFuncDelete func(ctx context.Context, placeID int, tx *sql.Tx)
- afterDeleteCounter uint64
- beforeDeleteCounter uint64
- DeleteMock mPlaceRepositoryMockDelete
- funcGet func(ctx context.Context, placeID int) (pp1 *models.Place, err error)
- inspectFuncGet func(ctx context.Context, placeID int)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mPlaceRepositoryMockGet
- funcGetAll func(ctx context.Context) (pa1 []models.Place, err error)
- inspectFuncGetAll func(ctx context.Context)
- afterGetAllCounter uint64
- beforeGetAllCounter uint64
- GetAllMock mPlaceRepositoryMockGetAll
- funcGetNestedPlaces func(ctx context.Context, placeID int) (pa1 []models.Place, err error)
- inspectFuncGetNestedPlaces func(ctx context.Context, placeID int)
- afterGetNestedPlacesCounter uint64
- beforeGetNestedPlacesCounter uint64
- GetNestedPlacesMock mPlaceRepositoryMockGetNestedPlaces
- funcUpdate func(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) (err error)
- inspectFuncUpdate func(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx)
- afterUpdateCounter uint64
- beforeUpdateCounter uint64
- UpdateMock mPlaceRepositoryMockUpdate
- }
- // NewPlaceRepositoryMock returns a mock for place.PlaceRepository
- func NewPlaceRepositoryMock(t minimock.Tester) *PlaceRepositoryMock {
- m := &PlaceRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mPlaceRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*PlaceRepositoryMockAddParams{}
- m.BeginTxMock = mPlaceRepositoryMockBeginTx{mock: m}
- m.BeginTxMock.callArgs = []*PlaceRepositoryMockBeginTxParams{}
- m.CommitTxMock = mPlaceRepositoryMockCommitTx{mock: m}
- m.CommitTxMock.callArgs = []*PlaceRepositoryMockCommitTxParams{}
- m.DeleteMock = mPlaceRepositoryMockDelete{mock: m}
- m.DeleteMock.callArgs = []*PlaceRepositoryMockDeleteParams{}
- m.GetMock = mPlaceRepositoryMockGet{mock: m}
- m.GetMock.callArgs = []*PlaceRepositoryMockGetParams{}
- m.GetAllMock = mPlaceRepositoryMockGetAll{mock: m}
- m.GetAllMock.callArgs = []*PlaceRepositoryMockGetAllParams{}
- m.GetNestedPlacesMock = mPlaceRepositoryMockGetNestedPlaces{mock: m}
- m.GetNestedPlacesMock.callArgs = []*PlaceRepositoryMockGetNestedPlacesParams{}
- m.UpdateMock = mPlaceRepositoryMockUpdate{mock: m}
- m.UpdateMock.callArgs = []*PlaceRepositoryMockUpdateParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mPlaceRepositoryMockAdd struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockAddExpectation
- expectations []*PlaceRepositoryMockAddExpectation
- callArgs []*PlaceRepositoryMockAddParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockAddExpectation specifies expectation struct of the PlaceRepository.Add
- type PlaceRepositoryMockAddExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockAddParams
- paramPtrs *PlaceRepositoryMockAddParamPtrs
- results *PlaceRepositoryMockAddResults
- Counter uint64
- }
- // PlaceRepositoryMockAddParams contains parameters of the PlaceRepository.Add
- type PlaceRepositoryMockAddParams struct {
- ctx context.Context
- req models.AddPlaceRequest
- tx *sql.Tx
- }
- // PlaceRepositoryMockAddParamPtrs contains pointers to parameters of the PlaceRepository.Add
- type PlaceRepositoryMockAddParamPtrs struct {
- ctx *context.Context
- req *models.AddPlaceRequest
- tx **sql.Tx
- }
- // PlaceRepositoryMockAddResults contains results of the PlaceRepository.Add
- type PlaceRepositoryMockAddResults struct {
- i1 int
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmAdd *mPlaceRepositoryMockAdd) Optional() *mPlaceRepositoryMockAdd {
- mmAdd.optional = true
- return mmAdd
- }
- // Expect sets up expected params for PlaceRepository.Add
- func (mmAdd *mPlaceRepositoryMockAdd) Expect(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) *mPlaceRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.paramPtrs != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by ExpectParams functions")
- }
- mmAdd.defaultExpectation.params = &PlaceRepositoryMockAddParams{ctx, req, tx}
- 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
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceRepository.Add
- func (mmAdd *mPlaceRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mPlaceRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &PlaceRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
- return mmAdd
- }
- // ExpectReqParam2 sets up expected param req for PlaceRepository.Add
- func (mmAdd *mPlaceRepositoryMockAdd) ExpectReqParam2(req models.AddPlaceRequest) *mPlaceRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &PlaceRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.req = &req
- return mmAdd
- }
- // ExpectTxParam3 sets up expected param tx for PlaceRepository.Add
- func (mmAdd *mPlaceRepositoryMockAdd) ExpectTxParam3(tx *sql.Tx) *mPlaceRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &PlaceRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.tx = &tx
- return mmAdd
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.Add
- func (mmAdd *mPlaceRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx)) *mPlaceRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by PlaceRepository.Add
- func (mmAdd *mPlaceRepositoryMockAdd) Return(i1 int, err error) *PlaceRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &PlaceRepositoryMockAddResults{i1, err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the PlaceRepository.Add method
- func (mmAdd *mPlaceRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) (i1 int, err error)) *PlaceRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the PlaceRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mPlaceRepositoryMockAdd) When(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) *PlaceRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceRepositoryMock.Add mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &PlaceRepositoryMockAddParams{ctx, req, tx},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.Add return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockAddExpectation) Then(i1 int, err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockAddResults{i1, err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.Add should be invoked
- func (mmAdd *mPlaceRepositoryMockAdd) Times(n uint64) *mPlaceRepositoryMockAdd {
- if n == 0 {
- mmAdd.mock.t.Fatalf("Times of PlaceRepositoryMock.Add mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
- return mmAdd
- }
- func (mmAdd *mPlaceRepositoryMockAdd) invocationsDone() bool {
- if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Add implements place.PlaceRepository
- func (mmAdd *PlaceRepositoryMock) Add(ctx context.Context, req models.AddPlaceRequest, tx *sql.Tx) (i1 int, err error) {
- mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
- defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
- if mmAdd.inspectFuncAdd != nil {
- mmAdd.inspectFuncAdd(ctx, req, tx)
- }
- mm_params := PlaceRepositoryMockAddParams{ctx, req, tx}
- // 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_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockAddParams{ctx, req, tx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmAdd.t.Errorf("PlaceRepositoryMock.Add got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
- mmAdd.t.Errorf("PlaceRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
- }
- if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
- mmAdd.t.Errorf("PlaceRepositoryMock.Add got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmAdd.t.Errorf("PlaceRepositoryMock.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 PlaceRepositoryMock.Add")
- }
- return (*mm_results).i1, (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, req, tx)
- }
- mmAdd.t.Fatalf("Unexpected call to PlaceRepositoryMock.Add. %v %v %v", ctx, req, tx)
- return
- }
- // AddAfterCounter returns a count of finished PlaceRepositoryMock.Add invocations
- func (mmAdd *PlaceRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of PlaceRepositoryMock.Add invocations
- func (mmAdd *PlaceRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mPlaceRepositoryMockAdd) Calls() []*PlaceRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockAddParams, 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 *PlaceRepositoryMock) MinimockAddDone() bool {
- if m.AddMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.AddMock.invocationsDone()
- }
- // MinimockAddInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Add with params: %#v", *e.params)
- }
- }
- afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
- if m.AddMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcAdd != nil && afterAddCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.Add")
- }
- if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.Add but found %d calls",
- mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
- }
- }
- type mPlaceRepositoryMockBeginTx struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockBeginTxExpectation
- expectations []*PlaceRepositoryMockBeginTxExpectation
- callArgs []*PlaceRepositoryMockBeginTxParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockBeginTxExpectation specifies expectation struct of the PlaceRepository.BeginTx
- type PlaceRepositoryMockBeginTxExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockBeginTxParams
- paramPtrs *PlaceRepositoryMockBeginTxParamPtrs
- results *PlaceRepositoryMockBeginTxResults
- Counter uint64
- }
- // PlaceRepositoryMockBeginTxParams contains parameters of the PlaceRepository.BeginTx
- type PlaceRepositoryMockBeginTxParams struct {
- ctx context.Context
- level sql.IsolationLevel
- }
- // PlaceRepositoryMockBeginTxParamPtrs contains pointers to parameters of the PlaceRepository.BeginTx
- type PlaceRepositoryMockBeginTxParamPtrs struct {
- ctx *context.Context
- level *sql.IsolationLevel
- }
- // PlaceRepositoryMockBeginTxResults contains results of the PlaceRepository.BeginTx
- type PlaceRepositoryMockBeginTxResults struct {
- tp1 *sql.Tx
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) Optional() *mPlaceRepositoryMockBeginTx {
- mmBeginTx.optional = true
- return mmBeginTx
- }
- // Expect sets up expected params for PlaceRepository.BeginTx
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) Expect(ctx context.Context, level sql.IsolationLevel) *mPlaceRepositoryMockBeginTx {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &PlaceRepositoryMockBeginTxExpectation{}
- }
- if mmBeginTx.defaultExpectation.paramPtrs != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by ExpectParams functions")
- }
- mmBeginTx.defaultExpectation.params = &PlaceRepositoryMockBeginTxParams{ctx, level}
- for _, e := range mmBeginTx.expectations {
- if minimock.Equal(e.params, mmBeginTx.defaultExpectation.params) {
- mmBeginTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmBeginTx.defaultExpectation.params)
- }
- }
- return mmBeginTx
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceRepository.BeginTx
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) ExpectCtxParam1(ctx context.Context) *mPlaceRepositoryMockBeginTx {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &PlaceRepositoryMockBeginTxExpectation{}
- }
- if mmBeginTx.defaultExpectation.params != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by Expect")
- }
- if mmBeginTx.defaultExpectation.paramPtrs == nil {
- mmBeginTx.defaultExpectation.paramPtrs = &PlaceRepositoryMockBeginTxParamPtrs{}
- }
- mmBeginTx.defaultExpectation.paramPtrs.ctx = &ctx
- return mmBeginTx
- }
- // ExpectLevelParam2 sets up expected param level for PlaceRepository.BeginTx
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) ExpectLevelParam2(level sql.IsolationLevel) *mPlaceRepositoryMockBeginTx {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &PlaceRepositoryMockBeginTxExpectation{}
- }
- if mmBeginTx.defaultExpectation.params != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by Expect")
- }
- if mmBeginTx.defaultExpectation.paramPtrs == nil {
- mmBeginTx.defaultExpectation.paramPtrs = &PlaceRepositoryMockBeginTxParamPtrs{}
- }
- mmBeginTx.defaultExpectation.paramPtrs.level = &level
- return mmBeginTx
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.BeginTx
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) Inspect(f func(ctx context.Context, level sql.IsolationLevel)) *mPlaceRepositoryMockBeginTx {
- if mmBeginTx.mock.inspectFuncBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.BeginTx")
- }
- mmBeginTx.mock.inspectFuncBeginTx = f
- return mmBeginTx
- }
- // Return sets up results that will be returned by PlaceRepository.BeginTx
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) Return(tp1 *sql.Tx, err error) *PlaceRepositoryMock {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &PlaceRepositoryMockBeginTxExpectation{mock: mmBeginTx.mock}
- }
- mmBeginTx.defaultExpectation.results = &PlaceRepositoryMockBeginTxResults{tp1, err}
- return mmBeginTx.mock
- }
- // Set uses given function f to mock the PlaceRepository.BeginTx method
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) Set(f func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)) *PlaceRepositoryMock {
- if mmBeginTx.defaultExpectation != nil {
- mmBeginTx.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.BeginTx method")
- }
- if len(mmBeginTx.expectations) > 0 {
- mmBeginTx.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.BeginTx method")
- }
- mmBeginTx.mock.funcBeginTx = f
- return mmBeginTx.mock
- }
- // When sets expectation for the PlaceRepository.BeginTx which will trigger the result defined by the following
- // Then helper
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) When(ctx context.Context, level sql.IsolationLevel) *PlaceRepositoryMockBeginTxExpectation {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("PlaceRepositoryMock.BeginTx mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockBeginTxExpectation{
- mock: mmBeginTx.mock,
- params: &PlaceRepositoryMockBeginTxParams{ctx, level},
- }
- mmBeginTx.expectations = append(mmBeginTx.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.BeginTx return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockBeginTxExpectation) Then(tp1 *sql.Tx, err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockBeginTxResults{tp1, err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.BeginTx should be invoked
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) Times(n uint64) *mPlaceRepositoryMockBeginTx {
- if n == 0 {
- mmBeginTx.mock.t.Fatalf("Times of PlaceRepositoryMock.BeginTx mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmBeginTx.expectedInvocations, n)
- return mmBeginTx
- }
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) invocationsDone() bool {
- if len(mmBeginTx.expectations) == 0 && mmBeginTx.defaultExpectation == nil && mmBeginTx.mock.funcBeginTx == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmBeginTx.mock.afterBeginTxCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmBeginTx.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // BeginTx implements place.PlaceRepository
- func (mmBeginTx *PlaceRepositoryMock) BeginTx(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error) {
- mm_atomic.AddUint64(&mmBeginTx.beforeBeginTxCounter, 1)
- defer mm_atomic.AddUint64(&mmBeginTx.afterBeginTxCounter, 1)
- if mmBeginTx.inspectFuncBeginTx != nil {
- mmBeginTx.inspectFuncBeginTx(ctx, level)
- }
- mm_params := PlaceRepositoryMockBeginTxParams{ctx, level}
- // Record call args
- mmBeginTx.BeginTxMock.mutex.Lock()
- mmBeginTx.BeginTxMock.callArgs = append(mmBeginTx.BeginTxMock.callArgs, &mm_params)
- mmBeginTx.BeginTxMock.mutex.Unlock()
- for _, e := range mmBeginTx.BeginTxMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.tp1, e.results.err
- }
- }
- if mmBeginTx.BeginTxMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmBeginTx.BeginTxMock.defaultExpectation.Counter, 1)
- mm_want := mmBeginTx.BeginTxMock.defaultExpectation.params
- mm_want_ptrs := mmBeginTx.BeginTxMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockBeginTxParams{ctx, level}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmBeginTx.t.Errorf("PlaceRepositoryMock.BeginTx got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.level != nil && !minimock.Equal(*mm_want_ptrs.level, mm_got.level) {
- mmBeginTx.t.Errorf("PlaceRepositoryMock.BeginTx got unexpected parameter level, want: %#v, got: %#v%s\n", *mm_want_ptrs.level, mm_got.level, minimock.Diff(*mm_want_ptrs.level, mm_got.level))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmBeginTx.t.Errorf("PlaceRepositoryMock.BeginTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmBeginTx.BeginTxMock.defaultExpectation.results
- if mm_results == nil {
- mmBeginTx.t.Fatal("No results are set for the PlaceRepositoryMock.BeginTx")
- }
- return (*mm_results).tp1, (*mm_results).err
- }
- if mmBeginTx.funcBeginTx != nil {
- return mmBeginTx.funcBeginTx(ctx, level)
- }
- mmBeginTx.t.Fatalf("Unexpected call to PlaceRepositoryMock.BeginTx. %v %v", ctx, level)
- return
- }
- // BeginTxAfterCounter returns a count of finished PlaceRepositoryMock.BeginTx invocations
- func (mmBeginTx *PlaceRepositoryMock) BeginTxAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmBeginTx.afterBeginTxCounter)
- }
- // BeginTxBeforeCounter returns a count of PlaceRepositoryMock.BeginTx invocations
- func (mmBeginTx *PlaceRepositoryMock) BeginTxBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmBeginTx.beforeBeginTxCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.BeginTx.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmBeginTx *mPlaceRepositoryMockBeginTx) Calls() []*PlaceRepositoryMockBeginTxParams {
- mmBeginTx.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockBeginTxParams, len(mmBeginTx.callArgs))
- copy(argCopy, mmBeginTx.callArgs)
- mmBeginTx.mutex.RUnlock()
- return argCopy
- }
- // MinimockBeginTxDone returns true if the count of the BeginTx invocations corresponds
- // the number of defined expectations
- func (m *PlaceRepositoryMock) MinimockBeginTxDone() bool {
- if m.BeginTxMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.BeginTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.BeginTxMock.invocationsDone()
- }
- // MinimockBeginTxInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockBeginTxInspect() {
- for _, e := range m.BeginTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.BeginTx with params: %#v", *e.params)
- }
- }
- afterBeginTxCounter := mm_atomic.LoadUint64(&m.afterBeginTxCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.BeginTxMock.defaultExpectation != nil && afterBeginTxCounter < 1 {
- if m.BeginTxMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.BeginTx")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.BeginTx with params: %#v", *m.BeginTxMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcBeginTx != nil && afterBeginTxCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.BeginTx")
- }
- if !m.BeginTxMock.invocationsDone() && afterBeginTxCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.BeginTx but found %d calls",
- mm_atomic.LoadUint64(&m.BeginTxMock.expectedInvocations), afterBeginTxCounter)
- }
- }
- type mPlaceRepositoryMockCommitTx struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockCommitTxExpectation
- expectations []*PlaceRepositoryMockCommitTxExpectation
- callArgs []*PlaceRepositoryMockCommitTxParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockCommitTxExpectation specifies expectation struct of the PlaceRepository.CommitTx
- type PlaceRepositoryMockCommitTxExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockCommitTxParams
- paramPtrs *PlaceRepositoryMockCommitTxParamPtrs
- results *PlaceRepositoryMockCommitTxResults
- Counter uint64
- }
- // PlaceRepositoryMockCommitTxParams contains parameters of the PlaceRepository.CommitTx
- type PlaceRepositoryMockCommitTxParams struct {
- tx *sql.Tx
- }
- // PlaceRepositoryMockCommitTxParamPtrs contains pointers to parameters of the PlaceRepository.CommitTx
- type PlaceRepositoryMockCommitTxParamPtrs struct {
- tx **sql.Tx
- }
- // PlaceRepositoryMockCommitTxResults contains results of the PlaceRepository.CommitTx
- type PlaceRepositoryMockCommitTxResults struct {
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) Optional() *mPlaceRepositoryMockCommitTx {
- mmCommitTx.optional = true
- return mmCommitTx
- }
- // Expect sets up expected params for PlaceRepository.CommitTx
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) Expect(tx *sql.Tx) *mPlaceRepositoryMockCommitTx {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("PlaceRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &PlaceRepositoryMockCommitTxExpectation{}
- }
- if mmCommitTx.defaultExpectation.paramPtrs != nil {
- mmCommitTx.mock.t.Fatalf("PlaceRepositoryMock.CommitTx mock is already set by ExpectParams functions")
- }
- mmCommitTx.defaultExpectation.params = &PlaceRepositoryMockCommitTxParams{tx}
- for _, e := range mmCommitTx.expectations {
- if minimock.Equal(e.params, mmCommitTx.defaultExpectation.params) {
- mmCommitTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCommitTx.defaultExpectation.params)
- }
- }
- return mmCommitTx
- }
- // ExpectTxParam1 sets up expected param tx for PlaceRepository.CommitTx
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) ExpectTxParam1(tx *sql.Tx) *mPlaceRepositoryMockCommitTx {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("PlaceRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &PlaceRepositoryMockCommitTxExpectation{}
- }
- if mmCommitTx.defaultExpectation.params != nil {
- mmCommitTx.mock.t.Fatalf("PlaceRepositoryMock.CommitTx mock is already set by Expect")
- }
- if mmCommitTx.defaultExpectation.paramPtrs == nil {
- mmCommitTx.defaultExpectation.paramPtrs = &PlaceRepositoryMockCommitTxParamPtrs{}
- }
- mmCommitTx.defaultExpectation.paramPtrs.tx = &tx
- return mmCommitTx
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.CommitTx
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) Inspect(f func(tx *sql.Tx)) *mPlaceRepositoryMockCommitTx {
- if mmCommitTx.mock.inspectFuncCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.CommitTx")
- }
- mmCommitTx.mock.inspectFuncCommitTx = f
- return mmCommitTx
- }
- // Return sets up results that will be returned by PlaceRepository.CommitTx
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) Return(err error) *PlaceRepositoryMock {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("PlaceRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &PlaceRepositoryMockCommitTxExpectation{mock: mmCommitTx.mock}
- }
- mmCommitTx.defaultExpectation.results = &PlaceRepositoryMockCommitTxResults{err}
- return mmCommitTx.mock
- }
- // Set uses given function f to mock the PlaceRepository.CommitTx method
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) Set(f func(tx *sql.Tx) (err error)) *PlaceRepositoryMock {
- if mmCommitTx.defaultExpectation != nil {
- mmCommitTx.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.CommitTx method")
- }
- if len(mmCommitTx.expectations) > 0 {
- mmCommitTx.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.CommitTx method")
- }
- mmCommitTx.mock.funcCommitTx = f
- return mmCommitTx.mock
- }
- // When sets expectation for the PlaceRepository.CommitTx which will trigger the result defined by the following
- // Then helper
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) When(tx *sql.Tx) *PlaceRepositoryMockCommitTxExpectation {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("PlaceRepositoryMock.CommitTx mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockCommitTxExpectation{
- mock: mmCommitTx.mock,
- params: &PlaceRepositoryMockCommitTxParams{tx},
- }
- mmCommitTx.expectations = append(mmCommitTx.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.CommitTx return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockCommitTxExpectation) Then(err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockCommitTxResults{err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.CommitTx should be invoked
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) Times(n uint64) *mPlaceRepositoryMockCommitTx {
- if n == 0 {
- mmCommitTx.mock.t.Fatalf("Times of PlaceRepositoryMock.CommitTx mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmCommitTx.expectedInvocations, n)
- return mmCommitTx
- }
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) invocationsDone() bool {
- if len(mmCommitTx.expectations) == 0 && mmCommitTx.defaultExpectation == nil && mmCommitTx.mock.funcCommitTx == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmCommitTx.mock.afterCommitTxCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmCommitTx.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // CommitTx implements place.PlaceRepository
- func (mmCommitTx *PlaceRepositoryMock) CommitTx(tx *sql.Tx) (err error) {
- mm_atomic.AddUint64(&mmCommitTx.beforeCommitTxCounter, 1)
- defer mm_atomic.AddUint64(&mmCommitTx.afterCommitTxCounter, 1)
- if mmCommitTx.inspectFuncCommitTx != nil {
- mmCommitTx.inspectFuncCommitTx(tx)
- }
- mm_params := PlaceRepositoryMockCommitTxParams{tx}
- // Record call args
- mmCommitTx.CommitTxMock.mutex.Lock()
- mmCommitTx.CommitTxMock.callArgs = append(mmCommitTx.CommitTxMock.callArgs, &mm_params)
- mmCommitTx.CommitTxMock.mutex.Unlock()
- for _, e := range mmCommitTx.CommitTxMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.err
- }
- }
- if mmCommitTx.CommitTxMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmCommitTx.CommitTxMock.defaultExpectation.Counter, 1)
- mm_want := mmCommitTx.CommitTxMock.defaultExpectation.params
- mm_want_ptrs := mmCommitTx.CommitTxMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockCommitTxParams{tx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
- mmCommitTx.t.Errorf("PlaceRepositoryMock.CommitTx got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmCommitTx.t.Errorf("PlaceRepositoryMock.CommitTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmCommitTx.CommitTxMock.defaultExpectation.results
- if mm_results == nil {
- mmCommitTx.t.Fatal("No results are set for the PlaceRepositoryMock.CommitTx")
- }
- return (*mm_results).err
- }
- if mmCommitTx.funcCommitTx != nil {
- return mmCommitTx.funcCommitTx(tx)
- }
- mmCommitTx.t.Fatalf("Unexpected call to PlaceRepositoryMock.CommitTx. %v", tx)
- return
- }
- // CommitTxAfterCounter returns a count of finished PlaceRepositoryMock.CommitTx invocations
- func (mmCommitTx *PlaceRepositoryMock) CommitTxAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmCommitTx.afterCommitTxCounter)
- }
- // CommitTxBeforeCounter returns a count of PlaceRepositoryMock.CommitTx invocations
- func (mmCommitTx *PlaceRepositoryMock) CommitTxBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmCommitTx.beforeCommitTxCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.CommitTx.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmCommitTx *mPlaceRepositoryMockCommitTx) Calls() []*PlaceRepositoryMockCommitTxParams {
- mmCommitTx.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockCommitTxParams, len(mmCommitTx.callArgs))
- copy(argCopy, mmCommitTx.callArgs)
- mmCommitTx.mutex.RUnlock()
- return argCopy
- }
- // MinimockCommitTxDone returns true if the count of the CommitTx invocations corresponds
- // the number of defined expectations
- func (m *PlaceRepositoryMock) MinimockCommitTxDone() bool {
- if m.CommitTxMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.CommitTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.CommitTxMock.invocationsDone()
- }
- // MinimockCommitTxInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockCommitTxInspect() {
- for _, e := range m.CommitTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.CommitTx with params: %#v", *e.params)
- }
- }
- afterCommitTxCounter := mm_atomic.LoadUint64(&m.afterCommitTxCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.CommitTxMock.defaultExpectation != nil && afterCommitTxCounter < 1 {
- if m.CommitTxMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.CommitTx")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.CommitTx with params: %#v", *m.CommitTxMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcCommitTx != nil && afterCommitTxCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.CommitTx")
- }
- if !m.CommitTxMock.invocationsDone() && afterCommitTxCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.CommitTx but found %d calls",
- mm_atomic.LoadUint64(&m.CommitTxMock.expectedInvocations), afterCommitTxCounter)
- }
- }
- type mPlaceRepositoryMockDelete struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockDeleteExpectation
- expectations []*PlaceRepositoryMockDeleteExpectation
- callArgs []*PlaceRepositoryMockDeleteParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockDeleteExpectation specifies expectation struct of the PlaceRepository.Delete
- type PlaceRepositoryMockDeleteExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockDeleteParams
- paramPtrs *PlaceRepositoryMockDeleteParamPtrs
- results *PlaceRepositoryMockDeleteResults
- Counter uint64
- }
- // PlaceRepositoryMockDeleteParams contains parameters of the PlaceRepository.Delete
- type PlaceRepositoryMockDeleteParams struct {
- ctx context.Context
- placeID int
- tx *sql.Tx
- }
- // PlaceRepositoryMockDeleteParamPtrs contains pointers to parameters of the PlaceRepository.Delete
- type PlaceRepositoryMockDeleteParamPtrs struct {
- ctx *context.Context
- placeID *int
- tx **sql.Tx
- }
- // PlaceRepositoryMockDeleteResults contains results of the PlaceRepository.Delete
- type PlaceRepositoryMockDeleteResults struct {
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmDelete *mPlaceRepositoryMockDelete) Optional() *mPlaceRepositoryMockDelete {
- mmDelete.optional = true
- return mmDelete
- }
- // Expect sets up expected params for PlaceRepository.Delete
- func (mmDelete *mPlaceRepositoryMockDelete) Expect(ctx context.Context, placeID int, tx *sql.Tx) *mPlaceRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.paramPtrs != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by ExpectParams functions")
- }
- mmDelete.defaultExpectation.params = &PlaceRepositoryMockDeleteParams{ctx, placeID, tx}
- 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
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceRepository.Delete
- func (mmDelete *mPlaceRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mPlaceRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &PlaceRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
- return mmDelete
- }
- // ExpectPlaceIDParam2 sets up expected param placeID for PlaceRepository.Delete
- func (mmDelete *mPlaceRepositoryMockDelete) ExpectPlaceIDParam2(placeID int) *mPlaceRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &PlaceRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.placeID = &placeID
- return mmDelete
- }
- // ExpectTxParam3 sets up expected param tx for PlaceRepository.Delete
- func (mmDelete *mPlaceRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mPlaceRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &PlaceRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.tx = &tx
- return mmDelete
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.Delete
- func (mmDelete *mPlaceRepositoryMockDelete) Inspect(f func(ctx context.Context, placeID int, tx *sql.Tx)) *mPlaceRepositoryMockDelete {
- if mmDelete.mock.inspectFuncDelete != nil {
- mmDelete.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.Delete")
- }
- mmDelete.mock.inspectFuncDelete = f
- return mmDelete
- }
- // Return sets up results that will be returned by PlaceRepository.Delete
- func (mmDelete *mPlaceRepositoryMockDelete) Return(err error) *PlaceRepositoryMock {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceRepositoryMockDeleteExpectation{mock: mmDelete.mock}
- }
- mmDelete.defaultExpectation.results = &PlaceRepositoryMockDeleteResults{err}
- return mmDelete.mock
- }
- // Set uses given function f to mock the PlaceRepository.Delete method
- func (mmDelete *mPlaceRepositoryMockDelete) Set(f func(ctx context.Context, placeID int, tx *sql.Tx) (err error)) *PlaceRepositoryMock {
- if mmDelete.defaultExpectation != nil {
- mmDelete.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.Delete method")
- }
- if len(mmDelete.expectations) > 0 {
- mmDelete.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.Delete method")
- }
- mmDelete.mock.funcDelete = f
- return mmDelete.mock
- }
- // When sets expectation for the PlaceRepository.Delete which will trigger the result defined by the following
- // Then helper
- func (mmDelete *mPlaceRepositoryMockDelete) When(ctx context.Context, placeID int, tx *sql.Tx) *PlaceRepositoryMockDeleteExpectation {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceRepositoryMock.Delete mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockDeleteExpectation{
- mock: mmDelete.mock,
- params: &PlaceRepositoryMockDeleteParams{ctx, placeID, tx},
- }
- mmDelete.expectations = append(mmDelete.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.Delete return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockDeleteExpectation) Then(err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockDeleteResults{err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.Delete should be invoked
- func (mmDelete *mPlaceRepositoryMockDelete) Times(n uint64) *mPlaceRepositoryMockDelete {
- if n == 0 {
- mmDelete.mock.t.Fatalf("Times of PlaceRepositoryMock.Delete mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
- return mmDelete
- }
- func (mmDelete *mPlaceRepositoryMockDelete) invocationsDone() bool {
- if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Delete implements place.PlaceRepository
- func (mmDelete *PlaceRepositoryMock) Delete(ctx context.Context, placeID int, tx *sql.Tx) (err error) {
- mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
- defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
- if mmDelete.inspectFuncDelete != nil {
- mmDelete.inspectFuncDelete(ctx, placeID, tx)
- }
- mm_params := PlaceRepositoryMockDeleteParams{ctx, placeID, tx}
- // 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_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockDeleteParams{ctx, placeID, tx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmDelete.t.Errorf("PlaceRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
- mmDelete.t.Errorf("PlaceRepositoryMock.Delete got unexpected parameter placeID, want: %#v, got: %#v%s\n", *mm_want_ptrs.placeID, mm_got.placeID, minimock.Diff(*mm_want_ptrs.placeID, mm_got.placeID))
- }
- if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
- mmDelete.t.Errorf("PlaceRepositoryMock.Delete got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmDelete.t.Errorf("PlaceRepositoryMock.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 PlaceRepositoryMock.Delete")
- }
- return (*mm_results).err
- }
- if mmDelete.funcDelete != nil {
- return mmDelete.funcDelete(ctx, placeID, tx)
- }
- mmDelete.t.Fatalf("Unexpected call to PlaceRepositoryMock.Delete. %v %v %v", ctx, placeID, tx)
- return
- }
- // DeleteAfterCounter returns a count of finished PlaceRepositoryMock.Delete invocations
- func (mmDelete *PlaceRepositoryMock) DeleteAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
- }
- // DeleteBeforeCounter returns a count of PlaceRepositoryMock.Delete invocations
- func (mmDelete *PlaceRepositoryMock) DeleteBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.Delete.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmDelete *mPlaceRepositoryMockDelete) Calls() []*PlaceRepositoryMockDeleteParams {
- mmDelete.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockDeleteParams, 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 *PlaceRepositoryMock) MinimockDeleteDone() bool {
- if m.DeleteMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.DeleteMock.invocationsDone()
- }
- // MinimockDeleteInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockDeleteInspect() {
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Delete with params: %#v", *e.params)
- }
- }
- afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
- if m.DeleteMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.Delete")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcDelete != nil && afterDeleteCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.Delete")
- }
- if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.Delete but found %d calls",
- mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
- }
- }
- type mPlaceRepositoryMockGet struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockGetExpectation
- expectations []*PlaceRepositoryMockGetExpectation
- callArgs []*PlaceRepositoryMockGetParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockGetExpectation specifies expectation struct of the PlaceRepository.Get
- type PlaceRepositoryMockGetExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockGetParams
- paramPtrs *PlaceRepositoryMockGetParamPtrs
- results *PlaceRepositoryMockGetResults
- Counter uint64
- }
- // PlaceRepositoryMockGetParams contains parameters of the PlaceRepository.Get
- type PlaceRepositoryMockGetParams struct {
- ctx context.Context
- placeID int
- }
- // PlaceRepositoryMockGetParamPtrs contains pointers to parameters of the PlaceRepository.Get
- type PlaceRepositoryMockGetParamPtrs struct {
- ctx *context.Context
- placeID *int
- }
- // PlaceRepositoryMockGetResults contains results of the PlaceRepository.Get
- type PlaceRepositoryMockGetResults struct {
- pp1 *models.Place
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmGet *mPlaceRepositoryMockGet) Optional() *mPlaceRepositoryMockGet {
- mmGet.optional = true
- return mmGet
- }
- // Expect sets up expected params for PlaceRepository.Get
- func (mmGet *mPlaceRepositoryMockGet) Expect(ctx context.Context, placeID int) *mPlaceRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.paramPtrs != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by ExpectParams functions")
- }
- mmGet.defaultExpectation.params = &PlaceRepositoryMockGetParams{ctx, placeID}
- for _, e := range mmGet.expectations {
- if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
- mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
- }
- }
- return mmGet
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceRepository.Get
- func (mmGet *mPlaceRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mPlaceRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &PlaceRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGet
- }
- // ExpectPlaceIDParam2 sets up expected param placeID for PlaceRepository.Get
- func (mmGet *mPlaceRepositoryMockGet) ExpectPlaceIDParam2(placeID int) *mPlaceRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &PlaceRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.placeID = &placeID
- return mmGet
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.Get
- func (mmGet *mPlaceRepositoryMockGet) Inspect(f func(ctx context.Context, placeID int)) *mPlaceRepositoryMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by PlaceRepository.Get
- func (mmGet *mPlaceRepositoryMockGet) Return(pp1 *models.Place, err error) *PlaceRepositoryMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceRepositoryMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &PlaceRepositoryMockGetResults{pp1, err}
- return mmGet.mock
- }
- // Set uses given function f to mock the PlaceRepository.Get method
- func (mmGet *mPlaceRepositoryMockGet) Set(f func(ctx context.Context, placeID int) (pp1 *models.Place, err error)) *PlaceRepositoryMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the PlaceRepository.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mPlaceRepositoryMockGet) When(ctx context.Context, placeID int) *PlaceRepositoryMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceRepositoryMock.Get mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockGetExpectation{
- mock: mmGet.mock,
- params: &PlaceRepositoryMockGetParams{ctx, placeID},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.Get return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockGetExpectation) Then(pp1 *models.Place, err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockGetResults{pp1, err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.Get should be invoked
- func (mmGet *mPlaceRepositoryMockGet) Times(n uint64) *mPlaceRepositoryMockGet {
- if n == 0 {
- mmGet.mock.t.Fatalf("Times of PlaceRepositoryMock.Get mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
- return mmGet
- }
- func (mmGet *mPlaceRepositoryMockGet) invocationsDone() bool {
- if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Get implements place.PlaceRepository
- func (mmGet *PlaceRepositoryMock) Get(ctx context.Context, placeID int) (pp1 *models.Place, err error) {
- mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
- defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
- if mmGet.inspectFuncGet != nil {
- mmGet.inspectFuncGet(ctx, placeID)
- }
- mm_params := PlaceRepositoryMockGetParams{ctx, placeID}
- // Record call args
- mmGet.GetMock.mutex.Lock()
- mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
- mmGet.GetMock.mutex.Unlock()
- for _, e := range mmGet.GetMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.pp1, e.results.err
- }
- }
- if mmGet.GetMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
- mm_want := mmGet.GetMock.defaultExpectation.params
- mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockGetParams{ctx, placeID}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGet.t.Errorf("PlaceRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
- mmGet.t.Errorf("PlaceRepositoryMock.Get got unexpected parameter placeID, want: %#v, got: %#v%s\n", *mm_want_ptrs.placeID, mm_got.placeID, minimock.Diff(*mm_want_ptrs.placeID, mm_got.placeID))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGet.t.Errorf("PlaceRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGet.GetMock.defaultExpectation.results
- if mm_results == nil {
- mmGet.t.Fatal("No results are set for the PlaceRepositoryMock.Get")
- }
- return (*mm_results).pp1, (*mm_results).err
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(ctx, placeID)
- }
- mmGet.t.Fatalf("Unexpected call to PlaceRepositoryMock.Get. %v %v", ctx, placeID)
- return
- }
- // GetAfterCounter returns a count of finished PlaceRepositoryMock.Get invocations
- func (mmGet *PlaceRepositoryMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of PlaceRepositoryMock.Get invocations
- func (mmGet *PlaceRepositoryMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mPlaceRepositoryMockGet) Calls() []*PlaceRepositoryMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockGetParams, len(mmGet.callArgs))
- copy(argCopy, mmGet.callArgs)
- mmGet.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetDone returns true if the count of the Get invocations corresponds
- // the number of defined expectations
- func (m *PlaceRepositoryMock) MinimockGetDone() bool {
- if m.GetMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetMock.invocationsDone()
- }
- // MinimockGetInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Get with params: %#v", *e.params)
- }
- }
- afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
- if m.GetMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.Get")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGet != nil && afterGetCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.Get")
- }
- if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.Get but found %d calls",
- mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
- }
- }
- type mPlaceRepositoryMockGetAll struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockGetAllExpectation
- expectations []*PlaceRepositoryMockGetAllExpectation
- callArgs []*PlaceRepositoryMockGetAllParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockGetAllExpectation specifies expectation struct of the PlaceRepository.GetAll
- type PlaceRepositoryMockGetAllExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockGetAllParams
- paramPtrs *PlaceRepositoryMockGetAllParamPtrs
- results *PlaceRepositoryMockGetAllResults
- Counter uint64
- }
- // PlaceRepositoryMockGetAllParams contains parameters of the PlaceRepository.GetAll
- type PlaceRepositoryMockGetAllParams struct {
- ctx context.Context
- }
- // PlaceRepositoryMockGetAllParamPtrs contains pointers to parameters of the PlaceRepository.GetAll
- type PlaceRepositoryMockGetAllParamPtrs struct {
- ctx *context.Context
- }
- // PlaceRepositoryMockGetAllResults contains results of the PlaceRepository.GetAll
- type PlaceRepositoryMockGetAllResults struct {
- pa1 []models.Place
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmGetAll *mPlaceRepositoryMockGetAll) Optional() *mPlaceRepositoryMockGetAll {
- mmGetAll.optional = true
- return mmGetAll
- }
- // Expect sets up expected params for PlaceRepository.GetAll
- func (mmGetAll *mPlaceRepositoryMockGetAll) Expect(ctx context.Context) *mPlaceRepositoryMockGetAll {
- if mmGetAll.mock.funcGetAll != nil {
- mmGetAll.mock.t.Fatalf("PlaceRepositoryMock.GetAll mock is already set by Set")
- }
- if mmGetAll.defaultExpectation == nil {
- mmGetAll.defaultExpectation = &PlaceRepositoryMockGetAllExpectation{}
- }
- if mmGetAll.defaultExpectation.paramPtrs != nil {
- mmGetAll.mock.t.Fatalf("PlaceRepositoryMock.GetAll mock is already set by ExpectParams functions")
- }
- mmGetAll.defaultExpectation.params = &PlaceRepositoryMockGetAllParams{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
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceRepository.GetAll
- func (mmGetAll *mPlaceRepositoryMockGetAll) ExpectCtxParam1(ctx context.Context) *mPlaceRepositoryMockGetAll {
- if mmGetAll.mock.funcGetAll != nil {
- mmGetAll.mock.t.Fatalf("PlaceRepositoryMock.GetAll mock is already set by Set")
- }
- if mmGetAll.defaultExpectation == nil {
- mmGetAll.defaultExpectation = &PlaceRepositoryMockGetAllExpectation{}
- }
- if mmGetAll.defaultExpectation.params != nil {
- mmGetAll.mock.t.Fatalf("PlaceRepositoryMock.GetAll mock is already set by Expect")
- }
- if mmGetAll.defaultExpectation.paramPtrs == nil {
- mmGetAll.defaultExpectation.paramPtrs = &PlaceRepositoryMockGetAllParamPtrs{}
- }
- mmGetAll.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetAll
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.GetAll
- func (mmGetAll *mPlaceRepositoryMockGetAll) Inspect(f func(ctx context.Context)) *mPlaceRepositoryMockGetAll {
- if mmGetAll.mock.inspectFuncGetAll != nil {
- mmGetAll.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.GetAll")
- }
- mmGetAll.mock.inspectFuncGetAll = f
- return mmGetAll
- }
- // Return sets up results that will be returned by PlaceRepository.GetAll
- func (mmGetAll *mPlaceRepositoryMockGetAll) Return(pa1 []models.Place, err error) *PlaceRepositoryMock {
- if mmGetAll.mock.funcGetAll != nil {
- mmGetAll.mock.t.Fatalf("PlaceRepositoryMock.GetAll mock is already set by Set")
- }
- if mmGetAll.defaultExpectation == nil {
- mmGetAll.defaultExpectation = &PlaceRepositoryMockGetAllExpectation{mock: mmGetAll.mock}
- }
- mmGetAll.defaultExpectation.results = &PlaceRepositoryMockGetAllResults{pa1, err}
- return mmGetAll.mock
- }
- // Set uses given function f to mock the PlaceRepository.GetAll method
- func (mmGetAll *mPlaceRepositoryMockGetAll) Set(f func(ctx context.Context) (pa1 []models.Place, err error)) *PlaceRepositoryMock {
- if mmGetAll.defaultExpectation != nil {
- mmGetAll.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.GetAll method")
- }
- if len(mmGetAll.expectations) > 0 {
- mmGetAll.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.GetAll method")
- }
- mmGetAll.mock.funcGetAll = f
- return mmGetAll.mock
- }
- // When sets expectation for the PlaceRepository.GetAll which will trigger the result defined by the following
- // Then helper
- func (mmGetAll *mPlaceRepositoryMockGetAll) When(ctx context.Context) *PlaceRepositoryMockGetAllExpectation {
- if mmGetAll.mock.funcGetAll != nil {
- mmGetAll.mock.t.Fatalf("PlaceRepositoryMock.GetAll mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockGetAllExpectation{
- mock: mmGetAll.mock,
- params: &PlaceRepositoryMockGetAllParams{ctx},
- }
- mmGetAll.expectations = append(mmGetAll.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.GetAll return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockGetAllExpectation) Then(pa1 []models.Place, err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockGetAllResults{pa1, err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.GetAll should be invoked
- func (mmGetAll *mPlaceRepositoryMockGetAll) Times(n uint64) *mPlaceRepositoryMockGetAll {
- if n == 0 {
- mmGetAll.mock.t.Fatalf("Times of PlaceRepositoryMock.GetAll mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetAll.expectedInvocations, n)
- return mmGetAll
- }
- func (mmGetAll *mPlaceRepositoryMockGetAll) invocationsDone() bool {
- if len(mmGetAll.expectations) == 0 && mmGetAll.defaultExpectation == nil && mmGetAll.mock.funcGetAll == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetAll.mock.afterGetAllCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetAll.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetAll implements place.PlaceRepository
- func (mmGetAll *PlaceRepositoryMock) GetAll(ctx context.Context) (pa1 []models.Place, err error) {
- mm_atomic.AddUint64(&mmGetAll.beforeGetAllCounter, 1)
- defer mm_atomic.AddUint64(&mmGetAll.afterGetAllCounter, 1)
- if mmGetAll.inspectFuncGetAll != nil {
- mmGetAll.inspectFuncGetAll(ctx)
- }
- mm_params := PlaceRepositoryMockGetAllParams{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.pa1, e.results.err
- }
- }
- if mmGetAll.GetAllMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetAll.GetAllMock.defaultExpectation.Counter, 1)
- mm_want := mmGetAll.GetAllMock.defaultExpectation.params
- mm_want_ptrs := mmGetAll.GetAllMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockGetAllParams{ctx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGetAll.t.Errorf("PlaceRepositoryMock.GetAll got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGetAll.t.Errorf("PlaceRepositoryMock.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 PlaceRepositoryMock.GetAll")
- }
- return (*mm_results).pa1, (*mm_results).err
- }
- if mmGetAll.funcGetAll != nil {
- return mmGetAll.funcGetAll(ctx)
- }
- mmGetAll.t.Fatalf("Unexpected call to PlaceRepositoryMock.GetAll. %v", ctx)
- return
- }
- // GetAllAfterCounter returns a count of finished PlaceRepositoryMock.GetAll invocations
- func (mmGetAll *PlaceRepositoryMock) GetAllAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter)
- }
- // GetAllBeforeCounter returns a count of PlaceRepositoryMock.GetAll invocations
- func (mmGetAll *PlaceRepositoryMock) GetAllBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.GetAll.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetAll *mPlaceRepositoryMockGetAll) Calls() []*PlaceRepositoryMockGetAllParams {
- mmGetAll.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockGetAllParams, 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 *PlaceRepositoryMock) MinimockGetAllDone() bool {
- if m.GetAllMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetAllMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetAllMock.invocationsDone()
- }
- // MinimockGetAllInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockGetAllInspect() {
- for _, e := range m.GetAllMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.GetAll with params: %#v", *e.params)
- }
- }
- afterGetAllCounter := mm_atomic.LoadUint64(&m.afterGetAllCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetAllMock.defaultExpectation != nil && afterGetAllCounter < 1 {
- if m.GetAllMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.GetAll")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.GetAll with params: %#v", *m.GetAllMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetAll != nil && afterGetAllCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.GetAll")
- }
- if !m.GetAllMock.invocationsDone() && afterGetAllCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.GetAll but found %d calls",
- mm_atomic.LoadUint64(&m.GetAllMock.expectedInvocations), afterGetAllCounter)
- }
- }
- type mPlaceRepositoryMockGetNestedPlaces struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockGetNestedPlacesExpectation
- expectations []*PlaceRepositoryMockGetNestedPlacesExpectation
- callArgs []*PlaceRepositoryMockGetNestedPlacesParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockGetNestedPlacesExpectation specifies expectation struct of the PlaceRepository.GetNestedPlaces
- type PlaceRepositoryMockGetNestedPlacesExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockGetNestedPlacesParams
- paramPtrs *PlaceRepositoryMockGetNestedPlacesParamPtrs
- results *PlaceRepositoryMockGetNestedPlacesResults
- Counter uint64
- }
- // PlaceRepositoryMockGetNestedPlacesParams contains parameters of the PlaceRepository.GetNestedPlaces
- type PlaceRepositoryMockGetNestedPlacesParams struct {
- ctx context.Context
- placeID int
- }
- // PlaceRepositoryMockGetNestedPlacesParamPtrs contains pointers to parameters of the PlaceRepository.GetNestedPlaces
- type PlaceRepositoryMockGetNestedPlacesParamPtrs struct {
- ctx *context.Context
- placeID *int
- }
- // PlaceRepositoryMockGetNestedPlacesResults contains results of the PlaceRepository.GetNestedPlaces
- type PlaceRepositoryMockGetNestedPlacesResults struct {
- pa1 []models.Place
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) Optional() *mPlaceRepositoryMockGetNestedPlaces {
- mmGetNestedPlaces.optional = true
- return mmGetNestedPlaces
- }
- // Expect sets up expected params for PlaceRepository.GetNestedPlaces
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) Expect(ctx context.Context, placeID int) *mPlaceRepositoryMockGetNestedPlaces {
- if mmGetNestedPlaces.mock.funcGetNestedPlaces != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by Set")
- }
- if mmGetNestedPlaces.defaultExpectation == nil {
- mmGetNestedPlaces.defaultExpectation = &PlaceRepositoryMockGetNestedPlacesExpectation{}
- }
- if mmGetNestedPlaces.defaultExpectation.paramPtrs != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by ExpectParams functions")
- }
- mmGetNestedPlaces.defaultExpectation.params = &PlaceRepositoryMockGetNestedPlacesParams{ctx, placeID}
- for _, e := range mmGetNestedPlaces.expectations {
- if minimock.Equal(e.params, mmGetNestedPlaces.defaultExpectation.params) {
- mmGetNestedPlaces.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetNestedPlaces.defaultExpectation.params)
- }
- }
- return mmGetNestedPlaces
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceRepository.GetNestedPlaces
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) ExpectCtxParam1(ctx context.Context) *mPlaceRepositoryMockGetNestedPlaces {
- if mmGetNestedPlaces.mock.funcGetNestedPlaces != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by Set")
- }
- if mmGetNestedPlaces.defaultExpectation == nil {
- mmGetNestedPlaces.defaultExpectation = &PlaceRepositoryMockGetNestedPlacesExpectation{}
- }
- if mmGetNestedPlaces.defaultExpectation.params != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by Expect")
- }
- if mmGetNestedPlaces.defaultExpectation.paramPtrs == nil {
- mmGetNestedPlaces.defaultExpectation.paramPtrs = &PlaceRepositoryMockGetNestedPlacesParamPtrs{}
- }
- mmGetNestedPlaces.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetNestedPlaces
- }
- // ExpectPlaceIDParam2 sets up expected param placeID for PlaceRepository.GetNestedPlaces
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) ExpectPlaceIDParam2(placeID int) *mPlaceRepositoryMockGetNestedPlaces {
- if mmGetNestedPlaces.mock.funcGetNestedPlaces != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by Set")
- }
- if mmGetNestedPlaces.defaultExpectation == nil {
- mmGetNestedPlaces.defaultExpectation = &PlaceRepositoryMockGetNestedPlacesExpectation{}
- }
- if mmGetNestedPlaces.defaultExpectation.params != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by Expect")
- }
- if mmGetNestedPlaces.defaultExpectation.paramPtrs == nil {
- mmGetNestedPlaces.defaultExpectation.paramPtrs = &PlaceRepositoryMockGetNestedPlacesParamPtrs{}
- }
- mmGetNestedPlaces.defaultExpectation.paramPtrs.placeID = &placeID
- return mmGetNestedPlaces
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.GetNestedPlaces
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) Inspect(f func(ctx context.Context, placeID int)) *mPlaceRepositoryMockGetNestedPlaces {
- if mmGetNestedPlaces.mock.inspectFuncGetNestedPlaces != nil {
- mmGetNestedPlaces.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.GetNestedPlaces")
- }
- mmGetNestedPlaces.mock.inspectFuncGetNestedPlaces = f
- return mmGetNestedPlaces
- }
- // Return sets up results that will be returned by PlaceRepository.GetNestedPlaces
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) Return(pa1 []models.Place, err error) *PlaceRepositoryMock {
- if mmGetNestedPlaces.mock.funcGetNestedPlaces != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by Set")
- }
- if mmGetNestedPlaces.defaultExpectation == nil {
- mmGetNestedPlaces.defaultExpectation = &PlaceRepositoryMockGetNestedPlacesExpectation{mock: mmGetNestedPlaces.mock}
- }
- mmGetNestedPlaces.defaultExpectation.results = &PlaceRepositoryMockGetNestedPlacesResults{pa1, err}
- return mmGetNestedPlaces.mock
- }
- // Set uses given function f to mock the PlaceRepository.GetNestedPlaces method
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) Set(f func(ctx context.Context, placeID int) (pa1 []models.Place, err error)) *PlaceRepositoryMock {
- if mmGetNestedPlaces.defaultExpectation != nil {
- mmGetNestedPlaces.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.GetNestedPlaces method")
- }
- if len(mmGetNestedPlaces.expectations) > 0 {
- mmGetNestedPlaces.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.GetNestedPlaces method")
- }
- mmGetNestedPlaces.mock.funcGetNestedPlaces = f
- return mmGetNestedPlaces.mock
- }
- // When sets expectation for the PlaceRepository.GetNestedPlaces which will trigger the result defined by the following
- // Then helper
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) When(ctx context.Context, placeID int) *PlaceRepositoryMockGetNestedPlacesExpectation {
- if mmGetNestedPlaces.mock.funcGetNestedPlaces != nil {
- mmGetNestedPlaces.mock.t.Fatalf("PlaceRepositoryMock.GetNestedPlaces mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockGetNestedPlacesExpectation{
- mock: mmGetNestedPlaces.mock,
- params: &PlaceRepositoryMockGetNestedPlacesParams{ctx, placeID},
- }
- mmGetNestedPlaces.expectations = append(mmGetNestedPlaces.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.GetNestedPlaces return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockGetNestedPlacesExpectation) Then(pa1 []models.Place, err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockGetNestedPlacesResults{pa1, err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.GetNestedPlaces should be invoked
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) Times(n uint64) *mPlaceRepositoryMockGetNestedPlaces {
- if n == 0 {
- mmGetNestedPlaces.mock.t.Fatalf("Times of PlaceRepositoryMock.GetNestedPlaces mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetNestedPlaces.expectedInvocations, n)
- return mmGetNestedPlaces
- }
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) invocationsDone() bool {
- if len(mmGetNestedPlaces.expectations) == 0 && mmGetNestedPlaces.defaultExpectation == nil && mmGetNestedPlaces.mock.funcGetNestedPlaces == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetNestedPlaces.mock.afterGetNestedPlacesCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetNestedPlaces.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetNestedPlaces implements place.PlaceRepository
- func (mmGetNestedPlaces *PlaceRepositoryMock) GetNestedPlaces(ctx context.Context, placeID int) (pa1 []models.Place, err error) {
- mm_atomic.AddUint64(&mmGetNestedPlaces.beforeGetNestedPlacesCounter, 1)
- defer mm_atomic.AddUint64(&mmGetNestedPlaces.afterGetNestedPlacesCounter, 1)
- if mmGetNestedPlaces.inspectFuncGetNestedPlaces != nil {
- mmGetNestedPlaces.inspectFuncGetNestedPlaces(ctx, placeID)
- }
- mm_params := PlaceRepositoryMockGetNestedPlacesParams{ctx, placeID}
- // Record call args
- mmGetNestedPlaces.GetNestedPlacesMock.mutex.Lock()
- mmGetNestedPlaces.GetNestedPlacesMock.callArgs = append(mmGetNestedPlaces.GetNestedPlacesMock.callArgs, &mm_params)
- mmGetNestedPlaces.GetNestedPlacesMock.mutex.Unlock()
- for _, e := range mmGetNestedPlaces.GetNestedPlacesMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.pa1, e.results.err
- }
- }
- if mmGetNestedPlaces.GetNestedPlacesMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetNestedPlaces.GetNestedPlacesMock.defaultExpectation.Counter, 1)
- mm_want := mmGetNestedPlaces.GetNestedPlacesMock.defaultExpectation.params
- mm_want_ptrs := mmGetNestedPlaces.GetNestedPlacesMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockGetNestedPlacesParams{ctx, placeID}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGetNestedPlaces.t.Errorf("PlaceRepositoryMock.GetNestedPlaces got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
- mmGetNestedPlaces.t.Errorf("PlaceRepositoryMock.GetNestedPlaces got unexpected parameter placeID, want: %#v, got: %#v%s\n", *mm_want_ptrs.placeID, mm_got.placeID, minimock.Diff(*mm_want_ptrs.placeID, mm_got.placeID))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGetNestedPlaces.t.Errorf("PlaceRepositoryMock.GetNestedPlaces got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetNestedPlaces.GetNestedPlacesMock.defaultExpectation.results
- if mm_results == nil {
- mmGetNestedPlaces.t.Fatal("No results are set for the PlaceRepositoryMock.GetNestedPlaces")
- }
- return (*mm_results).pa1, (*mm_results).err
- }
- if mmGetNestedPlaces.funcGetNestedPlaces != nil {
- return mmGetNestedPlaces.funcGetNestedPlaces(ctx, placeID)
- }
- mmGetNestedPlaces.t.Fatalf("Unexpected call to PlaceRepositoryMock.GetNestedPlaces. %v %v", ctx, placeID)
- return
- }
- // GetNestedPlacesAfterCounter returns a count of finished PlaceRepositoryMock.GetNestedPlaces invocations
- func (mmGetNestedPlaces *PlaceRepositoryMock) GetNestedPlacesAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetNestedPlaces.afterGetNestedPlacesCounter)
- }
- // GetNestedPlacesBeforeCounter returns a count of PlaceRepositoryMock.GetNestedPlaces invocations
- func (mmGetNestedPlaces *PlaceRepositoryMock) GetNestedPlacesBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetNestedPlaces.beforeGetNestedPlacesCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.GetNestedPlaces.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetNestedPlaces *mPlaceRepositoryMockGetNestedPlaces) Calls() []*PlaceRepositoryMockGetNestedPlacesParams {
- mmGetNestedPlaces.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockGetNestedPlacesParams, len(mmGetNestedPlaces.callArgs))
- copy(argCopy, mmGetNestedPlaces.callArgs)
- mmGetNestedPlaces.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetNestedPlacesDone returns true if the count of the GetNestedPlaces invocations corresponds
- // the number of defined expectations
- func (m *PlaceRepositoryMock) MinimockGetNestedPlacesDone() bool {
- if m.GetNestedPlacesMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetNestedPlacesMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetNestedPlacesMock.invocationsDone()
- }
- // MinimockGetNestedPlacesInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockGetNestedPlacesInspect() {
- for _, e := range m.GetNestedPlacesMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.GetNestedPlaces with params: %#v", *e.params)
- }
- }
- afterGetNestedPlacesCounter := mm_atomic.LoadUint64(&m.afterGetNestedPlacesCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetNestedPlacesMock.defaultExpectation != nil && afterGetNestedPlacesCounter < 1 {
- if m.GetNestedPlacesMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.GetNestedPlaces")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.GetNestedPlaces with params: %#v", *m.GetNestedPlacesMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetNestedPlaces != nil && afterGetNestedPlacesCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.GetNestedPlaces")
- }
- if !m.GetNestedPlacesMock.invocationsDone() && afterGetNestedPlacesCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.GetNestedPlaces but found %d calls",
- mm_atomic.LoadUint64(&m.GetNestedPlacesMock.expectedInvocations), afterGetNestedPlacesCounter)
- }
- }
- type mPlaceRepositoryMockUpdate struct {
- optional bool
- mock *PlaceRepositoryMock
- defaultExpectation *PlaceRepositoryMockUpdateExpectation
- expectations []*PlaceRepositoryMockUpdateExpectation
- callArgs []*PlaceRepositoryMockUpdateParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceRepositoryMockUpdateExpectation specifies expectation struct of the PlaceRepository.Update
- type PlaceRepositoryMockUpdateExpectation struct {
- mock *PlaceRepositoryMock
- params *PlaceRepositoryMockUpdateParams
- paramPtrs *PlaceRepositoryMockUpdateParamPtrs
- results *PlaceRepositoryMockUpdateResults
- Counter uint64
- }
- // PlaceRepositoryMockUpdateParams contains parameters of the PlaceRepository.Update
- type PlaceRepositoryMockUpdateParams struct {
- ctx context.Context
- req models.UpdatePlaceRequest
- tx *sql.Tx
- }
- // PlaceRepositoryMockUpdateParamPtrs contains pointers to parameters of the PlaceRepository.Update
- type PlaceRepositoryMockUpdateParamPtrs struct {
- ctx *context.Context
- req *models.UpdatePlaceRequest
- tx **sql.Tx
- }
- // PlaceRepositoryMockUpdateResults contains results of the PlaceRepository.Update
- type PlaceRepositoryMockUpdateResults struct {
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmUpdate *mPlaceRepositoryMockUpdate) Optional() *mPlaceRepositoryMockUpdate {
- mmUpdate.optional = true
- return mmUpdate
- }
- // Expect sets up expected params for PlaceRepository.Update
- func (mmUpdate *mPlaceRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) *mPlaceRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &PlaceRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.paramPtrs != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by ExpectParams functions")
- }
- mmUpdate.defaultExpectation.params = &PlaceRepositoryMockUpdateParams{ctx, req, tx}
- 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
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceRepository.Update
- func (mmUpdate *mPlaceRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mPlaceRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &PlaceRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &PlaceRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx
- return mmUpdate
- }
- // ExpectReqParam2 sets up expected param req for PlaceRepository.Update
- func (mmUpdate *mPlaceRepositoryMockUpdate) ExpectReqParam2(req models.UpdatePlaceRequest) *mPlaceRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &PlaceRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &PlaceRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.req = &req
- return mmUpdate
- }
- // ExpectTxParam3 sets up expected param tx for PlaceRepository.Update
- func (mmUpdate *mPlaceRepositoryMockUpdate) ExpectTxParam3(tx *sql.Tx) *mPlaceRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &PlaceRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &PlaceRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.tx = &tx
- return mmUpdate
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceRepository.Update
- func (mmUpdate *mPlaceRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx)) *mPlaceRepositoryMockUpdate {
- if mmUpdate.mock.inspectFuncUpdate != nil {
- mmUpdate.mock.t.Fatalf("Inspect function is already set for PlaceRepositoryMock.Update")
- }
- mmUpdate.mock.inspectFuncUpdate = f
- return mmUpdate
- }
- // Return sets up results that will be returned by PlaceRepository.Update
- func (mmUpdate *mPlaceRepositoryMockUpdate) Return(err error) *PlaceRepositoryMock {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &PlaceRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
- }
- mmUpdate.defaultExpectation.results = &PlaceRepositoryMockUpdateResults{err}
- return mmUpdate.mock
- }
- // Set uses given function f to mock the PlaceRepository.Update method
- func (mmUpdate *mPlaceRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) (err error)) *PlaceRepositoryMock {
- if mmUpdate.defaultExpectation != nil {
- mmUpdate.mock.t.Fatalf("Default expectation is already set for the PlaceRepository.Update method")
- }
- if len(mmUpdate.expectations) > 0 {
- mmUpdate.mock.t.Fatalf("Some expectations are already set for the PlaceRepository.Update method")
- }
- mmUpdate.mock.funcUpdate = f
- return mmUpdate.mock
- }
- // When sets expectation for the PlaceRepository.Update which will trigger the result defined by the following
- // Then helper
- func (mmUpdate *mPlaceRepositoryMockUpdate) When(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) *PlaceRepositoryMockUpdateExpectation {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("PlaceRepositoryMock.Update mock is already set by Set")
- }
- expectation := &PlaceRepositoryMockUpdateExpectation{
- mock: mmUpdate.mock,
- params: &PlaceRepositoryMockUpdateParams{ctx, req, tx},
- }
- mmUpdate.expectations = append(mmUpdate.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceRepository.Update return parameters for the expectation previously defined by the When method
- func (e *PlaceRepositoryMockUpdateExpectation) Then(err error) *PlaceRepositoryMock {
- e.results = &PlaceRepositoryMockUpdateResults{err}
- return e.mock
- }
- // Times sets number of times PlaceRepository.Update should be invoked
- func (mmUpdate *mPlaceRepositoryMockUpdate) Times(n uint64) *mPlaceRepositoryMockUpdate {
- if n == 0 {
- mmUpdate.mock.t.Fatalf("Times of PlaceRepositoryMock.Update mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
- return mmUpdate
- }
- func (mmUpdate *mPlaceRepositoryMockUpdate) invocationsDone() bool {
- if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Update implements place.PlaceRepository
- func (mmUpdate *PlaceRepositoryMock) Update(ctx context.Context, req models.UpdatePlaceRequest, tx *sql.Tx) (err error) {
- mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
- defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
- if mmUpdate.inspectFuncUpdate != nil {
- mmUpdate.inspectFuncUpdate(ctx, req, tx)
- }
- mm_params := PlaceRepositoryMockUpdateParams{ctx, req, tx}
- // 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_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs
- mm_got := PlaceRepositoryMockUpdateParams{ctx, req, tx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmUpdate.t.Errorf("PlaceRepositoryMock.Update got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
- mmUpdate.t.Errorf("PlaceRepositoryMock.Update got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
- }
- if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
- mmUpdate.t.Errorf("PlaceRepositoryMock.Update got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmUpdate.t.Errorf("PlaceRepositoryMock.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 PlaceRepositoryMock.Update")
- }
- return (*mm_results).err
- }
- if mmUpdate.funcUpdate != nil {
- return mmUpdate.funcUpdate(ctx, req, tx)
- }
- mmUpdate.t.Fatalf("Unexpected call to PlaceRepositoryMock.Update. %v %v %v", ctx, req, tx)
- return
- }
- // UpdateAfterCounter returns a count of finished PlaceRepositoryMock.Update invocations
- func (mmUpdate *PlaceRepositoryMock) UpdateAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
- }
- // UpdateBeforeCounter returns a count of PlaceRepositoryMock.Update invocations
- func (mmUpdate *PlaceRepositoryMock) UpdateBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceRepositoryMock.Update.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmUpdate *mPlaceRepositoryMockUpdate) Calls() []*PlaceRepositoryMockUpdateParams {
- mmUpdate.mutex.RLock()
- argCopy := make([]*PlaceRepositoryMockUpdateParams, 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 *PlaceRepositoryMock) MinimockUpdateDone() bool {
- if m.UpdateMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.UpdateMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.UpdateMock.invocationsDone()
- }
- // MinimockUpdateInspect logs each unmet expectation
- func (m *PlaceRepositoryMock) MinimockUpdateInspect() {
- for _, e := range m.UpdateMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Update with params: %#v", *e.params)
- }
- }
- afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
- if m.UpdateMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceRepositoryMock.Update")
- } else {
- m.t.Errorf("Expected call to PlaceRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcUpdate != nil && afterUpdateCounter < 1 {
- m.t.Error("Expected call to PlaceRepositoryMock.Update")
- }
- if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceRepositoryMock.Update but found %d calls",
- mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *PlaceRepositoryMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockAddInspect()
- m.MinimockBeginTxInspect()
- m.MinimockCommitTxInspect()
- m.MinimockDeleteInspect()
- m.MinimockGetInspect()
- m.MinimockGetAllInspect()
- m.MinimockGetNestedPlacesInspect()
- m.MinimockUpdateInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *PlaceRepositoryMock) 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 *PlaceRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockAddDone() &&
- m.MinimockBeginTxDone() &&
- m.MinimockCommitTxDone() &&
- m.MinimockDeleteDone() &&
- m.MinimockGetDone() &&
- m.MinimockGetAllDone() &&
- m.MinimockGetNestedPlacesDone() &&
- m.MinimockUpdateDone()
- }
|