12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113 |
- // 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/thing.ThingRepository -o thing_repository_minimock.go -n ThingRepositoryMock -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"
- )
- // ThingRepositoryMock implements thing.ThingRepository
- type ThingRepositoryMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)
- inspectFuncAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mThingRepositoryMockAdd
- 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 mThingRepositoryMockBeginTx
- funcCommitTx func(tx *sql.Tx) (err error)
- inspectFuncCommitTx func(tx *sql.Tx)
- afterCommitTxCounter uint64
- beforeCommitTxCounter uint64
- CommitTxMock mThingRepositoryMockCommitTx
- funcDelete func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
- inspectFuncDelete func(ctx context.Context, thingID int, tx *sql.Tx)
- afterDeleteCounter uint64
- beforeDeleteCounter uint64
- DeleteMock mThingRepositoryMockDelete
- funcGet func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)
- inspectFuncGet func(ctx context.Context, thingID int)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mThingRepositoryMockGet
- funcGetAllByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
- inspectFuncGetAllByPlaceID func(ctx context.Context, placeID int)
- afterGetAllByPlaceIDCounter uint64
- beforeGetAllByPlaceIDCounter uint64
- GetAllByPlaceIDMock mThingRepositoryMockGetAllByPlaceID
- funcGetByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
- inspectFuncGetByPlaceID func(ctx context.Context, placeID int)
- afterGetByPlaceIDCounter uint64
- beforeGetByPlaceIDCounter uint64
- GetByPlaceIDMock mThingRepositoryMockGetByPlaceID
- funcSearch func(ctx context.Context, search string) (ta1 []models.Thing, err error)
- inspectFuncSearch func(ctx context.Context, search string)
- afterSearchCounter uint64
- beforeSearchCounter uint64
- SearchMock mThingRepositoryMockSearch
- funcUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)
- inspectFuncUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)
- afterUpdateCounter uint64
- beforeUpdateCounter uint64
- UpdateMock mThingRepositoryMockUpdate
- }
- // NewThingRepositoryMock returns a mock for thing.ThingRepository
- func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock {
- m := &ThingRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mThingRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*ThingRepositoryMockAddParams{}
- m.BeginTxMock = mThingRepositoryMockBeginTx{mock: m}
- m.BeginTxMock.callArgs = []*ThingRepositoryMockBeginTxParams{}
- m.CommitTxMock = mThingRepositoryMockCommitTx{mock: m}
- m.CommitTxMock.callArgs = []*ThingRepositoryMockCommitTxParams{}
- m.DeleteMock = mThingRepositoryMockDelete{mock: m}
- m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{}
- m.GetMock = mThingRepositoryMockGet{mock: m}
- m.GetMock.callArgs = []*ThingRepositoryMockGetParams{}
- m.GetAllByPlaceIDMock = mThingRepositoryMockGetAllByPlaceID{mock: m}
- m.GetAllByPlaceIDMock.callArgs = []*ThingRepositoryMockGetAllByPlaceIDParams{}
- m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m}
- m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{}
- m.SearchMock = mThingRepositoryMockSearch{mock: m}
- m.SearchMock.callArgs = []*ThingRepositoryMockSearchParams{}
- m.UpdateMock = mThingRepositoryMockUpdate{mock: m}
- m.UpdateMock.callArgs = []*ThingRepositoryMockUpdateParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mThingRepositoryMockAdd struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockAddExpectation
- expectations []*ThingRepositoryMockAddExpectation
- callArgs []*ThingRepositoryMockAddParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockAddExpectation specifies expectation struct of the ThingRepository.Add
- type ThingRepositoryMockAddExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockAddParams
- paramPtrs *ThingRepositoryMockAddParamPtrs
- results *ThingRepositoryMockAddResults
- Counter uint64
- }
- // ThingRepositoryMockAddParams contains parameters of the ThingRepository.Add
- type ThingRepositoryMockAddParams struct {
- ctx context.Context
- req models.AddThingRequest
- tx *sql.Tx
- }
- // ThingRepositoryMockAddParamPtrs contains pointers to parameters of the ThingRepository.Add
- type ThingRepositoryMockAddParamPtrs struct {
- ctx *context.Context
- req *models.AddThingRequest
- tx **sql.Tx
- }
- // ThingRepositoryMockAddResults contains results of the ThingRepository.Add
- type ThingRepositoryMockAddResults 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 *mThingRepositoryMockAdd) Optional() *mThingRepositoryMockAdd {
- mmAdd.optional = true
- return mmAdd
- }
- // Expect sets up expected params for ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *mThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.paramPtrs != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by ExpectParams functions")
- }
- mmAdd.defaultExpectation.params = &ThingRepositoryMockAddParams{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 ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
- return mmAdd
- }
- // ExpectReqParam2 sets up expected param req for ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) ExpectReqParam2(req models.AddThingRequest) *mThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.req = &req
- return mmAdd
- }
- // ExpectTxParam3 sets up expected param tx for ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) ExpectTxParam3(tx *sql.Tx) *mThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.tx = &tx
- return mmAdd
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)) *mThingRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) Return(i1 int, err error) *ThingRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &ThingRepositoryMockAddResults{i1, err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the ThingRepository.Add method
- func (mmAdd *mThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)) *ThingRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the ThingRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mThingRepositoryMockAdd) When(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *ThingRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- expectation := &ThingRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &ThingRepositoryMockAddParams{ctx, req, tx},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Add return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockAddExpectation) Then(i1 int, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockAddResults{i1, err}
- return e.mock
- }
- // Times sets number of times ThingRepository.Add should be invoked
- func (mmAdd *mThingRepositoryMockAdd) Times(n uint64) *mThingRepositoryMockAdd {
- if n == 0 {
- mmAdd.mock.t.Fatalf("Times of ThingRepositoryMock.Add mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
- return mmAdd
- }
- func (mmAdd *mThingRepositoryMockAdd) 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 thing.ThingRepository
- func (mmAdd *ThingRepositoryMock) Add(ctx context.Context, req models.AddThingRequest, 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 := ThingRepositoryMockAddParams{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 := ThingRepositoryMockAddParams{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("ThingRepositoryMock.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("ThingRepositoryMock.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("ThingRepositoryMock.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("ThingRepositoryMock.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 ThingRepositoryMock.Add")
- }
- return (*mm_results).i1, (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, req, tx)
- }
- mmAdd.t.Fatalf("Unexpected call to ThingRepositoryMock.Add. %v %v %v", ctx, req, tx)
- return
- }
- // AddAfterCounter returns a count of finished ThingRepositoryMock.Add invocations
- func (mmAdd *ThingRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of ThingRepositoryMock.Add invocations
- func (mmAdd *ThingRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mThingRepositoryMockAdd) Calls() []*ThingRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockAddParams, 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 *ThingRepositoryMock) 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 *ThingRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Add")
- }
- if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.Add but found %d calls",
- mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
- }
- }
- type mThingRepositoryMockBeginTx struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockBeginTxExpectation
- expectations []*ThingRepositoryMockBeginTxExpectation
- callArgs []*ThingRepositoryMockBeginTxParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockBeginTxExpectation specifies expectation struct of the ThingRepository.BeginTx
- type ThingRepositoryMockBeginTxExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockBeginTxParams
- paramPtrs *ThingRepositoryMockBeginTxParamPtrs
- results *ThingRepositoryMockBeginTxResults
- Counter uint64
- }
- // ThingRepositoryMockBeginTxParams contains parameters of the ThingRepository.BeginTx
- type ThingRepositoryMockBeginTxParams struct {
- ctx context.Context
- level sql.IsolationLevel
- }
- // ThingRepositoryMockBeginTxParamPtrs contains pointers to parameters of the ThingRepository.BeginTx
- type ThingRepositoryMockBeginTxParamPtrs struct {
- ctx *context.Context
- level *sql.IsolationLevel
- }
- // ThingRepositoryMockBeginTxResults contains results of the ThingRepository.BeginTx
- type ThingRepositoryMockBeginTxResults 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 *mThingRepositoryMockBeginTx) Optional() *mThingRepositoryMockBeginTx {
- mmBeginTx.optional = true
- return mmBeginTx
- }
- // Expect sets up expected params for ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) Expect(ctx context.Context, level sql.IsolationLevel) *mThingRepositoryMockBeginTx {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
- }
- if mmBeginTx.defaultExpectation.paramPtrs != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by ExpectParams functions")
- }
- mmBeginTx.defaultExpectation.params = &ThingRepositoryMockBeginTxParams{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 ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockBeginTx {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
- }
- if mmBeginTx.defaultExpectation.params != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Expect")
- }
- if mmBeginTx.defaultExpectation.paramPtrs == nil {
- mmBeginTx.defaultExpectation.paramPtrs = &ThingRepositoryMockBeginTxParamPtrs{}
- }
- mmBeginTx.defaultExpectation.paramPtrs.ctx = &ctx
- return mmBeginTx
- }
- // ExpectLevelParam2 sets up expected param level for ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) ExpectLevelParam2(level sql.IsolationLevel) *mThingRepositoryMockBeginTx {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
- }
- if mmBeginTx.defaultExpectation.params != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Expect")
- }
- if mmBeginTx.defaultExpectation.paramPtrs == nil {
- mmBeginTx.defaultExpectation.paramPtrs = &ThingRepositoryMockBeginTxParamPtrs{}
- }
- mmBeginTx.defaultExpectation.paramPtrs.level = &level
- return mmBeginTx
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) Inspect(f func(ctx context.Context, level sql.IsolationLevel)) *mThingRepositoryMockBeginTx {
- if mmBeginTx.mock.inspectFuncBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.BeginTx")
- }
- mmBeginTx.mock.inspectFuncBeginTx = f
- return mmBeginTx
- }
- // Return sets up results that will be returned by ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) Return(tp1 *sql.Tx, err error) *ThingRepositoryMock {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{mock: mmBeginTx.mock}
- }
- mmBeginTx.defaultExpectation.results = &ThingRepositoryMockBeginTxResults{tp1, err}
- return mmBeginTx.mock
- }
- // Set uses given function f to mock the ThingRepository.BeginTx method
- func (mmBeginTx *mThingRepositoryMockBeginTx) Set(f func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)) *ThingRepositoryMock {
- if mmBeginTx.defaultExpectation != nil {
- mmBeginTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.BeginTx method")
- }
- if len(mmBeginTx.expectations) > 0 {
- mmBeginTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.BeginTx method")
- }
- mmBeginTx.mock.funcBeginTx = f
- return mmBeginTx.mock
- }
- // When sets expectation for the ThingRepository.BeginTx which will trigger the result defined by the following
- // Then helper
- func (mmBeginTx *mThingRepositoryMockBeginTx) When(ctx context.Context, level sql.IsolationLevel) *ThingRepositoryMockBeginTxExpectation {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- expectation := &ThingRepositoryMockBeginTxExpectation{
- mock: mmBeginTx.mock,
- params: &ThingRepositoryMockBeginTxParams{ctx, level},
- }
- mmBeginTx.expectations = append(mmBeginTx.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.BeginTx return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockBeginTxExpectation) Then(tp1 *sql.Tx, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockBeginTxResults{tp1, err}
- return e.mock
- }
- // Times sets number of times ThingRepository.BeginTx should be invoked
- func (mmBeginTx *mThingRepositoryMockBeginTx) Times(n uint64) *mThingRepositoryMockBeginTx {
- if n == 0 {
- mmBeginTx.mock.t.Fatalf("Times of ThingRepositoryMock.BeginTx mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmBeginTx.expectedInvocations, n)
- return mmBeginTx
- }
- func (mmBeginTx *mThingRepositoryMockBeginTx) 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 thing.ThingRepository
- func (mmBeginTx *ThingRepositoryMock) 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 := ThingRepositoryMockBeginTxParams{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 := ThingRepositoryMockBeginTxParams{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("ThingRepositoryMock.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("ThingRepositoryMock.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("ThingRepositoryMock.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 ThingRepositoryMock.BeginTx")
- }
- return (*mm_results).tp1, (*mm_results).err
- }
- if mmBeginTx.funcBeginTx != nil {
- return mmBeginTx.funcBeginTx(ctx, level)
- }
- mmBeginTx.t.Fatalf("Unexpected call to ThingRepositoryMock.BeginTx. %v %v", ctx, level)
- return
- }
- // BeginTxAfterCounter returns a count of finished ThingRepositoryMock.BeginTx invocations
- func (mmBeginTx *ThingRepositoryMock) BeginTxAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmBeginTx.afterBeginTxCounter)
- }
- // BeginTxBeforeCounter returns a count of ThingRepositoryMock.BeginTx invocations
- func (mmBeginTx *ThingRepositoryMock) BeginTxBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmBeginTx.beforeBeginTxCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.BeginTx.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmBeginTx *mThingRepositoryMockBeginTx) Calls() []*ThingRepositoryMockBeginTxParams {
- mmBeginTx.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockBeginTxParams, 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 *ThingRepositoryMock) 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 *ThingRepositoryMock) MinimockBeginTxInspect() {
- for _, e := range m.BeginTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.BeginTx")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.BeginTx")
- }
- if !m.BeginTxMock.invocationsDone() && afterBeginTxCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.BeginTx but found %d calls",
- mm_atomic.LoadUint64(&m.BeginTxMock.expectedInvocations), afterBeginTxCounter)
- }
- }
- type mThingRepositoryMockCommitTx struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockCommitTxExpectation
- expectations []*ThingRepositoryMockCommitTxExpectation
- callArgs []*ThingRepositoryMockCommitTxParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockCommitTxExpectation specifies expectation struct of the ThingRepository.CommitTx
- type ThingRepositoryMockCommitTxExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockCommitTxParams
- paramPtrs *ThingRepositoryMockCommitTxParamPtrs
- results *ThingRepositoryMockCommitTxResults
- Counter uint64
- }
- // ThingRepositoryMockCommitTxParams contains parameters of the ThingRepository.CommitTx
- type ThingRepositoryMockCommitTxParams struct {
- tx *sql.Tx
- }
- // ThingRepositoryMockCommitTxParamPtrs contains pointers to parameters of the ThingRepository.CommitTx
- type ThingRepositoryMockCommitTxParamPtrs struct {
- tx **sql.Tx
- }
- // ThingRepositoryMockCommitTxResults contains results of the ThingRepository.CommitTx
- type ThingRepositoryMockCommitTxResults 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 *mThingRepositoryMockCommitTx) Optional() *mThingRepositoryMockCommitTx {
- mmCommitTx.optional = true
- return mmCommitTx
- }
- // Expect sets up expected params for ThingRepository.CommitTx
- func (mmCommitTx *mThingRepositoryMockCommitTx) Expect(tx *sql.Tx) *mThingRepositoryMockCommitTx {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{}
- }
- if mmCommitTx.defaultExpectation.paramPtrs != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by ExpectParams functions")
- }
- mmCommitTx.defaultExpectation.params = &ThingRepositoryMockCommitTxParams{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 ThingRepository.CommitTx
- func (mmCommitTx *mThingRepositoryMockCommitTx) ExpectTxParam1(tx *sql.Tx) *mThingRepositoryMockCommitTx {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{}
- }
- if mmCommitTx.defaultExpectation.params != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Expect")
- }
- if mmCommitTx.defaultExpectation.paramPtrs == nil {
- mmCommitTx.defaultExpectation.paramPtrs = &ThingRepositoryMockCommitTxParamPtrs{}
- }
- mmCommitTx.defaultExpectation.paramPtrs.tx = &tx
- return mmCommitTx
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.CommitTx
- func (mmCommitTx *mThingRepositoryMockCommitTx) Inspect(f func(tx *sql.Tx)) *mThingRepositoryMockCommitTx {
- if mmCommitTx.mock.inspectFuncCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.CommitTx")
- }
- mmCommitTx.mock.inspectFuncCommitTx = f
- return mmCommitTx
- }
- // Return sets up results that will be returned by ThingRepository.CommitTx
- func (mmCommitTx *mThingRepositoryMockCommitTx) Return(err error) *ThingRepositoryMock {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{mock: mmCommitTx.mock}
- }
- mmCommitTx.defaultExpectation.results = &ThingRepositoryMockCommitTxResults{err}
- return mmCommitTx.mock
- }
- // Set uses given function f to mock the ThingRepository.CommitTx method
- func (mmCommitTx *mThingRepositoryMockCommitTx) Set(f func(tx *sql.Tx) (err error)) *ThingRepositoryMock {
- if mmCommitTx.defaultExpectation != nil {
- mmCommitTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.CommitTx method")
- }
- if len(mmCommitTx.expectations) > 0 {
- mmCommitTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.CommitTx method")
- }
- mmCommitTx.mock.funcCommitTx = f
- return mmCommitTx.mock
- }
- // When sets expectation for the ThingRepository.CommitTx which will trigger the result defined by the following
- // Then helper
- func (mmCommitTx *mThingRepositoryMockCommitTx) When(tx *sql.Tx) *ThingRepositoryMockCommitTxExpectation {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
- }
- expectation := &ThingRepositoryMockCommitTxExpectation{
- mock: mmCommitTx.mock,
- params: &ThingRepositoryMockCommitTxParams{tx},
- }
- mmCommitTx.expectations = append(mmCommitTx.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.CommitTx return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockCommitTxExpectation) Then(err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockCommitTxResults{err}
- return e.mock
- }
- // Times sets number of times ThingRepository.CommitTx should be invoked
- func (mmCommitTx *mThingRepositoryMockCommitTx) Times(n uint64) *mThingRepositoryMockCommitTx {
- if n == 0 {
- mmCommitTx.mock.t.Fatalf("Times of ThingRepositoryMock.CommitTx mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmCommitTx.expectedInvocations, n)
- return mmCommitTx
- }
- func (mmCommitTx *mThingRepositoryMockCommitTx) 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 thing.ThingRepository
- func (mmCommitTx *ThingRepositoryMock) 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 := ThingRepositoryMockCommitTxParams{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 := ThingRepositoryMockCommitTxParams{tx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
- mmCommitTx.t.Errorf("ThingRepositoryMock.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("ThingRepositoryMock.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 ThingRepositoryMock.CommitTx")
- }
- return (*mm_results).err
- }
- if mmCommitTx.funcCommitTx != nil {
- return mmCommitTx.funcCommitTx(tx)
- }
- mmCommitTx.t.Fatalf("Unexpected call to ThingRepositoryMock.CommitTx. %v", tx)
- return
- }
- // CommitTxAfterCounter returns a count of finished ThingRepositoryMock.CommitTx invocations
- func (mmCommitTx *ThingRepositoryMock) CommitTxAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmCommitTx.afterCommitTxCounter)
- }
- // CommitTxBeforeCounter returns a count of ThingRepositoryMock.CommitTx invocations
- func (mmCommitTx *ThingRepositoryMock) CommitTxBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmCommitTx.beforeCommitTxCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.CommitTx.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmCommitTx *mThingRepositoryMockCommitTx) Calls() []*ThingRepositoryMockCommitTxParams {
- mmCommitTx.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockCommitTxParams, 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 *ThingRepositoryMock) 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 *ThingRepositoryMock) MinimockCommitTxInspect() {
- for _, e := range m.CommitTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.CommitTx")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.CommitTx")
- }
- if !m.CommitTxMock.invocationsDone() && afterCommitTxCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.CommitTx but found %d calls",
- mm_atomic.LoadUint64(&m.CommitTxMock.expectedInvocations), afterCommitTxCounter)
- }
- }
- type mThingRepositoryMockDelete struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockDeleteExpectation
- expectations []*ThingRepositoryMockDeleteExpectation
- callArgs []*ThingRepositoryMockDeleteParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete
- type ThingRepositoryMockDeleteExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockDeleteParams
- paramPtrs *ThingRepositoryMockDeleteParamPtrs
- results *ThingRepositoryMockDeleteResults
- Counter uint64
- }
- // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
- type ThingRepositoryMockDeleteParams struct {
- ctx context.Context
- thingID int
- tx *sql.Tx
- }
- // ThingRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingRepository.Delete
- type ThingRepositoryMockDeleteParamPtrs struct {
- ctx *context.Context
- thingID *int
- tx **sql.Tx
- }
- // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
- type ThingRepositoryMockDeleteResults 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 *mThingRepositoryMockDelete) Optional() *mThingRepositoryMockDelete {
- mmDelete.optional = true
- return mmDelete
- }
- // Expect sets up expected params for ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.paramPtrs != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by ExpectParams functions")
- }
- mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, thingID, 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 ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
- return mmDelete
- }
- // ExpectThingIDParam2 sets up expected param thingID for ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) ExpectThingIDParam2(thingID int) *mThingRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.thingID = &thingID
- return mmDelete
- }
- // ExpectTxParam3 sets up expected param tx for ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.tx = &tx
- return mmDelete
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingRepositoryMockDelete {
- if mmDelete.mock.inspectFuncDelete != nil {
- mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
- }
- mmDelete.mock.inspectFuncDelete = f
- return mmDelete
- }
- // Return sets up results that will be returned by ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock}
- }
- mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err}
- return mmDelete.mock
- }
- // Set uses given function f to mock the ThingRepository.Delete method
- func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingRepositoryMock {
- if mmDelete.defaultExpectation != nil {
- mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
- }
- if len(mmDelete.expectations) > 0 {
- mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method")
- }
- mmDelete.mock.funcDelete = f
- return mmDelete.mock
- }
- // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
- // Then helper
- func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingRepositoryMockDeleteExpectation {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- expectation := &ThingRepositoryMockDeleteExpectation{
- mock: mmDelete.mock,
- params: &ThingRepositoryMockDeleteParams{ctx, thingID, tx},
- }
- mmDelete.expectations = append(mmDelete.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockDeleteResults{err}
- return e.mock
- }
- // Times sets number of times ThingRepository.Delete should be invoked
- func (mmDelete *mThingRepositoryMockDelete) Times(n uint64) *mThingRepositoryMockDelete {
- if n == 0 {
- mmDelete.mock.t.Fatalf("Times of ThingRepositoryMock.Delete mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
- return mmDelete
- }
- func (mmDelete *mThingRepositoryMockDelete) 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 thing.ThingRepository
- func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID 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, thingID, tx)
- }
- mm_params := ThingRepositoryMockDeleteParams{ctx, thingID, 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 := ThingRepositoryMockDeleteParams{ctx, thingID, tx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmDelete.t.Errorf("ThingRepositoryMock.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.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
- mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
- }
- if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
- mmDelete.t.Errorf("ThingRepositoryMock.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("ThingRepositoryMock.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 ThingRepositoryMock.Delete")
- }
- return (*mm_results).err
- }
- if mmDelete.funcDelete != nil {
- return mmDelete.funcDelete(ctx, thingID, tx)
- }
- mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
- return
- }
- // DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations
- func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
- }
- // DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations
- func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams {
- mmDelete.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockDeleteParams, 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 *ThingRepositoryMock) 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 *ThingRepositoryMock) MinimockDeleteInspect() {
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Delete")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Delete")
- }
- if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.Delete but found %d calls",
- mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
- }
- }
- type mThingRepositoryMockGet struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockGetExpectation
- expectations []*ThingRepositoryMockGetExpectation
- callArgs []*ThingRepositoryMockGetParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockGetExpectation specifies expectation struct of the ThingRepository.Get
- type ThingRepositoryMockGetExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockGetParams
- paramPtrs *ThingRepositoryMockGetParamPtrs
- results *ThingRepositoryMockGetResults
- Counter uint64
- }
- // ThingRepositoryMockGetParams contains parameters of the ThingRepository.Get
- type ThingRepositoryMockGetParams struct {
- ctx context.Context
- thingID int
- }
- // ThingRepositoryMockGetParamPtrs contains pointers to parameters of the ThingRepository.Get
- type ThingRepositoryMockGetParamPtrs struct {
- ctx *context.Context
- thingID *int
- }
- // ThingRepositoryMockGetResults contains results of the ThingRepository.Get
- type ThingRepositoryMockGetResults struct {
- tp1 *models.Thing
- 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 *mThingRepositoryMockGet) Optional() *mThingRepositoryMockGet {
- mmGet.optional = true
- return mmGet
- }
- // Expect sets up expected params for ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, thingID int) *mThingRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.paramPtrs != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by ExpectParams functions")
- }
- mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, thingID}
- 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 ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGet
- }
- // ExpectThingIDParam2 sets up expected param thingID for ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) ExpectThingIDParam2(thingID int) *mThingRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.thingID = &thingID
- return mmGet
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, thingID int)) *mThingRepositoryMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) Return(tp1 *models.Thing, err error) *ThingRepositoryMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &ThingRepositoryMockGetResults{tp1, err}
- return mmGet.mock
- }
- // Set uses given function f to mock the ThingRepository.Get method
- func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the ThingRepository.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, thingID int) *ThingRepositoryMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- expectation := &ThingRepositoryMockGetExpectation{
- mock: mmGet.mock,
- params: &ThingRepositoryMockGetParams{ctx, thingID},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Get return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockGetExpectation) Then(tp1 *models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockGetResults{tp1, err}
- return e.mock
- }
- // Times sets number of times ThingRepository.Get should be invoked
- func (mmGet *mThingRepositoryMockGet) Times(n uint64) *mThingRepositoryMockGet {
- if n == 0 {
- mmGet.mock.t.Fatalf("Times of ThingRepositoryMock.Get mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
- return mmGet
- }
- func (mmGet *mThingRepositoryMockGet) 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 thing.ThingRepository
- func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *models.Thing, err error) {
- mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
- defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
- if mmGet.inspectFuncGet != nil {
- mmGet.inspectFuncGet(ctx, thingID)
- }
- mm_params := ThingRepositoryMockGetParams{ctx, thingID}
- // 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.tp1, 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 := ThingRepositoryMockGetParams{ctx, thingID}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGet.t.Errorf("ThingRepositoryMock.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.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
- mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGet.t.Errorf("ThingRepositoryMock.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 ThingRepositoryMock.Get")
- }
- return (*mm_results).tp1, (*mm_results).err
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(ctx, thingID)
- }
- mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, thingID)
- return
- }
- // GetAfterCounter returns a count of finished ThingRepositoryMock.Get invocations
- func (mmGet *ThingRepositoryMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of ThingRepositoryMock.Get invocations
- func (mmGet *ThingRepositoryMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mThingRepositoryMockGet) Calls() []*ThingRepositoryMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockGetParams, 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 *ThingRepositoryMock) 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 *ThingRepositoryMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Get")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Get")
- }
- if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.Get but found %d calls",
- mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
- }
- }
- type mThingRepositoryMockGetAllByPlaceID struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockGetAllByPlaceIDExpectation
- expectations []*ThingRepositoryMockGetAllByPlaceIDExpectation
- callArgs []*ThingRepositoryMockGetAllByPlaceIDParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockGetAllByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetAllByPlaceID
- type ThingRepositoryMockGetAllByPlaceIDExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockGetAllByPlaceIDParams
- paramPtrs *ThingRepositoryMockGetAllByPlaceIDParamPtrs
- results *ThingRepositoryMockGetAllByPlaceIDResults
- Counter uint64
- }
- // ThingRepositoryMockGetAllByPlaceIDParams contains parameters of the ThingRepository.GetAllByPlaceID
- type ThingRepositoryMockGetAllByPlaceIDParams struct {
- ctx context.Context
- placeID int
- }
- // ThingRepositoryMockGetAllByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetAllByPlaceID
- type ThingRepositoryMockGetAllByPlaceIDParamPtrs struct {
- ctx *context.Context
- placeID *int
- }
- // ThingRepositoryMockGetAllByPlaceIDResults contains results of the ThingRepository.GetAllByPlaceID
- type ThingRepositoryMockGetAllByPlaceIDResults struct {
- ta1 []models.Thing
- 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 (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Optional() *mThingRepositoryMockGetAllByPlaceID {
- mmGetAllByPlaceID.optional = true
- return mmGetAllByPlaceID
- }
- // Expect sets up expected params for ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetAllByPlaceID {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- if mmGetAllByPlaceID.defaultExpectation == nil {
- mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
- }
- if mmGetAllByPlaceID.defaultExpectation.paramPtrs != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by ExpectParams functions")
- }
- mmGetAllByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
- for _, e := range mmGetAllByPlaceID.expectations {
- if minimock.Equal(e.params, mmGetAllByPlaceID.defaultExpectation.params) {
- mmGetAllByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllByPlaceID.defaultExpectation.params)
- }
- }
- return mmGetAllByPlaceID
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetAllByPlaceID {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- if mmGetAllByPlaceID.defaultExpectation == nil {
- mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
- }
- if mmGetAllByPlaceID.defaultExpectation.params != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
- }
- if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
- }
- mmGetAllByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetAllByPlaceID
- }
- // ExpectPlaceIDParam2 sets up expected param placeID for ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectPlaceIDParam2(placeID int) *mThingRepositoryMockGetAllByPlaceID {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- if mmGetAllByPlaceID.defaultExpectation == nil {
- mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
- }
- if mmGetAllByPlaceID.defaultExpectation.params != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
- }
- if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
- }
- mmGetAllByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID
- return mmGetAllByPlaceID
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetAllByPlaceID {
- if mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetAllByPlaceID")
- }
- mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID = f
- return mmGetAllByPlaceID
- }
- // Return sets up results that will be returned by ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- if mmGetAllByPlaceID.defaultExpectation == nil {
- mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{mock: mmGetAllByPlaceID.mock}
- }
- mmGetAllByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
- return mmGetAllByPlaceID.mock
- }
- // Set uses given function f to mock the ThingRepository.GetAllByPlaceID method
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
- if mmGetAllByPlaceID.defaultExpectation != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetAllByPlaceID method")
- }
- if len(mmGetAllByPlaceID.expectations) > 0 {
- mmGetAllByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetAllByPlaceID method")
- }
- mmGetAllByPlaceID.mock.funcGetAllByPlaceID = f
- return mmGetAllByPlaceID.mock
- }
- // When sets expectation for the ThingRepository.GetAllByPlaceID which will trigger the result defined by the following
- // Then helper
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetAllByPlaceIDExpectation {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- expectation := &ThingRepositoryMockGetAllByPlaceIDExpectation{
- mock: mmGetAllByPlaceID.mock,
- params: &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID},
- }
- mmGetAllByPlaceID.expectations = append(mmGetAllByPlaceID.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.GetAllByPlaceID return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockGetAllByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
- return e.mock
- }
- // Times sets number of times ThingRepository.GetAllByPlaceID should be invoked
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Times(n uint64) *mThingRepositoryMockGetAllByPlaceID {
- if n == 0 {
- mmGetAllByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetAllByPlaceID mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetAllByPlaceID.expectedInvocations, n)
- return mmGetAllByPlaceID
- }
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) invocationsDone() bool {
- if len(mmGetAllByPlaceID.expectations) == 0 && mmGetAllByPlaceID.defaultExpectation == nil && mmGetAllByPlaceID.mock.funcGetAllByPlaceID == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.mock.afterGetAllByPlaceIDCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetAllByPlaceID implements thing.ThingRepository
- func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
- mm_atomic.AddUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter, 1)
- defer mm_atomic.AddUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter, 1)
- if mmGetAllByPlaceID.inspectFuncGetAllByPlaceID != nil {
- mmGetAllByPlaceID.inspectFuncGetAllByPlaceID(ctx, placeID)
- }
- mm_params := ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
- // Record call args
- mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Lock()
- mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs = append(mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs, &mm_params)
- mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Unlock()
- for _, e := range mmGetAllByPlaceID.GetAllByPlaceIDMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ta1, e.results.err
- }
- }
- if mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.Counter, 1)
- mm_want := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.params
- mm_want_ptrs := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.paramPtrs
- mm_got := ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID 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) {
- mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID 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) {
- mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.results
- if mm_results == nil {
- mmGetAllByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetAllByPlaceID")
- }
- return (*mm_results).ta1, (*mm_results).err
- }
- if mmGetAllByPlaceID.funcGetAllByPlaceID != nil {
- return mmGetAllByPlaceID.funcGetAllByPlaceID(ctx, placeID)
- }
- mmGetAllByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetAllByPlaceID. %v %v", ctx, placeID)
- return
- }
- // GetAllByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetAllByPlaceID invocations
- func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter)
- }
- // GetAllByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetAllByPlaceID invocations
- func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetAllByPlaceID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Calls() []*ThingRepositoryMockGetAllByPlaceIDParams {
- mmGetAllByPlaceID.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockGetAllByPlaceIDParams, len(mmGetAllByPlaceID.callArgs))
- copy(argCopy, mmGetAllByPlaceID.callArgs)
- mmGetAllByPlaceID.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetAllByPlaceIDDone returns true if the count of the GetAllByPlaceID invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDDone() bool {
- if m.GetAllByPlaceIDMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetAllByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetAllByPlaceIDMock.invocationsDone()
- }
- // MinimockGetAllByPlaceIDInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDInspect() {
- for _, e := range m.GetAllByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *e.params)
- }
- }
- afterGetAllByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetAllByPlaceIDMock.defaultExpectation != nil && afterGetAllByPlaceIDCounter < 1 {
- if m.GetAllByPlaceIDMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *m.GetAllByPlaceIDMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetAllByPlaceID != nil && afterGetAllByPlaceIDCounter < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
- }
- if !m.GetAllByPlaceIDMock.invocationsDone() && afterGetAllByPlaceIDCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetAllByPlaceID but found %d calls",
- mm_atomic.LoadUint64(&m.GetAllByPlaceIDMock.expectedInvocations), afterGetAllByPlaceIDCounter)
- }
- }
- type mThingRepositoryMockGetByPlaceID struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation
- expectations []*ThingRepositoryMockGetByPlaceIDExpectation
- callArgs []*ThingRepositoryMockGetByPlaceIDParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID
- type ThingRepositoryMockGetByPlaceIDExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockGetByPlaceIDParams
- paramPtrs *ThingRepositoryMockGetByPlaceIDParamPtrs
- results *ThingRepositoryMockGetByPlaceIDResults
- Counter uint64
- }
- // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
- type ThingRepositoryMockGetByPlaceIDParams struct {
- ctx context.Context
- placeID int
- }
- // ThingRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetByPlaceID
- type ThingRepositoryMockGetByPlaceIDParamPtrs struct {
- ctx *context.Context
- placeID *int
- }
- // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
- type ThingRepositoryMockGetByPlaceIDResults struct {
- ta1 []models.Thing
- 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 (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Optional() *mThingRepositoryMockGetByPlaceID {
- mmGetByPlaceID.optional = true
- return mmGetByPlaceID
- }
- // Expect sets up expected params for ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
- }
- mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
- for _, e := range mmGetByPlaceID.expectations {
- if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
- mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
- }
- }
- return mmGetByPlaceID
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.params != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
- }
- mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetByPlaceID
- }
- // ExpectPlaceIDParam2 sets up expected param placeID for ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(placeID int) *mThingRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.params != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
- }
- mmGetByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID
- return mmGetByPlaceID
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
- }
- mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
- return mmGetByPlaceID
- }
- // Return sets up results that will be returned by ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
- }
- mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
- return mmGetByPlaceID.mock
- }
- // Set uses given function f to mock the ThingRepository.GetByPlaceID method
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
- if mmGetByPlaceID.defaultExpectation != nil {
- mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
- }
- if len(mmGetByPlaceID.expectations) > 0 {
- mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method")
- }
- mmGetByPlaceID.mock.funcGetByPlaceID = f
- return mmGetByPlaceID.mock
- }
- // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
- // Then helper
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetByPlaceIDExpectation {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
- mock: mmGetByPlaceID.mock,
- params: &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID},
- }
- mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
- return e.mock
- }
- // Times sets number of times ThingRepository.GetByPlaceID should be invoked
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Times(n uint64) *mThingRepositoryMockGetByPlaceID {
- if n == 0 {
- mmGetByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetByPlaceID mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
- return mmGetByPlaceID
- }
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) invocationsDone() bool {
- if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetByPlaceID implements thing.ThingRepository
- func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
- mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
- defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
- if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
- mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID)
- }
- mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
- // Record call args
- mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
- mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
- mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
- for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ta1, e.results.err
- }
- }
- if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
- mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
- mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
- mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID 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) {
- mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID 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) {
- mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
- if mm_results == nil {
- mmGetByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetByPlaceID")
- }
- return (*mm_results).ta1, (*mm_results).err
- }
- if mmGetByPlaceID.funcGetByPlaceID != nil {
- return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID)
- }
- mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, placeID)
- return
- }
- // GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
- }
- // GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams {
- mmGetByPlaceID.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
- copy(argCopy, mmGetByPlaceID.callArgs)
- mmGetByPlaceID.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool {
- if m.GetByPlaceIDMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetByPlaceIDMock.invocationsDone()
- }
- // MinimockGetByPlaceIDInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() {
- for _, e := range m.GetByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params)
- }
- }
- afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
- if m.GetByPlaceIDMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
- }
- if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetByPlaceID but found %d calls",
- mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
- }
- }
- type mThingRepositoryMockSearch struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockSearchExpectation
- expectations []*ThingRepositoryMockSearchExpectation
- callArgs []*ThingRepositoryMockSearchParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockSearchExpectation specifies expectation struct of the ThingRepository.Search
- type ThingRepositoryMockSearchExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockSearchParams
- paramPtrs *ThingRepositoryMockSearchParamPtrs
- results *ThingRepositoryMockSearchResults
- Counter uint64
- }
- // ThingRepositoryMockSearchParams contains parameters of the ThingRepository.Search
- type ThingRepositoryMockSearchParams struct {
- ctx context.Context
- search string
- }
- // ThingRepositoryMockSearchParamPtrs contains pointers to parameters of the ThingRepository.Search
- type ThingRepositoryMockSearchParamPtrs struct {
- ctx *context.Context
- search *string
- }
- // ThingRepositoryMockSearchResults contains results of the ThingRepository.Search
- type ThingRepositoryMockSearchResults struct {
- ta1 []models.Thing
- 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 (mmSearch *mThingRepositoryMockSearch) Optional() *mThingRepositoryMockSearch {
- mmSearch.optional = true
- return mmSearch
- }
- // Expect sets up expected params for ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) Expect(ctx context.Context, search string) *mThingRepositoryMockSearch {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- if mmSearch.defaultExpectation == nil {
- mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
- }
- if mmSearch.defaultExpectation.paramPtrs != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by ExpectParams functions")
- }
- mmSearch.defaultExpectation.params = &ThingRepositoryMockSearchParams{ctx, search}
- for _, e := range mmSearch.expectations {
- if minimock.Equal(e.params, mmSearch.defaultExpectation.params) {
- mmSearch.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSearch.defaultExpectation.params)
- }
- }
- return mmSearch
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockSearch {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- if mmSearch.defaultExpectation == nil {
- mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
- }
- if mmSearch.defaultExpectation.params != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
- }
- if mmSearch.defaultExpectation.paramPtrs == nil {
- mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
- }
- mmSearch.defaultExpectation.paramPtrs.ctx = &ctx
- return mmSearch
- }
- // ExpectSearchParam2 sets up expected param search for ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) ExpectSearchParam2(search string) *mThingRepositoryMockSearch {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- if mmSearch.defaultExpectation == nil {
- mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
- }
- if mmSearch.defaultExpectation.params != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
- }
- if mmSearch.defaultExpectation.paramPtrs == nil {
- mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
- }
- mmSearch.defaultExpectation.paramPtrs.search = &search
- return mmSearch
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) Inspect(f func(ctx context.Context, search string)) *mThingRepositoryMockSearch {
- if mmSearch.mock.inspectFuncSearch != nil {
- mmSearch.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Search")
- }
- mmSearch.mock.inspectFuncSearch = f
- return mmSearch
- }
- // Return sets up results that will be returned by ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- if mmSearch.defaultExpectation == nil {
- mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{mock: mmSearch.mock}
- }
- mmSearch.defaultExpectation.results = &ThingRepositoryMockSearchResults{ta1, err}
- return mmSearch.mock
- }
- // Set uses given function f to mock the ThingRepository.Search method
- func (mmSearch *mThingRepositoryMockSearch) Set(f func(ctx context.Context, search string) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
- if mmSearch.defaultExpectation != nil {
- mmSearch.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Search method")
- }
- if len(mmSearch.expectations) > 0 {
- mmSearch.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Search method")
- }
- mmSearch.mock.funcSearch = f
- return mmSearch.mock
- }
- // When sets expectation for the ThingRepository.Search which will trigger the result defined by the following
- // Then helper
- func (mmSearch *mThingRepositoryMockSearch) When(ctx context.Context, search string) *ThingRepositoryMockSearchExpectation {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- expectation := &ThingRepositoryMockSearchExpectation{
- mock: mmSearch.mock,
- params: &ThingRepositoryMockSearchParams{ctx, search},
- }
- mmSearch.expectations = append(mmSearch.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Search return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockSearchExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockSearchResults{ta1, err}
- return e.mock
- }
- // Times sets number of times ThingRepository.Search should be invoked
- func (mmSearch *mThingRepositoryMockSearch) Times(n uint64) *mThingRepositoryMockSearch {
- if n == 0 {
- mmSearch.mock.t.Fatalf("Times of ThingRepositoryMock.Search mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmSearch.expectedInvocations, n)
- return mmSearch
- }
- func (mmSearch *mThingRepositoryMockSearch) invocationsDone() bool {
- if len(mmSearch.expectations) == 0 && mmSearch.defaultExpectation == nil && mmSearch.mock.funcSearch == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmSearch.mock.afterSearchCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmSearch.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Search implements thing.ThingRepository
- func (mmSearch *ThingRepositoryMock) Search(ctx context.Context, search string) (ta1 []models.Thing, err error) {
- mm_atomic.AddUint64(&mmSearch.beforeSearchCounter, 1)
- defer mm_atomic.AddUint64(&mmSearch.afterSearchCounter, 1)
- if mmSearch.inspectFuncSearch != nil {
- mmSearch.inspectFuncSearch(ctx, search)
- }
- mm_params := ThingRepositoryMockSearchParams{ctx, search}
- // Record call args
- mmSearch.SearchMock.mutex.Lock()
- mmSearch.SearchMock.callArgs = append(mmSearch.SearchMock.callArgs, &mm_params)
- mmSearch.SearchMock.mutex.Unlock()
- for _, e := range mmSearch.SearchMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ta1, e.results.err
- }
- }
- if mmSearch.SearchMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmSearch.SearchMock.defaultExpectation.Counter, 1)
- mm_want := mmSearch.SearchMock.defaultExpectation.params
- mm_want_ptrs := mmSearch.SearchMock.defaultExpectation.paramPtrs
- mm_got := ThingRepositoryMockSearchParams{ctx, search}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmSearch.t.Errorf("ThingRepositoryMock.Search 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.search != nil && !minimock.Equal(*mm_want_ptrs.search, mm_got.search) {
- mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameter search, want: %#v, got: %#v%s\n", *mm_want_ptrs.search, mm_got.search, minimock.Diff(*mm_want_ptrs.search, mm_got.search))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmSearch.SearchMock.defaultExpectation.results
- if mm_results == nil {
- mmSearch.t.Fatal("No results are set for the ThingRepositoryMock.Search")
- }
- return (*mm_results).ta1, (*mm_results).err
- }
- if mmSearch.funcSearch != nil {
- return mmSearch.funcSearch(ctx, search)
- }
- mmSearch.t.Fatalf("Unexpected call to ThingRepositoryMock.Search. %v %v", ctx, search)
- return
- }
- // SearchAfterCounter returns a count of finished ThingRepositoryMock.Search invocations
- func (mmSearch *ThingRepositoryMock) SearchAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmSearch.afterSearchCounter)
- }
- // SearchBeforeCounter returns a count of ThingRepositoryMock.Search invocations
- func (mmSearch *ThingRepositoryMock) SearchBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmSearch.beforeSearchCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Search.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmSearch *mThingRepositoryMockSearch) Calls() []*ThingRepositoryMockSearchParams {
- mmSearch.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockSearchParams, len(mmSearch.callArgs))
- copy(argCopy, mmSearch.callArgs)
- mmSearch.mutex.RUnlock()
- return argCopy
- }
- // MinimockSearchDone returns true if the count of the Search invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockSearchDone() bool {
- if m.SearchMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.SearchMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.SearchMock.invocationsDone()
- }
- // MinimockSearchInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockSearchInspect() {
- for _, e := range m.SearchMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *e.params)
- }
- }
- afterSearchCounter := mm_atomic.LoadUint64(&m.afterSearchCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.SearchMock.defaultExpectation != nil && afterSearchCounter < 1 {
- if m.SearchMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.Search")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *m.SearchMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcSearch != nil && afterSearchCounter < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.Search")
- }
- if !m.SearchMock.invocationsDone() && afterSearchCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.Search but found %d calls",
- mm_atomic.LoadUint64(&m.SearchMock.expectedInvocations), afterSearchCounter)
- }
- }
- type mThingRepositoryMockUpdate struct {
- optional bool
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockUpdateExpectation
- expectations []*ThingRepositoryMockUpdateExpectation
- callArgs []*ThingRepositoryMockUpdateParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingRepositoryMockUpdateExpectation specifies expectation struct of the ThingRepository.Update
- type ThingRepositoryMockUpdateExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockUpdateParams
- paramPtrs *ThingRepositoryMockUpdateParamPtrs
- results *ThingRepositoryMockUpdateResults
- Counter uint64
- }
- // ThingRepositoryMockUpdateParams contains parameters of the ThingRepository.Update
- type ThingRepositoryMockUpdateParams struct {
- ctx context.Context
- req models.UpdateThingRequest
- tx *sql.Tx
- }
- // ThingRepositoryMockUpdateParamPtrs contains pointers to parameters of the ThingRepository.Update
- type ThingRepositoryMockUpdateParamPtrs struct {
- ctx *context.Context
- req *models.UpdateThingRequest
- tx **sql.Tx
- }
- // ThingRepositoryMockUpdateResults contains results of the ThingRepository.Update
- type ThingRepositoryMockUpdateResults 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 *mThingRepositoryMockUpdate) Optional() *mThingRepositoryMockUpdate {
- mmUpdate.optional = true
- return mmUpdate
- }
- // Expect sets up expected params for ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *mThingRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.paramPtrs != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by ExpectParams functions")
- }
- mmUpdate.defaultExpectation.params = &ThingRepositoryMockUpdateParams{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 ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx
- return mmUpdate
- }
- // ExpectReqParam2 sets up expected param req for ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) ExpectReqParam2(req models.UpdateThingRequest) *mThingRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.req = &req
- return mmUpdate
- }
- // ExpectTxParam3 sets up expected param tx for ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) ExpectTxParam3(tx *sql.Tx) *mThingRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.tx = &tx
- return mmUpdate
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)) *mThingRepositoryMockUpdate {
- if mmUpdate.mock.inspectFuncUpdate != nil {
- mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Update")
- }
- mmUpdate.mock.inspectFuncUpdate = f
- return mmUpdate
- }
- // Return sets up results that will be returned by ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) Return(err error) *ThingRepositoryMock {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
- }
- mmUpdate.defaultExpectation.results = &ThingRepositoryMockUpdateResults{err}
- return mmUpdate.mock
- }
- // Set uses given function f to mock the ThingRepository.Update method
- func (mmUpdate *mThingRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)) *ThingRepositoryMock {
- if mmUpdate.defaultExpectation != nil {
- mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Update method")
- }
- if len(mmUpdate.expectations) > 0 {
- mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Update method")
- }
- mmUpdate.mock.funcUpdate = f
- return mmUpdate.mock
- }
- // When sets expectation for the ThingRepository.Update which will trigger the result defined by the following
- // Then helper
- func (mmUpdate *mThingRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *ThingRepositoryMockUpdateExpectation {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- expectation := &ThingRepositoryMockUpdateExpectation{
- mock: mmUpdate.mock,
- params: &ThingRepositoryMockUpdateParams{ctx, req, tx},
- }
- mmUpdate.expectations = append(mmUpdate.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Update return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockUpdateExpectation) Then(err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockUpdateResults{err}
- return e.mock
- }
- // Times sets number of times ThingRepository.Update should be invoked
- func (mmUpdate *mThingRepositoryMockUpdate) Times(n uint64) *mThingRepositoryMockUpdate {
- if n == 0 {
- mmUpdate.mock.t.Fatalf("Times of ThingRepositoryMock.Update mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
- return mmUpdate
- }
- func (mmUpdate *mThingRepositoryMockUpdate) 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 thing.ThingRepository
- func (mmUpdate *ThingRepositoryMock) Update(ctx context.Context, req models.UpdateThingRequest, 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 := ThingRepositoryMockUpdateParams{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 := ThingRepositoryMockUpdateParams{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("ThingRepositoryMock.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("ThingRepositoryMock.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("ThingRepositoryMock.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("ThingRepositoryMock.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 ThingRepositoryMock.Update")
- }
- return (*mm_results).err
- }
- if mmUpdate.funcUpdate != nil {
- return mmUpdate.funcUpdate(ctx, req, tx)
- }
- mmUpdate.t.Fatalf("Unexpected call to ThingRepositoryMock.Update. %v %v %v", ctx, req, tx)
- return
- }
- // UpdateAfterCounter returns a count of finished ThingRepositoryMock.Update invocations
- func (mmUpdate *ThingRepositoryMock) UpdateAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
- }
- // UpdateBeforeCounter returns a count of ThingRepositoryMock.Update invocations
- func (mmUpdate *ThingRepositoryMock) UpdateBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Update.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmUpdate *mThingRepositoryMockUpdate) Calls() []*ThingRepositoryMockUpdateParams {
- mmUpdate.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockUpdateParams, 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 *ThingRepositoryMock) 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 *ThingRepositoryMock) MinimockUpdateInspect() {
- for _, e := range m.UpdateMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Update")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.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 ThingRepositoryMock.Update")
- }
- if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingRepositoryMock.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 *ThingRepositoryMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockAddInspect()
- m.MinimockBeginTxInspect()
- m.MinimockCommitTxInspect()
- m.MinimockDeleteInspect()
- m.MinimockGetInspect()
- m.MinimockGetAllByPlaceIDInspect()
- m.MinimockGetByPlaceIDInspect()
- m.MinimockSearchInspect()
- m.MinimockUpdateInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *ThingRepositoryMock) 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 *ThingRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockAddDone() &&
- m.MinimockBeginTxDone() &&
- m.MinimockCommitTxDone() &&
- m.MinimockDeleteDone() &&
- m.MinimockGetDone() &&
- m.MinimockGetAllByPlaceIDDone() &&
- m.MinimockGetByPlaceIDDone() &&
- m.MinimockSearchDone() &&
- m.MinimockUpdateDone()
- }
|