thing_repository_minimock.go 118 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113
  1. // Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
  2. package mocks
  3. //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/thing.ThingRepository -o thing_repository_minimock.go -n ThingRepositoryMock -p mocks
  4. import (
  5. "context"
  6. "database/sql"
  7. "sync"
  8. mm_atomic "sync/atomic"
  9. mm_time "time"
  10. "git.dmitriygnatenko.ru/dima/homethings/internal/models"
  11. "github.com/gojuno/minimock/v3"
  12. )
  13. // ThingRepositoryMock implements thing.ThingRepository
  14. type ThingRepositoryMock struct {
  15. t minimock.Tester
  16. finishOnce sync.Once
  17. funcAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)
  18. inspectFuncAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)
  19. afterAddCounter uint64
  20. beforeAddCounter uint64
  21. AddMock mThingRepositoryMockAdd
  22. funcBeginTx func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)
  23. inspectFuncBeginTx func(ctx context.Context, level sql.IsolationLevel)
  24. afterBeginTxCounter uint64
  25. beforeBeginTxCounter uint64
  26. BeginTxMock mThingRepositoryMockBeginTx
  27. funcCommitTx func(tx *sql.Tx) (err error)
  28. inspectFuncCommitTx func(tx *sql.Tx)
  29. afterCommitTxCounter uint64
  30. beforeCommitTxCounter uint64
  31. CommitTxMock mThingRepositoryMockCommitTx
  32. funcDelete func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
  33. inspectFuncDelete func(ctx context.Context, thingID int, tx *sql.Tx)
  34. afterDeleteCounter uint64
  35. beforeDeleteCounter uint64
  36. DeleteMock mThingRepositoryMockDelete
  37. funcGet func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)
  38. inspectFuncGet func(ctx context.Context, thingID int)
  39. afterGetCounter uint64
  40. beforeGetCounter uint64
  41. GetMock mThingRepositoryMockGet
  42. funcGetAllByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
  43. inspectFuncGetAllByPlaceID func(ctx context.Context, placeID int)
  44. afterGetAllByPlaceIDCounter uint64
  45. beforeGetAllByPlaceIDCounter uint64
  46. GetAllByPlaceIDMock mThingRepositoryMockGetAllByPlaceID
  47. funcGetByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
  48. inspectFuncGetByPlaceID func(ctx context.Context, placeID int)
  49. afterGetByPlaceIDCounter uint64
  50. beforeGetByPlaceIDCounter uint64
  51. GetByPlaceIDMock mThingRepositoryMockGetByPlaceID
  52. funcSearch func(ctx context.Context, search string) (ta1 []models.Thing, err error)
  53. inspectFuncSearch func(ctx context.Context, search string)
  54. afterSearchCounter uint64
  55. beforeSearchCounter uint64
  56. SearchMock mThingRepositoryMockSearch
  57. funcUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)
  58. inspectFuncUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)
  59. afterUpdateCounter uint64
  60. beforeUpdateCounter uint64
  61. UpdateMock mThingRepositoryMockUpdate
  62. }
  63. // NewThingRepositoryMock returns a mock for thing.ThingRepository
  64. func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock {
  65. m := &ThingRepositoryMock{t: t}
  66. if controller, ok := t.(minimock.MockController); ok {
  67. controller.RegisterMocker(m)
  68. }
  69. m.AddMock = mThingRepositoryMockAdd{mock: m}
  70. m.AddMock.callArgs = []*ThingRepositoryMockAddParams{}
  71. m.BeginTxMock = mThingRepositoryMockBeginTx{mock: m}
  72. m.BeginTxMock.callArgs = []*ThingRepositoryMockBeginTxParams{}
  73. m.CommitTxMock = mThingRepositoryMockCommitTx{mock: m}
  74. m.CommitTxMock.callArgs = []*ThingRepositoryMockCommitTxParams{}
  75. m.DeleteMock = mThingRepositoryMockDelete{mock: m}
  76. m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{}
  77. m.GetMock = mThingRepositoryMockGet{mock: m}
  78. m.GetMock.callArgs = []*ThingRepositoryMockGetParams{}
  79. m.GetAllByPlaceIDMock = mThingRepositoryMockGetAllByPlaceID{mock: m}
  80. m.GetAllByPlaceIDMock.callArgs = []*ThingRepositoryMockGetAllByPlaceIDParams{}
  81. m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m}
  82. m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{}
  83. m.SearchMock = mThingRepositoryMockSearch{mock: m}
  84. m.SearchMock.callArgs = []*ThingRepositoryMockSearchParams{}
  85. m.UpdateMock = mThingRepositoryMockUpdate{mock: m}
  86. m.UpdateMock.callArgs = []*ThingRepositoryMockUpdateParams{}
  87. t.Cleanup(m.MinimockFinish)
  88. return m
  89. }
  90. type mThingRepositoryMockAdd struct {
  91. optional bool
  92. mock *ThingRepositoryMock
  93. defaultExpectation *ThingRepositoryMockAddExpectation
  94. expectations []*ThingRepositoryMockAddExpectation
  95. callArgs []*ThingRepositoryMockAddParams
  96. mutex sync.RWMutex
  97. expectedInvocations uint64
  98. }
  99. // ThingRepositoryMockAddExpectation specifies expectation struct of the ThingRepository.Add
  100. type ThingRepositoryMockAddExpectation struct {
  101. mock *ThingRepositoryMock
  102. params *ThingRepositoryMockAddParams
  103. paramPtrs *ThingRepositoryMockAddParamPtrs
  104. results *ThingRepositoryMockAddResults
  105. Counter uint64
  106. }
  107. // ThingRepositoryMockAddParams contains parameters of the ThingRepository.Add
  108. type ThingRepositoryMockAddParams struct {
  109. ctx context.Context
  110. req models.AddThingRequest
  111. tx *sql.Tx
  112. }
  113. // ThingRepositoryMockAddParamPtrs contains pointers to parameters of the ThingRepository.Add
  114. type ThingRepositoryMockAddParamPtrs struct {
  115. ctx *context.Context
  116. req *models.AddThingRequest
  117. tx **sql.Tx
  118. }
  119. // ThingRepositoryMockAddResults contains results of the ThingRepository.Add
  120. type ThingRepositoryMockAddResults struct {
  121. i1 int
  122. err error
  123. }
  124. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  125. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  126. // Optional() makes method check to work in '0 or more' mode.
  127. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  128. // catch the problems when the expected method call is totally skipped during test run.
  129. func (mmAdd *mThingRepositoryMockAdd) Optional() *mThingRepositoryMockAdd {
  130. mmAdd.optional = true
  131. return mmAdd
  132. }
  133. // Expect sets up expected params for ThingRepository.Add
  134. func (mmAdd *mThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *mThingRepositoryMockAdd {
  135. if mmAdd.mock.funcAdd != nil {
  136. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  137. }
  138. if mmAdd.defaultExpectation == nil {
  139. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
  140. }
  141. if mmAdd.defaultExpectation.paramPtrs != nil {
  142. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by ExpectParams functions")
  143. }
  144. mmAdd.defaultExpectation.params = &ThingRepositoryMockAddParams{ctx, req, tx}
  145. for _, e := range mmAdd.expectations {
  146. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  147. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  148. }
  149. }
  150. return mmAdd
  151. }
  152. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Add
  153. func (mmAdd *mThingRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockAdd {
  154. if mmAdd.mock.funcAdd != nil {
  155. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  156. }
  157. if mmAdd.defaultExpectation == nil {
  158. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
  159. }
  160. if mmAdd.defaultExpectation.params != nil {
  161. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
  162. }
  163. if mmAdd.defaultExpectation.paramPtrs == nil {
  164. mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
  165. }
  166. mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
  167. return mmAdd
  168. }
  169. // ExpectReqParam2 sets up expected param req for ThingRepository.Add
  170. func (mmAdd *mThingRepositoryMockAdd) ExpectReqParam2(req models.AddThingRequest) *mThingRepositoryMockAdd {
  171. if mmAdd.mock.funcAdd != nil {
  172. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  173. }
  174. if mmAdd.defaultExpectation == nil {
  175. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
  176. }
  177. if mmAdd.defaultExpectation.params != nil {
  178. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
  179. }
  180. if mmAdd.defaultExpectation.paramPtrs == nil {
  181. mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
  182. }
  183. mmAdd.defaultExpectation.paramPtrs.req = &req
  184. return mmAdd
  185. }
  186. // ExpectTxParam3 sets up expected param tx for ThingRepository.Add
  187. func (mmAdd *mThingRepositoryMockAdd) ExpectTxParam3(tx *sql.Tx) *mThingRepositoryMockAdd {
  188. if mmAdd.mock.funcAdd != nil {
  189. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  190. }
  191. if mmAdd.defaultExpectation == nil {
  192. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
  193. }
  194. if mmAdd.defaultExpectation.params != nil {
  195. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
  196. }
  197. if mmAdd.defaultExpectation.paramPtrs == nil {
  198. mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
  199. }
  200. mmAdd.defaultExpectation.paramPtrs.tx = &tx
  201. return mmAdd
  202. }
  203. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Add
  204. func (mmAdd *mThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)) *mThingRepositoryMockAdd {
  205. if mmAdd.mock.inspectFuncAdd != nil {
  206. mmAdd.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Add")
  207. }
  208. mmAdd.mock.inspectFuncAdd = f
  209. return mmAdd
  210. }
  211. // Return sets up results that will be returned by ThingRepository.Add
  212. func (mmAdd *mThingRepositoryMockAdd) Return(i1 int, err error) *ThingRepositoryMock {
  213. if mmAdd.mock.funcAdd != nil {
  214. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  215. }
  216. if mmAdd.defaultExpectation == nil {
  217. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{mock: mmAdd.mock}
  218. }
  219. mmAdd.defaultExpectation.results = &ThingRepositoryMockAddResults{i1, err}
  220. return mmAdd.mock
  221. }
  222. // Set uses given function f to mock the ThingRepository.Add method
  223. func (mmAdd *mThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)) *ThingRepositoryMock {
  224. if mmAdd.defaultExpectation != nil {
  225. mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Add method")
  226. }
  227. if len(mmAdd.expectations) > 0 {
  228. mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Add method")
  229. }
  230. mmAdd.mock.funcAdd = f
  231. return mmAdd.mock
  232. }
  233. // When sets expectation for the ThingRepository.Add which will trigger the result defined by the following
  234. // Then helper
  235. func (mmAdd *mThingRepositoryMockAdd) When(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *ThingRepositoryMockAddExpectation {
  236. if mmAdd.mock.funcAdd != nil {
  237. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  238. }
  239. expectation := &ThingRepositoryMockAddExpectation{
  240. mock: mmAdd.mock,
  241. params: &ThingRepositoryMockAddParams{ctx, req, tx},
  242. }
  243. mmAdd.expectations = append(mmAdd.expectations, expectation)
  244. return expectation
  245. }
  246. // Then sets up ThingRepository.Add return parameters for the expectation previously defined by the When method
  247. func (e *ThingRepositoryMockAddExpectation) Then(i1 int, err error) *ThingRepositoryMock {
  248. e.results = &ThingRepositoryMockAddResults{i1, err}
  249. return e.mock
  250. }
  251. // Times sets number of times ThingRepository.Add should be invoked
  252. func (mmAdd *mThingRepositoryMockAdd) Times(n uint64) *mThingRepositoryMockAdd {
  253. if n == 0 {
  254. mmAdd.mock.t.Fatalf("Times of ThingRepositoryMock.Add mock can not be zero")
  255. }
  256. mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
  257. return mmAdd
  258. }
  259. func (mmAdd *mThingRepositoryMockAdd) invocationsDone() bool {
  260. if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
  261. return true
  262. }
  263. totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
  264. expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
  265. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  266. }
  267. // Add implements thing.ThingRepository
  268. func (mmAdd *ThingRepositoryMock) Add(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error) {
  269. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  270. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  271. if mmAdd.inspectFuncAdd != nil {
  272. mmAdd.inspectFuncAdd(ctx, req, tx)
  273. }
  274. mm_params := ThingRepositoryMockAddParams{ctx, req, tx}
  275. // Record call args
  276. mmAdd.AddMock.mutex.Lock()
  277. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
  278. mmAdd.AddMock.mutex.Unlock()
  279. for _, e := range mmAdd.AddMock.expectations {
  280. if minimock.Equal(*e.params, mm_params) {
  281. mm_atomic.AddUint64(&e.Counter, 1)
  282. return e.results.i1, e.results.err
  283. }
  284. }
  285. if mmAdd.AddMock.defaultExpectation != nil {
  286. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  287. mm_want := mmAdd.AddMock.defaultExpectation.params
  288. mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
  289. mm_got := ThingRepositoryMockAddParams{ctx, req, tx}
  290. if mm_want_ptrs != nil {
  291. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  292. 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))
  293. }
  294. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  295. 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))
  296. }
  297. if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
  298. 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))
  299. }
  300. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  301. mmAdd.t.Errorf("ThingRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  302. }
  303. mm_results := mmAdd.AddMock.defaultExpectation.results
  304. if mm_results == nil {
  305. mmAdd.t.Fatal("No results are set for the ThingRepositoryMock.Add")
  306. }
  307. return (*mm_results).i1, (*mm_results).err
  308. }
  309. if mmAdd.funcAdd != nil {
  310. return mmAdd.funcAdd(ctx, req, tx)
  311. }
  312. mmAdd.t.Fatalf("Unexpected call to ThingRepositoryMock.Add. %v %v %v", ctx, req, tx)
  313. return
  314. }
  315. // AddAfterCounter returns a count of finished ThingRepositoryMock.Add invocations
  316. func (mmAdd *ThingRepositoryMock) AddAfterCounter() uint64 {
  317. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  318. }
  319. // AddBeforeCounter returns a count of ThingRepositoryMock.Add invocations
  320. func (mmAdd *ThingRepositoryMock) AddBeforeCounter() uint64 {
  321. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  322. }
  323. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Add.
  324. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  325. func (mmAdd *mThingRepositoryMockAdd) Calls() []*ThingRepositoryMockAddParams {
  326. mmAdd.mutex.RLock()
  327. argCopy := make([]*ThingRepositoryMockAddParams, len(mmAdd.callArgs))
  328. copy(argCopy, mmAdd.callArgs)
  329. mmAdd.mutex.RUnlock()
  330. return argCopy
  331. }
  332. // MinimockAddDone returns true if the count of the Add invocations corresponds
  333. // the number of defined expectations
  334. func (m *ThingRepositoryMock) MinimockAddDone() bool {
  335. if m.AddMock.optional {
  336. // Optional methods provide '0 or more' call count restriction.
  337. return true
  338. }
  339. for _, e := range m.AddMock.expectations {
  340. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  341. return false
  342. }
  343. }
  344. return m.AddMock.invocationsDone()
  345. }
  346. // MinimockAddInspect logs each unmet expectation
  347. func (m *ThingRepositoryMock) MinimockAddInspect() {
  348. for _, e := range m.AddMock.expectations {
  349. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  350. m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *e.params)
  351. }
  352. }
  353. afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
  354. // if default expectation was set then invocations count should be greater than zero
  355. if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
  356. if m.AddMock.defaultExpectation.params == nil {
  357. m.t.Error("Expected call to ThingRepositoryMock.Add")
  358. } else {
  359. m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  360. }
  361. }
  362. // if func was set then invocations count should be greater than zero
  363. if m.funcAdd != nil && afterAddCounter < 1 {
  364. m.t.Error("Expected call to ThingRepositoryMock.Add")
  365. }
  366. if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
  367. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Add but found %d calls",
  368. mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
  369. }
  370. }
  371. type mThingRepositoryMockBeginTx struct {
  372. optional bool
  373. mock *ThingRepositoryMock
  374. defaultExpectation *ThingRepositoryMockBeginTxExpectation
  375. expectations []*ThingRepositoryMockBeginTxExpectation
  376. callArgs []*ThingRepositoryMockBeginTxParams
  377. mutex sync.RWMutex
  378. expectedInvocations uint64
  379. }
  380. // ThingRepositoryMockBeginTxExpectation specifies expectation struct of the ThingRepository.BeginTx
  381. type ThingRepositoryMockBeginTxExpectation struct {
  382. mock *ThingRepositoryMock
  383. params *ThingRepositoryMockBeginTxParams
  384. paramPtrs *ThingRepositoryMockBeginTxParamPtrs
  385. results *ThingRepositoryMockBeginTxResults
  386. Counter uint64
  387. }
  388. // ThingRepositoryMockBeginTxParams contains parameters of the ThingRepository.BeginTx
  389. type ThingRepositoryMockBeginTxParams struct {
  390. ctx context.Context
  391. level sql.IsolationLevel
  392. }
  393. // ThingRepositoryMockBeginTxParamPtrs contains pointers to parameters of the ThingRepository.BeginTx
  394. type ThingRepositoryMockBeginTxParamPtrs struct {
  395. ctx *context.Context
  396. level *sql.IsolationLevel
  397. }
  398. // ThingRepositoryMockBeginTxResults contains results of the ThingRepository.BeginTx
  399. type ThingRepositoryMockBeginTxResults struct {
  400. tp1 *sql.Tx
  401. err error
  402. }
  403. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  404. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  405. // Optional() makes method check to work in '0 or more' mode.
  406. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  407. // catch the problems when the expected method call is totally skipped during test run.
  408. func (mmBeginTx *mThingRepositoryMockBeginTx) Optional() *mThingRepositoryMockBeginTx {
  409. mmBeginTx.optional = true
  410. return mmBeginTx
  411. }
  412. // Expect sets up expected params for ThingRepository.BeginTx
  413. func (mmBeginTx *mThingRepositoryMockBeginTx) Expect(ctx context.Context, level sql.IsolationLevel) *mThingRepositoryMockBeginTx {
  414. if mmBeginTx.mock.funcBeginTx != nil {
  415. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  416. }
  417. if mmBeginTx.defaultExpectation == nil {
  418. mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
  419. }
  420. if mmBeginTx.defaultExpectation.paramPtrs != nil {
  421. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by ExpectParams functions")
  422. }
  423. mmBeginTx.defaultExpectation.params = &ThingRepositoryMockBeginTxParams{ctx, level}
  424. for _, e := range mmBeginTx.expectations {
  425. if minimock.Equal(e.params, mmBeginTx.defaultExpectation.params) {
  426. mmBeginTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmBeginTx.defaultExpectation.params)
  427. }
  428. }
  429. return mmBeginTx
  430. }
  431. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.BeginTx
  432. func (mmBeginTx *mThingRepositoryMockBeginTx) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockBeginTx {
  433. if mmBeginTx.mock.funcBeginTx != nil {
  434. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  435. }
  436. if mmBeginTx.defaultExpectation == nil {
  437. mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
  438. }
  439. if mmBeginTx.defaultExpectation.params != nil {
  440. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Expect")
  441. }
  442. if mmBeginTx.defaultExpectation.paramPtrs == nil {
  443. mmBeginTx.defaultExpectation.paramPtrs = &ThingRepositoryMockBeginTxParamPtrs{}
  444. }
  445. mmBeginTx.defaultExpectation.paramPtrs.ctx = &ctx
  446. return mmBeginTx
  447. }
  448. // ExpectLevelParam2 sets up expected param level for ThingRepository.BeginTx
  449. func (mmBeginTx *mThingRepositoryMockBeginTx) ExpectLevelParam2(level sql.IsolationLevel) *mThingRepositoryMockBeginTx {
  450. if mmBeginTx.mock.funcBeginTx != nil {
  451. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  452. }
  453. if mmBeginTx.defaultExpectation == nil {
  454. mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
  455. }
  456. if mmBeginTx.defaultExpectation.params != nil {
  457. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Expect")
  458. }
  459. if mmBeginTx.defaultExpectation.paramPtrs == nil {
  460. mmBeginTx.defaultExpectation.paramPtrs = &ThingRepositoryMockBeginTxParamPtrs{}
  461. }
  462. mmBeginTx.defaultExpectation.paramPtrs.level = &level
  463. return mmBeginTx
  464. }
  465. // Inspect accepts an inspector function that has same arguments as the ThingRepository.BeginTx
  466. func (mmBeginTx *mThingRepositoryMockBeginTx) Inspect(f func(ctx context.Context, level sql.IsolationLevel)) *mThingRepositoryMockBeginTx {
  467. if mmBeginTx.mock.inspectFuncBeginTx != nil {
  468. mmBeginTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.BeginTx")
  469. }
  470. mmBeginTx.mock.inspectFuncBeginTx = f
  471. return mmBeginTx
  472. }
  473. // Return sets up results that will be returned by ThingRepository.BeginTx
  474. func (mmBeginTx *mThingRepositoryMockBeginTx) Return(tp1 *sql.Tx, err error) *ThingRepositoryMock {
  475. if mmBeginTx.mock.funcBeginTx != nil {
  476. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  477. }
  478. if mmBeginTx.defaultExpectation == nil {
  479. mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{mock: mmBeginTx.mock}
  480. }
  481. mmBeginTx.defaultExpectation.results = &ThingRepositoryMockBeginTxResults{tp1, err}
  482. return mmBeginTx.mock
  483. }
  484. // Set uses given function f to mock the ThingRepository.BeginTx method
  485. func (mmBeginTx *mThingRepositoryMockBeginTx) Set(f func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)) *ThingRepositoryMock {
  486. if mmBeginTx.defaultExpectation != nil {
  487. mmBeginTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.BeginTx method")
  488. }
  489. if len(mmBeginTx.expectations) > 0 {
  490. mmBeginTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.BeginTx method")
  491. }
  492. mmBeginTx.mock.funcBeginTx = f
  493. return mmBeginTx.mock
  494. }
  495. // When sets expectation for the ThingRepository.BeginTx which will trigger the result defined by the following
  496. // Then helper
  497. func (mmBeginTx *mThingRepositoryMockBeginTx) When(ctx context.Context, level sql.IsolationLevel) *ThingRepositoryMockBeginTxExpectation {
  498. if mmBeginTx.mock.funcBeginTx != nil {
  499. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  500. }
  501. expectation := &ThingRepositoryMockBeginTxExpectation{
  502. mock: mmBeginTx.mock,
  503. params: &ThingRepositoryMockBeginTxParams{ctx, level},
  504. }
  505. mmBeginTx.expectations = append(mmBeginTx.expectations, expectation)
  506. return expectation
  507. }
  508. // Then sets up ThingRepository.BeginTx return parameters for the expectation previously defined by the When method
  509. func (e *ThingRepositoryMockBeginTxExpectation) Then(tp1 *sql.Tx, err error) *ThingRepositoryMock {
  510. e.results = &ThingRepositoryMockBeginTxResults{tp1, err}
  511. return e.mock
  512. }
  513. // Times sets number of times ThingRepository.BeginTx should be invoked
  514. func (mmBeginTx *mThingRepositoryMockBeginTx) Times(n uint64) *mThingRepositoryMockBeginTx {
  515. if n == 0 {
  516. mmBeginTx.mock.t.Fatalf("Times of ThingRepositoryMock.BeginTx mock can not be zero")
  517. }
  518. mm_atomic.StoreUint64(&mmBeginTx.expectedInvocations, n)
  519. return mmBeginTx
  520. }
  521. func (mmBeginTx *mThingRepositoryMockBeginTx) invocationsDone() bool {
  522. if len(mmBeginTx.expectations) == 0 && mmBeginTx.defaultExpectation == nil && mmBeginTx.mock.funcBeginTx == nil {
  523. return true
  524. }
  525. totalInvocations := mm_atomic.LoadUint64(&mmBeginTx.mock.afterBeginTxCounter)
  526. expectedInvocations := mm_atomic.LoadUint64(&mmBeginTx.expectedInvocations)
  527. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  528. }
  529. // BeginTx implements thing.ThingRepository
  530. func (mmBeginTx *ThingRepositoryMock) BeginTx(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error) {
  531. mm_atomic.AddUint64(&mmBeginTx.beforeBeginTxCounter, 1)
  532. defer mm_atomic.AddUint64(&mmBeginTx.afterBeginTxCounter, 1)
  533. if mmBeginTx.inspectFuncBeginTx != nil {
  534. mmBeginTx.inspectFuncBeginTx(ctx, level)
  535. }
  536. mm_params := ThingRepositoryMockBeginTxParams{ctx, level}
  537. // Record call args
  538. mmBeginTx.BeginTxMock.mutex.Lock()
  539. mmBeginTx.BeginTxMock.callArgs = append(mmBeginTx.BeginTxMock.callArgs, &mm_params)
  540. mmBeginTx.BeginTxMock.mutex.Unlock()
  541. for _, e := range mmBeginTx.BeginTxMock.expectations {
  542. if minimock.Equal(*e.params, mm_params) {
  543. mm_atomic.AddUint64(&e.Counter, 1)
  544. return e.results.tp1, e.results.err
  545. }
  546. }
  547. if mmBeginTx.BeginTxMock.defaultExpectation != nil {
  548. mm_atomic.AddUint64(&mmBeginTx.BeginTxMock.defaultExpectation.Counter, 1)
  549. mm_want := mmBeginTx.BeginTxMock.defaultExpectation.params
  550. mm_want_ptrs := mmBeginTx.BeginTxMock.defaultExpectation.paramPtrs
  551. mm_got := ThingRepositoryMockBeginTxParams{ctx, level}
  552. if mm_want_ptrs != nil {
  553. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  554. 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))
  555. }
  556. if mm_want_ptrs.level != nil && !minimock.Equal(*mm_want_ptrs.level, mm_got.level) {
  557. 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))
  558. }
  559. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  560. mmBeginTx.t.Errorf("ThingRepositoryMock.BeginTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  561. }
  562. mm_results := mmBeginTx.BeginTxMock.defaultExpectation.results
  563. if mm_results == nil {
  564. mmBeginTx.t.Fatal("No results are set for the ThingRepositoryMock.BeginTx")
  565. }
  566. return (*mm_results).tp1, (*mm_results).err
  567. }
  568. if mmBeginTx.funcBeginTx != nil {
  569. return mmBeginTx.funcBeginTx(ctx, level)
  570. }
  571. mmBeginTx.t.Fatalf("Unexpected call to ThingRepositoryMock.BeginTx. %v %v", ctx, level)
  572. return
  573. }
  574. // BeginTxAfterCounter returns a count of finished ThingRepositoryMock.BeginTx invocations
  575. func (mmBeginTx *ThingRepositoryMock) BeginTxAfterCounter() uint64 {
  576. return mm_atomic.LoadUint64(&mmBeginTx.afterBeginTxCounter)
  577. }
  578. // BeginTxBeforeCounter returns a count of ThingRepositoryMock.BeginTx invocations
  579. func (mmBeginTx *ThingRepositoryMock) BeginTxBeforeCounter() uint64 {
  580. return mm_atomic.LoadUint64(&mmBeginTx.beforeBeginTxCounter)
  581. }
  582. // Calls returns a list of arguments used in each call to ThingRepositoryMock.BeginTx.
  583. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  584. func (mmBeginTx *mThingRepositoryMockBeginTx) Calls() []*ThingRepositoryMockBeginTxParams {
  585. mmBeginTx.mutex.RLock()
  586. argCopy := make([]*ThingRepositoryMockBeginTxParams, len(mmBeginTx.callArgs))
  587. copy(argCopy, mmBeginTx.callArgs)
  588. mmBeginTx.mutex.RUnlock()
  589. return argCopy
  590. }
  591. // MinimockBeginTxDone returns true if the count of the BeginTx invocations corresponds
  592. // the number of defined expectations
  593. func (m *ThingRepositoryMock) MinimockBeginTxDone() bool {
  594. if m.BeginTxMock.optional {
  595. // Optional methods provide '0 or more' call count restriction.
  596. return true
  597. }
  598. for _, e := range m.BeginTxMock.expectations {
  599. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  600. return false
  601. }
  602. }
  603. return m.BeginTxMock.invocationsDone()
  604. }
  605. // MinimockBeginTxInspect logs each unmet expectation
  606. func (m *ThingRepositoryMock) MinimockBeginTxInspect() {
  607. for _, e := range m.BeginTxMock.expectations {
  608. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  609. m.t.Errorf("Expected call to ThingRepositoryMock.BeginTx with params: %#v", *e.params)
  610. }
  611. }
  612. afterBeginTxCounter := mm_atomic.LoadUint64(&m.afterBeginTxCounter)
  613. // if default expectation was set then invocations count should be greater than zero
  614. if m.BeginTxMock.defaultExpectation != nil && afterBeginTxCounter < 1 {
  615. if m.BeginTxMock.defaultExpectation.params == nil {
  616. m.t.Error("Expected call to ThingRepositoryMock.BeginTx")
  617. } else {
  618. m.t.Errorf("Expected call to ThingRepositoryMock.BeginTx with params: %#v", *m.BeginTxMock.defaultExpectation.params)
  619. }
  620. }
  621. // if func was set then invocations count should be greater than zero
  622. if m.funcBeginTx != nil && afterBeginTxCounter < 1 {
  623. m.t.Error("Expected call to ThingRepositoryMock.BeginTx")
  624. }
  625. if !m.BeginTxMock.invocationsDone() && afterBeginTxCounter > 0 {
  626. m.t.Errorf("Expected %d calls to ThingRepositoryMock.BeginTx but found %d calls",
  627. mm_atomic.LoadUint64(&m.BeginTxMock.expectedInvocations), afterBeginTxCounter)
  628. }
  629. }
  630. type mThingRepositoryMockCommitTx struct {
  631. optional bool
  632. mock *ThingRepositoryMock
  633. defaultExpectation *ThingRepositoryMockCommitTxExpectation
  634. expectations []*ThingRepositoryMockCommitTxExpectation
  635. callArgs []*ThingRepositoryMockCommitTxParams
  636. mutex sync.RWMutex
  637. expectedInvocations uint64
  638. }
  639. // ThingRepositoryMockCommitTxExpectation specifies expectation struct of the ThingRepository.CommitTx
  640. type ThingRepositoryMockCommitTxExpectation struct {
  641. mock *ThingRepositoryMock
  642. params *ThingRepositoryMockCommitTxParams
  643. paramPtrs *ThingRepositoryMockCommitTxParamPtrs
  644. results *ThingRepositoryMockCommitTxResults
  645. Counter uint64
  646. }
  647. // ThingRepositoryMockCommitTxParams contains parameters of the ThingRepository.CommitTx
  648. type ThingRepositoryMockCommitTxParams struct {
  649. tx *sql.Tx
  650. }
  651. // ThingRepositoryMockCommitTxParamPtrs contains pointers to parameters of the ThingRepository.CommitTx
  652. type ThingRepositoryMockCommitTxParamPtrs struct {
  653. tx **sql.Tx
  654. }
  655. // ThingRepositoryMockCommitTxResults contains results of the ThingRepository.CommitTx
  656. type ThingRepositoryMockCommitTxResults struct {
  657. err error
  658. }
  659. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  660. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  661. // Optional() makes method check to work in '0 or more' mode.
  662. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  663. // catch the problems when the expected method call is totally skipped during test run.
  664. func (mmCommitTx *mThingRepositoryMockCommitTx) Optional() *mThingRepositoryMockCommitTx {
  665. mmCommitTx.optional = true
  666. return mmCommitTx
  667. }
  668. // Expect sets up expected params for ThingRepository.CommitTx
  669. func (mmCommitTx *mThingRepositoryMockCommitTx) Expect(tx *sql.Tx) *mThingRepositoryMockCommitTx {
  670. if mmCommitTx.mock.funcCommitTx != nil {
  671. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
  672. }
  673. if mmCommitTx.defaultExpectation == nil {
  674. mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{}
  675. }
  676. if mmCommitTx.defaultExpectation.paramPtrs != nil {
  677. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by ExpectParams functions")
  678. }
  679. mmCommitTx.defaultExpectation.params = &ThingRepositoryMockCommitTxParams{tx}
  680. for _, e := range mmCommitTx.expectations {
  681. if minimock.Equal(e.params, mmCommitTx.defaultExpectation.params) {
  682. mmCommitTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCommitTx.defaultExpectation.params)
  683. }
  684. }
  685. return mmCommitTx
  686. }
  687. // ExpectTxParam1 sets up expected param tx for ThingRepository.CommitTx
  688. func (mmCommitTx *mThingRepositoryMockCommitTx) ExpectTxParam1(tx *sql.Tx) *mThingRepositoryMockCommitTx {
  689. if mmCommitTx.mock.funcCommitTx != nil {
  690. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
  691. }
  692. if mmCommitTx.defaultExpectation == nil {
  693. mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{}
  694. }
  695. if mmCommitTx.defaultExpectation.params != nil {
  696. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Expect")
  697. }
  698. if mmCommitTx.defaultExpectation.paramPtrs == nil {
  699. mmCommitTx.defaultExpectation.paramPtrs = &ThingRepositoryMockCommitTxParamPtrs{}
  700. }
  701. mmCommitTx.defaultExpectation.paramPtrs.tx = &tx
  702. return mmCommitTx
  703. }
  704. // Inspect accepts an inspector function that has same arguments as the ThingRepository.CommitTx
  705. func (mmCommitTx *mThingRepositoryMockCommitTx) Inspect(f func(tx *sql.Tx)) *mThingRepositoryMockCommitTx {
  706. if mmCommitTx.mock.inspectFuncCommitTx != nil {
  707. mmCommitTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.CommitTx")
  708. }
  709. mmCommitTx.mock.inspectFuncCommitTx = f
  710. return mmCommitTx
  711. }
  712. // Return sets up results that will be returned by ThingRepository.CommitTx
  713. func (mmCommitTx *mThingRepositoryMockCommitTx) Return(err error) *ThingRepositoryMock {
  714. if mmCommitTx.mock.funcCommitTx != nil {
  715. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
  716. }
  717. if mmCommitTx.defaultExpectation == nil {
  718. mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{mock: mmCommitTx.mock}
  719. }
  720. mmCommitTx.defaultExpectation.results = &ThingRepositoryMockCommitTxResults{err}
  721. return mmCommitTx.mock
  722. }
  723. // Set uses given function f to mock the ThingRepository.CommitTx method
  724. func (mmCommitTx *mThingRepositoryMockCommitTx) Set(f func(tx *sql.Tx) (err error)) *ThingRepositoryMock {
  725. if mmCommitTx.defaultExpectation != nil {
  726. mmCommitTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.CommitTx method")
  727. }
  728. if len(mmCommitTx.expectations) > 0 {
  729. mmCommitTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.CommitTx method")
  730. }
  731. mmCommitTx.mock.funcCommitTx = f
  732. return mmCommitTx.mock
  733. }
  734. // When sets expectation for the ThingRepository.CommitTx which will trigger the result defined by the following
  735. // Then helper
  736. func (mmCommitTx *mThingRepositoryMockCommitTx) When(tx *sql.Tx) *ThingRepositoryMockCommitTxExpectation {
  737. if mmCommitTx.mock.funcCommitTx != nil {
  738. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
  739. }
  740. expectation := &ThingRepositoryMockCommitTxExpectation{
  741. mock: mmCommitTx.mock,
  742. params: &ThingRepositoryMockCommitTxParams{tx},
  743. }
  744. mmCommitTx.expectations = append(mmCommitTx.expectations, expectation)
  745. return expectation
  746. }
  747. // Then sets up ThingRepository.CommitTx return parameters for the expectation previously defined by the When method
  748. func (e *ThingRepositoryMockCommitTxExpectation) Then(err error) *ThingRepositoryMock {
  749. e.results = &ThingRepositoryMockCommitTxResults{err}
  750. return e.mock
  751. }
  752. // Times sets number of times ThingRepository.CommitTx should be invoked
  753. func (mmCommitTx *mThingRepositoryMockCommitTx) Times(n uint64) *mThingRepositoryMockCommitTx {
  754. if n == 0 {
  755. mmCommitTx.mock.t.Fatalf("Times of ThingRepositoryMock.CommitTx mock can not be zero")
  756. }
  757. mm_atomic.StoreUint64(&mmCommitTx.expectedInvocations, n)
  758. return mmCommitTx
  759. }
  760. func (mmCommitTx *mThingRepositoryMockCommitTx) invocationsDone() bool {
  761. if len(mmCommitTx.expectations) == 0 && mmCommitTx.defaultExpectation == nil && mmCommitTx.mock.funcCommitTx == nil {
  762. return true
  763. }
  764. totalInvocations := mm_atomic.LoadUint64(&mmCommitTx.mock.afterCommitTxCounter)
  765. expectedInvocations := mm_atomic.LoadUint64(&mmCommitTx.expectedInvocations)
  766. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  767. }
  768. // CommitTx implements thing.ThingRepository
  769. func (mmCommitTx *ThingRepositoryMock) CommitTx(tx *sql.Tx) (err error) {
  770. mm_atomic.AddUint64(&mmCommitTx.beforeCommitTxCounter, 1)
  771. defer mm_atomic.AddUint64(&mmCommitTx.afterCommitTxCounter, 1)
  772. if mmCommitTx.inspectFuncCommitTx != nil {
  773. mmCommitTx.inspectFuncCommitTx(tx)
  774. }
  775. mm_params := ThingRepositoryMockCommitTxParams{tx}
  776. // Record call args
  777. mmCommitTx.CommitTxMock.mutex.Lock()
  778. mmCommitTx.CommitTxMock.callArgs = append(mmCommitTx.CommitTxMock.callArgs, &mm_params)
  779. mmCommitTx.CommitTxMock.mutex.Unlock()
  780. for _, e := range mmCommitTx.CommitTxMock.expectations {
  781. if minimock.Equal(*e.params, mm_params) {
  782. mm_atomic.AddUint64(&e.Counter, 1)
  783. return e.results.err
  784. }
  785. }
  786. if mmCommitTx.CommitTxMock.defaultExpectation != nil {
  787. mm_atomic.AddUint64(&mmCommitTx.CommitTxMock.defaultExpectation.Counter, 1)
  788. mm_want := mmCommitTx.CommitTxMock.defaultExpectation.params
  789. mm_want_ptrs := mmCommitTx.CommitTxMock.defaultExpectation.paramPtrs
  790. mm_got := ThingRepositoryMockCommitTxParams{tx}
  791. if mm_want_ptrs != nil {
  792. if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
  793. 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))
  794. }
  795. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  796. mmCommitTx.t.Errorf("ThingRepositoryMock.CommitTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  797. }
  798. mm_results := mmCommitTx.CommitTxMock.defaultExpectation.results
  799. if mm_results == nil {
  800. mmCommitTx.t.Fatal("No results are set for the ThingRepositoryMock.CommitTx")
  801. }
  802. return (*mm_results).err
  803. }
  804. if mmCommitTx.funcCommitTx != nil {
  805. return mmCommitTx.funcCommitTx(tx)
  806. }
  807. mmCommitTx.t.Fatalf("Unexpected call to ThingRepositoryMock.CommitTx. %v", tx)
  808. return
  809. }
  810. // CommitTxAfterCounter returns a count of finished ThingRepositoryMock.CommitTx invocations
  811. func (mmCommitTx *ThingRepositoryMock) CommitTxAfterCounter() uint64 {
  812. return mm_atomic.LoadUint64(&mmCommitTx.afterCommitTxCounter)
  813. }
  814. // CommitTxBeforeCounter returns a count of ThingRepositoryMock.CommitTx invocations
  815. func (mmCommitTx *ThingRepositoryMock) CommitTxBeforeCounter() uint64 {
  816. return mm_atomic.LoadUint64(&mmCommitTx.beforeCommitTxCounter)
  817. }
  818. // Calls returns a list of arguments used in each call to ThingRepositoryMock.CommitTx.
  819. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  820. func (mmCommitTx *mThingRepositoryMockCommitTx) Calls() []*ThingRepositoryMockCommitTxParams {
  821. mmCommitTx.mutex.RLock()
  822. argCopy := make([]*ThingRepositoryMockCommitTxParams, len(mmCommitTx.callArgs))
  823. copy(argCopy, mmCommitTx.callArgs)
  824. mmCommitTx.mutex.RUnlock()
  825. return argCopy
  826. }
  827. // MinimockCommitTxDone returns true if the count of the CommitTx invocations corresponds
  828. // the number of defined expectations
  829. func (m *ThingRepositoryMock) MinimockCommitTxDone() bool {
  830. if m.CommitTxMock.optional {
  831. // Optional methods provide '0 or more' call count restriction.
  832. return true
  833. }
  834. for _, e := range m.CommitTxMock.expectations {
  835. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  836. return false
  837. }
  838. }
  839. return m.CommitTxMock.invocationsDone()
  840. }
  841. // MinimockCommitTxInspect logs each unmet expectation
  842. func (m *ThingRepositoryMock) MinimockCommitTxInspect() {
  843. for _, e := range m.CommitTxMock.expectations {
  844. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  845. m.t.Errorf("Expected call to ThingRepositoryMock.CommitTx with params: %#v", *e.params)
  846. }
  847. }
  848. afterCommitTxCounter := mm_atomic.LoadUint64(&m.afterCommitTxCounter)
  849. // if default expectation was set then invocations count should be greater than zero
  850. if m.CommitTxMock.defaultExpectation != nil && afterCommitTxCounter < 1 {
  851. if m.CommitTxMock.defaultExpectation.params == nil {
  852. m.t.Error("Expected call to ThingRepositoryMock.CommitTx")
  853. } else {
  854. m.t.Errorf("Expected call to ThingRepositoryMock.CommitTx with params: %#v", *m.CommitTxMock.defaultExpectation.params)
  855. }
  856. }
  857. // if func was set then invocations count should be greater than zero
  858. if m.funcCommitTx != nil && afterCommitTxCounter < 1 {
  859. m.t.Error("Expected call to ThingRepositoryMock.CommitTx")
  860. }
  861. if !m.CommitTxMock.invocationsDone() && afterCommitTxCounter > 0 {
  862. m.t.Errorf("Expected %d calls to ThingRepositoryMock.CommitTx but found %d calls",
  863. mm_atomic.LoadUint64(&m.CommitTxMock.expectedInvocations), afterCommitTxCounter)
  864. }
  865. }
  866. type mThingRepositoryMockDelete struct {
  867. optional bool
  868. mock *ThingRepositoryMock
  869. defaultExpectation *ThingRepositoryMockDeleteExpectation
  870. expectations []*ThingRepositoryMockDeleteExpectation
  871. callArgs []*ThingRepositoryMockDeleteParams
  872. mutex sync.RWMutex
  873. expectedInvocations uint64
  874. }
  875. // ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete
  876. type ThingRepositoryMockDeleteExpectation struct {
  877. mock *ThingRepositoryMock
  878. params *ThingRepositoryMockDeleteParams
  879. paramPtrs *ThingRepositoryMockDeleteParamPtrs
  880. results *ThingRepositoryMockDeleteResults
  881. Counter uint64
  882. }
  883. // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
  884. type ThingRepositoryMockDeleteParams struct {
  885. ctx context.Context
  886. thingID int
  887. tx *sql.Tx
  888. }
  889. // ThingRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingRepository.Delete
  890. type ThingRepositoryMockDeleteParamPtrs struct {
  891. ctx *context.Context
  892. thingID *int
  893. tx **sql.Tx
  894. }
  895. // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
  896. type ThingRepositoryMockDeleteResults struct {
  897. err error
  898. }
  899. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  900. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  901. // Optional() makes method check to work in '0 or more' mode.
  902. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  903. // catch the problems when the expected method call is totally skipped during test run.
  904. func (mmDelete *mThingRepositoryMockDelete) Optional() *mThingRepositoryMockDelete {
  905. mmDelete.optional = true
  906. return mmDelete
  907. }
  908. // Expect sets up expected params for ThingRepository.Delete
  909. func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingRepositoryMockDelete {
  910. if mmDelete.mock.funcDelete != nil {
  911. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  912. }
  913. if mmDelete.defaultExpectation == nil {
  914. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  915. }
  916. if mmDelete.defaultExpectation.paramPtrs != nil {
  917. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by ExpectParams functions")
  918. }
  919. mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, thingID, tx}
  920. for _, e := range mmDelete.expectations {
  921. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  922. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  923. }
  924. }
  925. return mmDelete
  926. }
  927. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Delete
  928. func (mmDelete *mThingRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockDelete {
  929. if mmDelete.mock.funcDelete != nil {
  930. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  931. }
  932. if mmDelete.defaultExpectation == nil {
  933. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  934. }
  935. if mmDelete.defaultExpectation.params != nil {
  936. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
  937. }
  938. if mmDelete.defaultExpectation.paramPtrs == nil {
  939. mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
  940. }
  941. mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
  942. return mmDelete
  943. }
  944. // ExpectThingIDParam2 sets up expected param thingID for ThingRepository.Delete
  945. func (mmDelete *mThingRepositoryMockDelete) ExpectThingIDParam2(thingID int) *mThingRepositoryMockDelete {
  946. if mmDelete.mock.funcDelete != nil {
  947. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  948. }
  949. if mmDelete.defaultExpectation == nil {
  950. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  951. }
  952. if mmDelete.defaultExpectation.params != nil {
  953. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
  954. }
  955. if mmDelete.defaultExpectation.paramPtrs == nil {
  956. mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
  957. }
  958. mmDelete.defaultExpectation.paramPtrs.thingID = &thingID
  959. return mmDelete
  960. }
  961. // ExpectTxParam3 sets up expected param tx for ThingRepository.Delete
  962. func (mmDelete *mThingRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingRepositoryMockDelete {
  963. if mmDelete.mock.funcDelete != nil {
  964. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  965. }
  966. if mmDelete.defaultExpectation == nil {
  967. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  968. }
  969. if mmDelete.defaultExpectation.params != nil {
  970. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
  971. }
  972. if mmDelete.defaultExpectation.paramPtrs == nil {
  973. mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
  974. }
  975. mmDelete.defaultExpectation.paramPtrs.tx = &tx
  976. return mmDelete
  977. }
  978. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
  979. func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingRepositoryMockDelete {
  980. if mmDelete.mock.inspectFuncDelete != nil {
  981. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
  982. }
  983. mmDelete.mock.inspectFuncDelete = f
  984. return mmDelete
  985. }
  986. // Return sets up results that will be returned by ThingRepository.Delete
  987. func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock {
  988. if mmDelete.mock.funcDelete != nil {
  989. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  990. }
  991. if mmDelete.defaultExpectation == nil {
  992. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  993. }
  994. mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err}
  995. return mmDelete.mock
  996. }
  997. // Set uses given function f to mock the ThingRepository.Delete method
  998. func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingRepositoryMock {
  999. if mmDelete.defaultExpectation != nil {
  1000. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
  1001. }
  1002. if len(mmDelete.expectations) > 0 {
  1003. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method")
  1004. }
  1005. mmDelete.mock.funcDelete = f
  1006. return mmDelete.mock
  1007. }
  1008. // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
  1009. // Then helper
  1010. func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingRepositoryMockDeleteExpectation {
  1011. if mmDelete.mock.funcDelete != nil {
  1012. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  1013. }
  1014. expectation := &ThingRepositoryMockDeleteExpectation{
  1015. mock: mmDelete.mock,
  1016. params: &ThingRepositoryMockDeleteParams{ctx, thingID, tx},
  1017. }
  1018. mmDelete.expectations = append(mmDelete.expectations, expectation)
  1019. return expectation
  1020. }
  1021. // Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method
  1022. func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock {
  1023. e.results = &ThingRepositoryMockDeleteResults{err}
  1024. return e.mock
  1025. }
  1026. // Times sets number of times ThingRepository.Delete should be invoked
  1027. func (mmDelete *mThingRepositoryMockDelete) Times(n uint64) *mThingRepositoryMockDelete {
  1028. if n == 0 {
  1029. mmDelete.mock.t.Fatalf("Times of ThingRepositoryMock.Delete mock can not be zero")
  1030. }
  1031. mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
  1032. return mmDelete
  1033. }
  1034. func (mmDelete *mThingRepositoryMockDelete) invocationsDone() bool {
  1035. if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
  1036. return true
  1037. }
  1038. totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
  1039. expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
  1040. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1041. }
  1042. // Delete implements thing.ThingRepository
  1043. func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
  1044. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  1045. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  1046. if mmDelete.inspectFuncDelete != nil {
  1047. mmDelete.inspectFuncDelete(ctx, thingID, tx)
  1048. }
  1049. mm_params := ThingRepositoryMockDeleteParams{ctx, thingID, tx}
  1050. // Record call args
  1051. mmDelete.DeleteMock.mutex.Lock()
  1052. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
  1053. mmDelete.DeleteMock.mutex.Unlock()
  1054. for _, e := range mmDelete.DeleteMock.expectations {
  1055. if minimock.Equal(*e.params, mm_params) {
  1056. mm_atomic.AddUint64(&e.Counter, 1)
  1057. return e.results.err
  1058. }
  1059. }
  1060. if mmDelete.DeleteMock.defaultExpectation != nil {
  1061. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  1062. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  1063. mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
  1064. mm_got := ThingRepositoryMockDeleteParams{ctx, thingID, tx}
  1065. if mm_want_ptrs != nil {
  1066. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1067. 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))
  1068. }
  1069. if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
  1070. 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))
  1071. }
  1072. if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
  1073. 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))
  1074. }
  1075. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1076. mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1077. }
  1078. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  1079. if mm_results == nil {
  1080. mmDelete.t.Fatal("No results are set for the ThingRepositoryMock.Delete")
  1081. }
  1082. return (*mm_results).err
  1083. }
  1084. if mmDelete.funcDelete != nil {
  1085. return mmDelete.funcDelete(ctx, thingID, tx)
  1086. }
  1087. mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
  1088. return
  1089. }
  1090. // DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations
  1091. func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 {
  1092. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  1093. }
  1094. // DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations
  1095. func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 {
  1096. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  1097. }
  1098. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete.
  1099. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1100. func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams {
  1101. mmDelete.mutex.RLock()
  1102. argCopy := make([]*ThingRepositoryMockDeleteParams, len(mmDelete.callArgs))
  1103. copy(argCopy, mmDelete.callArgs)
  1104. mmDelete.mutex.RUnlock()
  1105. return argCopy
  1106. }
  1107. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  1108. // the number of defined expectations
  1109. func (m *ThingRepositoryMock) MinimockDeleteDone() bool {
  1110. if m.DeleteMock.optional {
  1111. // Optional methods provide '0 or more' call count restriction.
  1112. return true
  1113. }
  1114. for _, e := range m.DeleteMock.expectations {
  1115. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1116. return false
  1117. }
  1118. }
  1119. return m.DeleteMock.invocationsDone()
  1120. }
  1121. // MinimockDeleteInspect logs each unmet expectation
  1122. func (m *ThingRepositoryMock) MinimockDeleteInspect() {
  1123. for _, e := range m.DeleteMock.expectations {
  1124. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1125. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *e.params)
  1126. }
  1127. }
  1128. afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
  1129. // if default expectation was set then invocations count should be greater than zero
  1130. if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
  1131. if m.DeleteMock.defaultExpectation.params == nil {
  1132. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  1133. } else {
  1134. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  1135. }
  1136. }
  1137. // if func was set then invocations count should be greater than zero
  1138. if m.funcDelete != nil && afterDeleteCounter < 1 {
  1139. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  1140. }
  1141. if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
  1142. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Delete but found %d calls",
  1143. mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
  1144. }
  1145. }
  1146. type mThingRepositoryMockGet struct {
  1147. optional bool
  1148. mock *ThingRepositoryMock
  1149. defaultExpectation *ThingRepositoryMockGetExpectation
  1150. expectations []*ThingRepositoryMockGetExpectation
  1151. callArgs []*ThingRepositoryMockGetParams
  1152. mutex sync.RWMutex
  1153. expectedInvocations uint64
  1154. }
  1155. // ThingRepositoryMockGetExpectation specifies expectation struct of the ThingRepository.Get
  1156. type ThingRepositoryMockGetExpectation struct {
  1157. mock *ThingRepositoryMock
  1158. params *ThingRepositoryMockGetParams
  1159. paramPtrs *ThingRepositoryMockGetParamPtrs
  1160. results *ThingRepositoryMockGetResults
  1161. Counter uint64
  1162. }
  1163. // ThingRepositoryMockGetParams contains parameters of the ThingRepository.Get
  1164. type ThingRepositoryMockGetParams struct {
  1165. ctx context.Context
  1166. thingID int
  1167. }
  1168. // ThingRepositoryMockGetParamPtrs contains pointers to parameters of the ThingRepository.Get
  1169. type ThingRepositoryMockGetParamPtrs struct {
  1170. ctx *context.Context
  1171. thingID *int
  1172. }
  1173. // ThingRepositoryMockGetResults contains results of the ThingRepository.Get
  1174. type ThingRepositoryMockGetResults struct {
  1175. tp1 *models.Thing
  1176. err error
  1177. }
  1178. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1179. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1180. // Optional() makes method check to work in '0 or more' mode.
  1181. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1182. // catch the problems when the expected method call is totally skipped during test run.
  1183. func (mmGet *mThingRepositoryMockGet) Optional() *mThingRepositoryMockGet {
  1184. mmGet.optional = true
  1185. return mmGet
  1186. }
  1187. // Expect sets up expected params for ThingRepository.Get
  1188. func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, thingID int) *mThingRepositoryMockGet {
  1189. if mmGet.mock.funcGet != nil {
  1190. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  1191. }
  1192. if mmGet.defaultExpectation == nil {
  1193. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
  1194. }
  1195. if mmGet.defaultExpectation.paramPtrs != nil {
  1196. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by ExpectParams functions")
  1197. }
  1198. mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, thingID}
  1199. for _, e := range mmGet.expectations {
  1200. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  1201. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  1202. }
  1203. }
  1204. return mmGet
  1205. }
  1206. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Get
  1207. func (mmGet *mThingRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGet {
  1208. if mmGet.mock.funcGet != nil {
  1209. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  1210. }
  1211. if mmGet.defaultExpectation == nil {
  1212. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
  1213. }
  1214. if mmGet.defaultExpectation.params != nil {
  1215. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
  1216. }
  1217. if mmGet.defaultExpectation.paramPtrs == nil {
  1218. mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
  1219. }
  1220. mmGet.defaultExpectation.paramPtrs.ctx = &ctx
  1221. return mmGet
  1222. }
  1223. // ExpectThingIDParam2 sets up expected param thingID for ThingRepository.Get
  1224. func (mmGet *mThingRepositoryMockGet) ExpectThingIDParam2(thingID int) *mThingRepositoryMockGet {
  1225. if mmGet.mock.funcGet != nil {
  1226. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  1227. }
  1228. if mmGet.defaultExpectation == nil {
  1229. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
  1230. }
  1231. if mmGet.defaultExpectation.params != nil {
  1232. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
  1233. }
  1234. if mmGet.defaultExpectation.paramPtrs == nil {
  1235. mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
  1236. }
  1237. mmGet.defaultExpectation.paramPtrs.thingID = &thingID
  1238. return mmGet
  1239. }
  1240. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Get
  1241. func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, thingID int)) *mThingRepositoryMockGet {
  1242. if mmGet.mock.inspectFuncGet != nil {
  1243. mmGet.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Get")
  1244. }
  1245. mmGet.mock.inspectFuncGet = f
  1246. return mmGet
  1247. }
  1248. // Return sets up results that will be returned by ThingRepository.Get
  1249. func (mmGet *mThingRepositoryMockGet) Return(tp1 *models.Thing, err error) *ThingRepositoryMock {
  1250. if mmGet.mock.funcGet != nil {
  1251. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  1252. }
  1253. if mmGet.defaultExpectation == nil {
  1254. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{mock: mmGet.mock}
  1255. }
  1256. mmGet.defaultExpectation.results = &ThingRepositoryMockGetResults{tp1, err}
  1257. return mmGet.mock
  1258. }
  1259. // Set uses given function f to mock the ThingRepository.Get method
  1260. func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
  1261. if mmGet.defaultExpectation != nil {
  1262. mmGet.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Get method")
  1263. }
  1264. if len(mmGet.expectations) > 0 {
  1265. mmGet.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Get method")
  1266. }
  1267. mmGet.mock.funcGet = f
  1268. return mmGet.mock
  1269. }
  1270. // When sets expectation for the ThingRepository.Get which will trigger the result defined by the following
  1271. // Then helper
  1272. func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, thingID int) *ThingRepositoryMockGetExpectation {
  1273. if mmGet.mock.funcGet != nil {
  1274. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  1275. }
  1276. expectation := &ThingRepositoryMockGetExpectation{
  1277. mock: mmGet.mock,
  1278. params: &ThingRepositoryMockGetParams{ctx, thingID},
  1279. }
  1280. mmGet.expectations = append(mmGet.expectations, expectation)
  1281. return expectation
  1282. }
  1283. // Then sets up ThingRepository.Get return parameters for the expectation previously defined by the When method
  1284. func (e *ThingRepositoryMockGetExpectation) Then(tp1 *models.Thing, err error) *ThingRepositoryMock {
  1285. e.results = &ThingRepositoryMockGetResults{tp1, err}
  1286. return e.mock
  1287. }
  1288. // Times sets number of times ThingRepository.Get should be invoked
  1289. func (mmGet *mThingRepositoryMockGet) Times(n uint64) *mThingRepositoryMockGet {
  1290. if n == 0 {
  1291. mmGet.mock.t.Fatalf("Times of ThingRepositoryMock.Get mock can not be zero")
  1292. }
  1293. mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
  1294. return mmGet
  1295. }
  1296. func (mmGet *mThingRepositoryMockGet) invocationsDone() bool {
  1297. if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
  1298. return true
  1299. }
  1300. totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
  1301. expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
  1302. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1303. }
  1304. // Get implements thing.ThingRepository
  1305. func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *models.Thing, err error) {
  1306. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  1307. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  1308. if mmGet.inspectFuncGet != nil {
  1309. mmGet.inspectFuncGet(ctx, thingID)
  1310. }
  1311. mm_params := ThingRepositoryMockGetParams{ctx, thingID}
  1312. // Record call args
  1313. mmGet.GetMock.mutex.Lock()
  1314. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
  1315. mmGet.GetMock.mutex.Unlock()
  1316. for _, e := range mmGet.GetMock.expectations {
  1317. if minimock.Equal(*e.params, mm_params) {
  1318. mm_atomic.AddUint64(&e.Counter, 1)
  1319. return e.results.tp1, e.results.err
  1320. }
  1321. }
  1322. if mmGet.GetMock.defaultExpectation != nil {
  1323. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  1324. mm_want := mmGet.GetMock.defaultExpectation.params
  1325. mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
  1326. mm_got := ThingRepositoryMockGetParams{ctx, thingID}
  1327. if mm_want_ptrs != nil {
  1328. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1329. 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))
  1330. }
  1331. if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
  1332. 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))
  1333. }
  1334. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1335. mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1336. }
  1337. mm_results := mmGet.GetMock.defaultExpectation.results
  1338. if mm_results == nil {
  1339. mmGet.t.Fatal("No results are set for the ThingRepositoryMock.Get")
  1340. }
  1341. return (*mm_results).tp1, (*mm_results).err
  1342. }
  1343. if mmGet.funcGet != nil {
  1344. return mmGet.funcGet(ctx, thingID)
  1345. }
  1346. mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, thingID)
  1347. return
  1348. }
  1349. // GetAfterCounter returns a count of finished ThingRepositoryMock.Get invocations
  1350. func (mmGet *ThingRepositoryMock) GetAfterCounter() uint64 {
  1351. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  1352. }
  1353. // GetBeforeCounter returns a count of ThingRepositoryMock.Get invocations
  1354. func (mmGet *ThingRepositoryMock) GetBeforeCounter() uint64 {
  1355. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  1356. }
  1357. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Get.
  1358. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1359. func (mmGet *mThingRepositoryMockGet) Calls() []*ThingRepositoryMockGetParams {
  1360. mmGet.mutex.RLock()
  1361. argCopy := make([]*ThingRepositoryMockGetParams, len(mmGet.callArgs))
  1362. copy(argCopy, mmGet.callArgs)
  1363. mmGet.mutex.RUnlock()
  1364. return argCopy
  1365. }
  1366. // MinimockGetDone returns true if the count of the Get invocations corresponds
  1367. // the number of defined expectations
  1368. func (m *ThingRepositoryMock) MinimockGetDone() bool {
  1369. if m.GetMock.optional {
  1370. // Optional methods provide '0 or more' call count restriction.
  1371. return true
  1372. }
  1373. for _, e := range m.GetMock.expectations {
  1374. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1375. return false
  1376. }
  1377. }
  1378. return m.GetMock.invocationsDone()
  1379. }
  1380. // MinimockGetInspect logs each unmet expectation
  1381. func (m *ThingRepositoryMock) MinimockGetInspect() {
  1382. for _, e := range m.GetMock.expectations {
  1383. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1384. m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *e.params)
  1385. }
  1386. }
  1387. afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
  1388. // if default expectation was set then invocations count should be greater than zero
  1389. if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
  1390. if m.GetMock.defaultExpectation.params == nil {
  1391. m.t.Error("Expected call to ThingRepositoryMock.Get")
  1392. } else {
  1393. m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  1394. }
  1395. }
  1396. // if func was set then invocations count should be greater than zero
  1397. if m.funcGet != nil && afterGetCounter < 1 {
  1398. m.t.Error("Expected call to ThingRepositoryMock.Get")
  1399. }
  1400. if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
  1401. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Get but found %d calls",
  1402. mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
  1403. }
  1404. }
  1405. type mThingRepositoryMockGetAllByPlaceID struct {
  1406. optional bool
  1407. mock *ThingRepositoryMock
  1408. defaultExpectation *ThingRepositoryMockGetAllByPlaceIDExpectation
  1409. expectations []*ThingRepositoryMockGetAllByPlaceIDExpectation
  1410. callArgs []*ThingRepositoryMockGetAllByPlaceIDParams
  1411. mutex sync.RWMutex
  1412. expectedInvocations uint64
  1413. }
  1414. // ThingRepositoryMockGetAllByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetAllByPlaceID
  1415. type ThingRepositoryMockGetAllByPlaceIDExpectation struct {
  1416. mock *ThingRepositoryMock
  1417. params *ThingRepositoryMockGetAllByPlaceIDParams
  1418. paramPtrs *ThingRepositoryMockGetAllByPlaceIDParamPtrs
  1419. results *ThingRepositoryMockGetAllByPlaceIDResults
  1420. Counter uint64
  1421. }
  1422. // ThingRepositoryMockGetAllByPlaceIDParams contains parameters of the ThingRepository.GetAllByPlaceID
  1423. type ThingRepositoryMockGetAllByPlaceIDParams struct {
  1424. ctx context.Context
  1425. placeID int
  1426. }
  1427. // ThingRepositoryMockGetAllByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetAllByPlaceID
  1428. type ThingRepositoryMockGetAllByPlaceIDParamPtrs struct {
  1429. ctx *context.Context
  1430. placeID *int
  1431. }
  1432. // ThingRepositoryMockGetAllByPlaceIDResults contains results of the ThingRepository.GetAllByPlaceID
  1433. type ThingRepositoryMockGetAllByPlaceIDResults struct {
  1434. ta1 []models.Thing
  1435. err error
  1436. }
  1437. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1438. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1439. // Optional() makes method check to work in '0 or more' mode.
  1440. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1441. // catch the problems when the expected method call is totally skipped during test run.
  1442. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Optional() *mThingRepositoryMockGetAllByPlaceID {
  1443. mmGetAllByPlaceID.optional = true
  1444. return mmGetAllByPlaceID
  1445. }
  1446. // Expect sets up expected params for ThingRepository.GetAllByPlaceID
  1447. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetAllByPlaceID {
  1448. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1449. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1450. }
  1451. if mmGetAllByPlaceID.defaultExpectation == nil {
  1452. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
  1453. }
  1454. if mmGetAllByPlaceID.defaultExpectation.paramPtrs != nil {
  1455. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by ExpectParams functions")
  1456. }
  1457. mmGetAllByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
  1458. for _, e := range mmGetAllByPlaceID.expectations {
  1459. if minimock.Equal(e.params, mmGetAllByPlaceID.defaultExpectation.params) {
  1460. mmGetAllByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllByPlaceID.defaultExpectation.params)
  1461. }
  1462. }
  1463. return mmGetAllByPlaceID
  1464. }
  1465. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetAllByPlaceID
  1466. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetAllByPlaceID {
  1467. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1468. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1469. }
  1470. if mmGetAllByPlaceID.defaultExpectation == nil {
  1471. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
  1472. }
  1473. if mmGetAllByPlaceID.defaultExpectation.params != nil {
  1474. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
  1475. }
  1476. if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
  1477. mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
  1478. }
  1479. mmGetAllByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
  1480. return mmGetAllByPlaceID
  1481. }
  1482. // ExpectPlaceIDParam2 sets up expected param placeID for ThingRepository.GetAllByPlaceID
  1483. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectPlaceIDParam2(placeID int) *mThingRepositoryMockGetAllByPlaceID {
  1484. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1485. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1486. }
  1487. if mmGetAllByPlaceID.defaultExpectation == nil {
  1488. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
  1489. }
  1490. if mmGetAllByPlaceID.defaultExpectation.params != nil {
  1491. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
  1492. }
  1493. if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
  1494. mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
  1495. }
  1496. mmGetAllByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID
  1497. return mmGetAllByPlaceID
  1498. }
  1499. // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetAllByPlaceID
  1500. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetAllByPlaceID {
  1501. if mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID != nil {
  1502. mmGetAllByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetAllByPlaceID")
  1503. }
  1504. mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID = f
  1505. return mmGetAllByPlaceID
  1506. }
  1507. // Return sets up results that will be returned by ThingRepository.GetAllByPlaceID
  1508. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1509. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1510. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1511. }
  1512. if mmGetAllByPlaceID.defaultExpectation == nil {
  1513. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{mock: mmGetAllByPlaceID.mock}
  1514. }
  1515. mmGetAllByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
  1516. return mmGetAllByPlaceID.mock
  1517. }
  1518. // Set uses given function f to mock the ThingRepository.GetAllByPlaceID method
  1519. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  1520. if mmGetAllByPlaceID.defaultExpectation != nil {
  1521. mmGetAllByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetAllByPlaceID method")
  1522. }
  1523. if len(mmGetAllByPlaceID.expectations) > 0 {
  1524. mmGetAllByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetAllByPlaceID method")
  1525. }
  1526. mmGetAllByPlaceID.mock.funcGetAllByPlaceID = f
  1527. return mmGetAllByPlaceID.mock
  1528. }
  1529. // When sets expectation for the ThingRepository.GetAllByPlaceID which will trigger the result defined by the following
  1530. // Then helper
  1531. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetAllByPlaceIDExpectation {
  1532. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1533. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1534. }
  1535. expectation := &ThingRepositoryMockGetAllByPlaceIDExpectation{
  1536. mock: mmGetAllByPlaceID.mock,
  1537. params: &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID},
  1538. }
  1539. mmGetAllByPlaceID.expectations = append(mmGetAllByPlaceID.expectations, expectation)
  1540. return expectation
  1541. }
  1542. // Then sets up ThingRepository.GetAllByPlaceID return parameters for the expectation previously defined by the When method
  1543. func (e *ThingRepositoryMockGetAllByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1544. e.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
  1545. return e.mock
  1546. }
  1547. // Times sets number of times ThingRepository.GetAllByPlaceID should be invoked
  1548. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Times(n uint64) *mThingRepositoryMockGetAllByPlaceID {
  1549. if n == 0 {
  1550. mmGetAllByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetAllByPlaceID mock can not be zero")
  1551. }
  1552. mm_atomic.StoreUint64(&mmGetAllByPlaceID.expectedInvocations, n)
  1553. return mmGetAllByPlaceID
  1554. }
  1555. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) invocationsDone() bool {
  1556. if len(mmGetAllByPlaceID.expectations) == 0 && mmGetAllByPlaceID.defaultExpectation == nil && mmGetAllByPlaceID.mock.funcGetAllByPlaceID == nil {
  1557. return true
  1558. }
  1559. totalInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.mock.afterGetAllByPlaceIDCounter)
  1560. expectedInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.expectedInvocations)
  1561. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1562. }
  1563. // GetAllByPlaceID implements thing.ThingRepository
  1564. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
  1565. mm_atomic.AddUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter, 1)
  1566. defer mm_atomic.AddUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter, 1)
  1567. if mmGetAllByPlaceID.inspectFuncGetAllByPlaceID != nil {
  1568. mmGetAllByPlaceID.inspectFuncGetAllByPlaceID(ctx, placeID)
  1569. }
  1570. mm_params := ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
  1571. // Record call args
  1572. mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Lock()
  1573. mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs = append(mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs, &mm_params)
  1574. mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Unlock()
  1575. for _, e := range mmGetAllByPlaceID.GetAllByPlaceIDMock.expectations {
  1576. if minimock.Equal(*e.params, mm_params) {
  1577. mm_atomic.AddUint64(&e.Counter, 1)
  1578. return e.results.ta1, e.results.err
  1579. }
  1580. }
  1581. if mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation != nil {
  1582. mm_atomic.AddUint64(&mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.Counter, 1)
  1583. mm_want := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.params
  1584. mm_want_ptrs := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.paramPtrs
  1585. mm_got := ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
  1586. if mm_want_ptrs != nil {
  1587. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1588. 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))
  1589. }
  1590. if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
  1591. 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))
  1592. }
  1593. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1594. mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1595. }
  1596. mm_results := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.results
  1597. if mm_results == nil {
  1598. mmGetAllByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetAllByPlaceID")
  1599. }
  1600. return (*mm_results).ta1, (*mm_results).err
  1601. }
  1602. if mmGetAllByPlaceID.funcGetAllByPlaceID != nil {
  1603. return mmGetAllByPlaceID.funcGetAllByPlaceID(ctx, placeID)
  1604. }
  1605. mmGetAllByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetAllByPlaceID. %v %v", ctx, placeID)
  1606. return
  1607. }
  1608. // GetAllByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetAllByPlaceID invocations
  1609. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDAfterCounter() uint64 {
  1610. return mm_atomic.LoadUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter)
  1611. }
  1612. // GetAllByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetAllByPlaceID invocations
  1613. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDBeforeCounter() uint64 {
  1614. return mm_atomic.LoadUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter)
  1615. }
  1616. // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetAllByPlaceID.
  1617. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1618. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Calls() []*ThingRepositoryMockGetAllByPlaceIDParams {
  1619. mmGetAllByPlaceID.mutex.RLock()
  1620. argCopy := make([]*ThingRepositoryMockGetAllByPlaceIDParams, len(mmGetAllByPlaceID.callArgs))
  1621. copy(argCopy, mmGetAllByPlaceID.callArgs)
  1622. mmGetAllByPlaceID.mutex.RUnlock()
  1623. return argCopy
  1624. }
  1625. // MinimockGetAllByPlaceIDDone returns true if the count of the GetAllByPlaceID invocations corresponds
  1626. // the number of defined expectations
  1627. func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDDone() bool {
  1628. if m.GetAllByPlaceIDMock.optional {
  1629. // Optional methods provide '0 or more' call count restriction.
  1630. return true
  1631. }
  1632. for _, e := range m.GetAllByPlaceIDMock.expectations {
  1633. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1634. return false
  1635. }
  1636. }
  1637. return m.GetAllByPlaceIDMock.invocationsDone()
  1638. }
  1639. // MinimockGetAllByPlaceIDInspect logs each unmet expectation
  1640. func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDInspect() {
  1641. for _, e := range m.GetAllByPlaceIDMock.expectations {
  1642. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1643. m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *e.params)
  1644. }
  1645. }
  1646. afterGetAllByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter)
  1647. // if default expectation was set then invocations count should be greater than zero
  1648. if m.GetAllByPlaceIDMock.defaultExpectation != nil && afterGetAllByPlaceIDCounter < 1 {
  1649. if m.GetAllByPlaceIDMock.defaultExpectation.params == nil {
  1650. m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
  1651. } else {
  1652. m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *m.GetAllByPlaceIDMock.defaultExpectation.params)
  1653. }
  1654. }
  1655. // if func was set then invocations count should be greater than zero
  1656. if m.funcGetAllByPlaceID != nil && afterGetAllByPlaceIDCounter < 1 {
  1657. m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
  1658. }
  1659. if !m.GetAllByPlaceIDMock.invocationsDone() && afterGetAllByPlaceIDCounter > 0 {
  1660. m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetAllByPlaceID but found %d calls",
  1661. mm_atomic.LoadUint64(&m.GetAllByPlaceIDMock.expectedInvocations), afterGetAllByPlaceIDCounter)
  1662. }
  1663. }
  1664. type mThingRepositoryMockGetByPlaceID struct {
  1665. optional bool
  1666. mock *ThingRepositoryMock
  1667. defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation
  1668. expectations []*ThingRepositoryMockGetByPlaceIDExpectation
  1669. callArgs []*ThingRepositoryMockGetByPlaceIDParams
  1670. mutex sync.RWMutex
  1671. expectedInvocations uint64
  1672. }
  1673. // ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID
  1674. type ThingRepositoryMockGetByPlaceIDExpectation struct {
  1675. mock *ThingRepositoryMock
  1676. params *ThingRepositoryMockGetByPlaceIDParams
  1677. paramPtrs *ThingRepositoryMockGetByPlaceIDParamPtrs
  1678. results *ThingRepositoryMockGetByPlaceIDResults
  1679. Counter uint64
  1680. }
  1681. // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
  1682. type ThingRepositoryMockGetByPlaceIDParams struct {
  1683. ctx context.Context
  1684. placeID int
  1685. }
  1686. // ThingRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetByPlaceID
  1687. type ThingRepositoryMockGetByPlaceIDParamPtrs struct {
  1688. ctx *context.Context
  1689. placeID *int
  1690. }
  1691. // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
  1692. type ThingRepositoryMockGetByPlaceIDResults struct {
  1693. ta1 []models.Thing
  1694. err error
  1695. }
  1696. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1697. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1698. // Optional() makes method check to work in '0 or more' mode.
  1699. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1700. // catch the problems when the expected method call is totally skipped during test run.
  1701. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Optional() *mThingRepositoryMockGetByPlaceID {
  1702. mmGetByPlaceID.optional = true
  1703. return mmGetByPlaceID
  1704. }
  1705. // Expect sets up expected params for ThingRepository.GetByPlaceID
  1706. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetByPlaceID {
  1707. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1708. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1709. }
  1710. if mmGetByPlaceID.defaultExpectation == nil {
  1711. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  1712. }
  1713. if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
  1714. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
  1715. }
  1716. mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
  1717. for _, e := range mmGetByPlaceID.expectations {
  1718. if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
  1719. mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
  1720. }
  1721. }
  1722. return mmGetByPlaceID
  1723. }
  1724. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetByPlaceID
  1725. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetByPlaceID {
  1726. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1727. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1728. }
  1729. if mmGetByPlaceID.defaultExpectation == nil {
  1730. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  1731. }
  1732. if mmGetByPlaceID.defaultExpectation.params != nil {
  1733. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
  1734. }
  1735. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  1736. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
  1737. }
  1738. mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
  1739. return mmGetByPlaceID
  1740. }
  1741. // ExpectPlaceIDParam2 sets up expected param placeID for ThingRepository.GetByPlaceID
  1742. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectPlaceIDParam2(placeID int) *mThingRepositoryMockGetByPlaceID {
  1743. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1744. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1745. }
  1746. if mmGetByPlaceID.defaultExpectation == nil {
  1747. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  1748. }
  1749. if mmGetByPlaceID.defaultExpectation.params != nil {
  1750. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
  1751. }
  1752. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  1753. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
  1754. }
  1755. mmGetByPlaceID.defaultExpectation.paramPtrs.placeID = &placeID
  1756. return mmGetByPlaceID
  1757. }
  1758. // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
  1759. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetByPlaceID {
  1760. if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
  1761. mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
  1762. }
  1763. mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
  1764. return mmGetByPlaceID
  1765. }
  1766. // Return sets up results that will be returned by ThingRepository.GetByPlaceID
  1767. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1768. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1769. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1770. }
  1771. if mmGetByPlaceID.defaultExpectation == nil {
  1772. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
  1773. }
  1774. mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  1775. return mmGetByPlaceID.mock
  1776. }
  1777. // Set uses given function f to mock the ThingRepository.GetByPlaceID method
  1778. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  1779. if mmGetByPlaceID.defaultExpectation != nil {
  1780. mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
  1781. }
  1782. if len(mmGetByPlaceID.expectations) > 0 {
  1783. mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method")
  1784. }
  1785. mmGetByPlaceID.mock.funcGetByPlaceID = f
  1786. return mmGetByPlaceID.mock
  1787. }
  1788. // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
  1789. // Then helper
  1790. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetByPlaceIDExpectation {
  1791. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1792. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1793. }
  1794. expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
  1795. mock: mmGetByPlaceID.mock,
  1796. params: &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID},
  1797. }
  1798. mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
  1799. return expectation
  1800. }
  1801. // Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
  1802. func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1803. e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  1804. return e.mock
  1805. }
  1806. // Times sets number of times ThingRepository.GetByPlaceID should be invoked
  1807. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Times(n uint64) *mThingRepositoryMockGetByPlaceID {
  1808. if n == 0 {
  1809. mmGetByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetByPlaceID mock can not be zero")
  1810. }
  1811. mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
  1812. return mmGetByPlaceID
  1813. }
  1814. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) invocationsDone() bool {
  1815. if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
  1816. return true
  1817. }
  1818. totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
  1819. expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)
  1820. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1821. }
  1822. // GetByPlaceID implements thing.ThingRepository
  1823. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
  1824. mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
  1825. defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
  1826. if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
  1827. mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID)
  1828. }
  1829. mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
  1830. // Record call args
  1831. mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
  1832. mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
  1833. mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
  1834. for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
  1835. if minimock.Equal(*e.params, mm_params) {
  1836. mm_atomic.AddUint64(&e.Counter, 1)
  1837. return e.results.ta1, e.results.err
  1838. }
  1839. }
  1840. if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
  1841. mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
  1842. mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
  1843. mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
  1844. mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
  1845. if mm_want_ptrs != nil {
  1846. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1847. 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))
  1848. }
  1849. if mm_want_ptrs.placeID != nil && !minimock.Equal(*mm_want_ptrs.placeID, mm_got.placeID) {
  1850. 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))
  1851. }
  1852. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1853. mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1854. }
  1855. mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
  1856. if mm_results == nil {
  1857. mmGetByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetByPlaceID")
  1858. }
  1859. return (*mm_results).ta1, (*mm_results).err
  1860. }
  1861. if mmGetByPlaceID.funcGetByPlaceID != nil {
  1862. return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID)
  1863. }
  1864. mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, placeID)
  1865. return
  1866. }
  1867. // GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations
  1868. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
  1869. return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
  1870. }
  1871. // GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations
  1872. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
  1873. return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
  1874. }
  1875. // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID.
  1876. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1877. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams {
  1878. mmGetByPlaceID.mutex.RLock()
  1879. argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
  1880. copy(argCopy, mmGetByPlaceID.callArgs)
  1881. mmGetByPlaceID.mutex.RUnlock()
  1882. return argCopy
  1883. }
  1884. // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
  1885. // the number of defined expectations
  1886. func (m *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool {
  1887. if m.GetByPlaceIDMock.optional {
  1888. // Optional methods provide '0 or more' call count restriction.
  1889. return true
  1890. }
  1891. for _, e := range m.GetByPlaceIDMock.expectations {
  1892. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1893. return false
  1894. }
  1895. }
  1896. return m.GetByPlaceIDMock.invocationsDone()
  1897. }
  1898. // MinimockGetByPlaceIDInspect logs each unmet expectation
  1899. func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() {
  1900. for _, e := range m.GetByPlaceIDMock.expectations {
  1901. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1902. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params)
  1903. }
  1904. }
  1905. afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
  1906. // if default expectation was set then invocations count should be greater than zero
  1907. if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
  1908. if m.GetByPlaceIDMock.defaultExpectation.params == nil {
  1909. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  1910. } else {
  1911. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
  1912. }
  1913. }
  1914. // if func was set then invocations count should be greater than zero
  1915. if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
  1916. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  1917. }
  1918. if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
  1919. m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetByPlaceID but found %d calls",
  1920. mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
  1921. }
  1922. }
  1923. type mThingRepositoryMockSearch struct {
  1924. optional bool
  1925. mock *ThingRepositoryMock
  1926. defaultExpectation *ThingRepositoryMockSearchExpectation
  1927. expectations []*ThingRepositoryMockSearchExpectation
  1928. callArgs []*ThingRepositoryMockSearchParams
  1929. mutex sync.RWMutex
  1930. expectedInvocations uint64
  1931. }
  1932. // ThingRepositoryMockSearchExpectation specifies expectation struct of the ThingRepository.Search
  1933. type ThingRepositoryMockSearchExpectation struct {
  1934. mock *ThingRepositoryMock
  1935. params *ThingRepositoryMockSearchParams
  1936. paramPtrs *ThingRepositoryMockSearchParamPtrs
  1937. results *ThingRepositoryMockSearchResults
  1938. Counter uint64
  1939. }
  1940. // ThingRepositoryMockSearchParams contains parameters of the ThingRepository.Search
  1941. type ThingRepositoryMockSearchParams struct {
  1942. ctx context.Context
  1943. search string
  1944. }
  1945. // ThingRepositoryMockSearchParamPtrs contains pointers to parameters of the ThingRepository.Search
  1946. type ThingRepositoryMockSearchParamPtrs struct {
  1947. ctx *context.Context
  1948. search *string
  1949. }
  1950. // ThingRepositoryMockSearchResults contains results of the ThingRepository.Search
  1951. type ThingRepositoryMockSearchResults struct {
  1952. ta1 []models.Thing
  1953. err error
  1954. }
  1955. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1956. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1957. // Optional() makes method check to work in '0 or more' mode.
  1958. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1959. // catch the problems when the expected method call is totally skipped during test run.
  1960. func (mmSearch *mThingRepositoryMockSearch) Optional() *mThingRepositoryMockSearch {
  1961. mmSearch.optional = true
  1962. return mmSearch
  1963. }
  1964. // Expect sets up expected params for ThingRepository.Search
  1965. func (mmSearch *mThingRepositoryMockSearch) Expect(ctx context.Context, search string) *mThingRepositoryMockSearch {
  1966. if mmSearch.mock.funcSearch != nil {
  1967. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1968. }
  1969. if mmSearch.defaultExpectation == nil {
  1970. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
  1971. }
  1972. if mmSearch.defaultExpectation.paramPtrs != nil {
  1973. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by ExpectParams functions")
  1974. }
  1975. mmSearch.defaultExpectation.params = &ThingRepositoryMockSearchParams{ctx, search}
  1976. for _, e := range mmSearch.expectations {
  1977. if minimock.Equal(e.params, mmSearch.defaultExpectation.params) {
  1978. mmSearch.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSearch.defaultExpectation.params)
  1979. }
  1980. }
  1981. return mmSearch
  1982. }
  1983. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Search
  1984. func (mmSearch *mThingRepositoryMockSearch) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockSearch {
  1985. if mmSearch.mock.funcSearch != nil {
  1986. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1987. }
  1988. if mmSearch.defaultExpectation == nil {
  1989. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
  1990. }
  1991. if mmSearch.defaultExpectation.params != nil {
  1992. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
  1993. }
  1994. if mmSearch.defaultExpectation.paramPtrs == nil {
  1995. mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
  1996. }
  1997. mmSearch.defaultExpectation.paramPtrs.ctx = &ctx
  1998. return mmSearch
  1999. }
  2000. // ExpectSearchParam2 sets up expected param search for ThingRepository.Search
  2001. func (mmSearch *mThingRepositoryMockSearch) ExpectSearchParam2(search string) *mThingRepositoryMockSearch {
  2002. if mmSearch.mock.funcSearch != nil {
  2003. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  2004. }
  2005. if mmSearch.defaultExpectation == nil {
  2006. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
  2007. }
  2008. if mmSearch.defaultExpectation.params != nil {
  2009. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
  2010. }
  2011. if mmSearch.defaultExpectation.paramPtrs == nil {
  2012. mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
  2013. }
  2014. mmSearch.defaultExpectation.paramPtrs.search = &search
  2015. return mmSearch
  2016. }
  2017. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Search
  2018. func (mmSearch *mThingRepositoryMockSearch) Inspect(f func(ctx context.Context, search string)) *mThingRepositoryMockSearch {
  2019. if mmSearch.mock.inspectFuncSearch != nil {
  2020. mmSearch.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Search")
  2021. }
  2022. mmSearch.mock.inspectFuncSearch = f
  2023. return mmSearch
  2024. }
  2025. // Return sets up results that will be returned by ThingRepository.Search
  2026. func (mmSearch *mThingRepositoryMockSearch) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  2027. if mmSearch.mock.funcSearch != nil {
  2028. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  2029. }
  2030. if mmSearch.defaultExpectation == nil {
  2031. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{mock: mmSearch.mock}
  2032. }
  2033. mmSearch.defaultExpectation.results = &ThingRepositoryMockSearchResults{ta1, err}
  2034. return mmSearch.mock
  2035. }
  2036. // Set uses given function f to mock the ThingRepository.Search method
  2037. func (mmSearch *mThingRepositoryMockSearch) Set(f func(ctx context.Context, search string) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  2038. if mmSearch.defaultExpectation != nil {
  2039. mmSearch.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Search method")
  2040. }
  2041. if len(mmSearch.expectations) > 0 {
  2042. mmSearch.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Search method")
  2043. }
  2044. mmSearch.mock.funcSearch = f
  2045. return mmSearch.mock
  2046. }
  2047. // When sets expectation for the ThingRepository.Search which will trigger the result defined by the following
  2048. // Then helper
  2049. func (mmSearch *mThingRepositoryMockSearch) When(ctx context.Context, search string) *ThingRepositoryMockSearchExpectation {
  2050. if mmSearch.mock.funcSearch != nil {
  2051. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  2052. }
  2053. expectation := &ThingRepositoryMockSearchExpectation{
  2054. mock: mmSearch.mock,
  2055. params: &ThingRepositoryMockSearchParams{ctx, search},
  2056. }
  2057. mmSearch.expectations = append(mmSearch.expectations, expectation)
  2058. return expectation
  2059. }
  2060. // Then sets up ThingRepository.Search return parameters for the expectation previously defined by the When method
  2061. func (e *ThingRepositoryMockSearchExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  2062. e.results = &ThingRepositoryMockSearchResults{ta1, err}
  2063. return e.mock
  2064. }
  2065. // Times sets number of times ThingRepository.Search should be invoked
  2066. func (mmSearch *mThingRepositoryMockSearch) Times(n uint64) *mThingRepositoryMockSearch {
  2067. if n == 0 {
  2068. mmSearch.mock.t.Fatalf("Times of ThingRepositoryMock.Search mock can not be zero")
  2069. }
  2070. mm_atomic.StoreUint64(&mmSearch.expectedInvocations, n)
  2071. return mmSearch
  2072. }
  2073. func (mmSearch *mThingRepositoryMockSearch) invocationsDone() bool {
  2074. if len(mmSearch.expectations) == 0 && mmSearch.defaultExpectation == nil && mmSearch.mock.funcSearch == nil {
  2075. return true
  2076. }
  2077. totalInvocations := mm_atomic.LoadUint64(&mmSearch.mock.afterSearchCounter)
  2078. expectedInvocations := mm_atomic.LoadUint64(&mmSearch.expectedInvocations)
  2079. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  2080. }
  2081. // Search implements thing.ThingRepository
  2082. func (mmSearch *ThingRepositoryMock) Search(ctx context.Context, search string) (ta1 []models.Thing, err error) {
  2083. mm_atomic.AddUint64(&mmSearch.beforeSearchCounter, 1)
  2084. defer mm_atomic.AddUint64(&mmSearch.afterSearchCounter, 1)
  2085. if mmSearch.inspectFuncSearch != nil {
  2086. mmSearch.inspectFuncSearch(ctx, search)
  2087. }
  2088. mm_params := ThingRepositoryMockSearchParams{ctx, search}
  2089. // Record call args
  2090. mmSearch.SearchMock.mutex.Lock()
  2091. mmSearch.SearchMock.callArgs = append(mmSearch.SearchMock.callArgs, &mm_params)
  2092. mmSearch.SearchMock.mutex.Unlock()
  2093. for _, e := range mmSearch.SearchMock.expectations {
  2094. if minimock.Equal(*e.params, mm_params) {
  2095. mm_atomic.AddUint64(&e.Counter, 1)
  2096. return e.results.ta1, e.results.err
  2097. }
  2098. }
  2099. if mmSearch.SearchMock.defaultExpectation != nil {
  2100. mm_atomic.AddUint64(&mmSearch.SearchMock.defaultExpectation.Counter, 1)
  2101. mm_want := mmSearch.SearchMock.defaultExpectation.params
  2102. mm_want_ptrs := mmSearch.SearchMock.defaultExpectation.paramPtrs
  2103. mm_got := ThingRepositoryMockSearchParams{ctx, search}
  2104. if mm_want_ptrs != nil {
  2105. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  2106. 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))
  2107. }
  2108. if mm_want_ptrs.search != nil && !minimock.Equal(*mm_want_ptrs.search, mm_got.search) {
  2109. 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))
  2110. }
  2111. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  2112. mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  2113. }
  2114. mm_results := mmSearch.SearchMock.defaultExpectation.results
  2115. if mm_results == nil {
  2116. mmSearch.t.Fatal("No results are set for the ThingRepositoryMock.Search")
  2117. }
  2118. return (*mm_results).ta1, (*mm_results).err
  2119. }
  2120. if mmSearch.funcSearch != nil {
  2121. return mmSearch.funcSearch(ctx, search)
  2122. }
  2123. mmSearch.t.Fatalf("Unexpected call to ThingRepositoryMock.Search. %v %v", ctx, search)
  2124. return
  2125. }
  2126. // SearchAfterCounter returns a count of finished ThingRepositoryMock.Search invocations
  2127. func (mmSearch *ThingRepositoryMock) SearchAfterCounter() uint64 {
  2128. return mm_atomic.LoadUint64(&mmSearch.afterSearchCounter)
  2129. }
  2130. // SearchBeforeCounter returns a count of ThingRepositoryMock.Search invocations
  2131. func (mmSearch *ThingRepositoryMock) SearchBeforeCounter() uint64 {
  2132. return mm_atomic.LoadUint64(&mmSearch.beforeSearchCounter)
  2133. }
  2134. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Search.
  2135. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  2136. func (mmSearch *mThingRepositoryMockSearch) Calls() []*ThingRepositoryMockSearchParams {
  2137. mmSearch.mutex.RLock()
  2138. argCopy := make([]*ThingRepositoryMockSearchParams, len(mmSearch.callArgs))
  2139. copy(argCopy, mmSearch.callArgs)
  2140. mmSearch.mutex.RUnlock()
  2141. return argCopy
  2142. }
  2143. // MinimockSearchDone returns true if the count of the Search invocations corresponds
  2144. // the number of defined expectations
  2145. func (m *ThingRepositoryMock) MinimockSearchDone() bool {
  2146. if m.SearchMock.optional {
  2147. // Optional methods provide '0 or more' call count restriction.
  2148. return true
  2149. }
  2150. for _, e := range m.SearchMock.expectations {
  2151. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  2152. return false
  2153. }
  2154. }
  2155. return m.SearchMock.invocationsDone()
  2156. }
  2157. // MinimockSearchInspect logs each unmet expectation
  2158. func (m *ThingRepositoryMock) MinimockSearchInspect() {
  2159. for _, e := range m.SearchMock.expectations {
  2160. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  2161. m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *e.params)
  2162. }
  2163. }
  2164. afterSearchCounter := mm_atomic.LoadUint64(&m.afterSearchCounter)
  2165. // if default expectation was set then invocations count should be greater than zero
  2166. if m.SearchMock.defaultExpectation != nil && afterSearchCounter < 1 {
  2167. if m.SearchMock.defaultExpectation.params == nil {
  2168. m.t.Error("Expected call to ThingRepositoryMock.Search")
  2169. } else {
  2170. m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *m.SearchMock.defaultExpectation.params)
  2171. }
  2172. }
  2173. // if func was set then invocations count should be greater than zero
  2174. if m.funcSearch != nil && afterSearchCounter < 1 {
  2175. m.t.Error("Expected call to ThingRepositoryMock.Search")
  2176. }
  2177. if !m.SearchMock.invocationsDone() && afterSearchCounter > 0 {
  2178. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Search but found %d calls",
  2179. mm_atomic.LoadUint64(&m.SearchMock.expectedInvocations), afterSearchCounter)
  2180. }
  2181. }
  2182. type mThingRepositoryMockUpdate struct {
  2183. optional bool
  2184. mock *ThingRepositoryMock
  2185. defaultExpectation *ThingRepositoryMockUpdateExpectation
  2186. expectations []*ThingRepositoryMockUpdateExpectation
  2187. callArgs []*ThingRepositoryMockUpdateParams
  2188. mutex sync.RWMutex
  2189. expectedInvocations uint64
  2190. }
  2191. // ThingRepositoryMockUpdateExpectation specifies expectation struct of the ThingRepository.Update
  2192. type ThingRepositoryMockUpdateExpectation struct {
  2193. mock *ThingRepositoryMock
  2194. params *ThingRepositoryMockUpdateParams
  2195. paramPtrs *ThingRepositoryMockUpdateParamPtrs
  2196. results *ThingRepositoryMockUpdateResults
  2197. Counter uint64
  2198. }
  2199. // ThingRepositoryMockUpdateParams contains parameters of the ThingRepository.Update
  2200. type ThingRepositoryMockUpdateParams struct {
  2201. ctx context.Context
  2202. req models.UpdateThingRequest
  2203. tx *sql.Tx
  2204. }
  2205. // ThingRepositoryMockUpdateParamPtrs contains pointers to parameters of the ThingRepository.Update
  2206. type ThingRepositoryMockUpdateParamPtrs struct {
  2207. ctx *context.Context
  2208. req *models.UpdateThingRequest
  2209. tx **sql.Tx
  2210. }
  2211. // ThingRepositoryMockUpdateResults contains results of the ThingRepository.Update
  2212. type ThingRepositoryMockUpdateResults struct {
  2213. err error
  2214. }
  2215. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  2216. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  2217. // Optional() makes method check to work in '0 or more' mode.
  2218. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  2219. // catch the problems when the expected method call is totally skipped during test run.
  2220. func (mmUpdate *mThingRepositoryMockUpdate) Optional() *mThingRepositoryMockUpdate {
  2221. mmUpdate.optional = true
  2222. return mmUpdate
  2223. }
  2224. // Expect sets up expected params for ThingRepository.Update
  2225. func (mmUpdate *mThingRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *mThingRepositoryMockUpdate {
  2226. if mmUpdate.mock.funcUpdate != nil {
  2227. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  2228. }
  2229. if mmUpdate.defaultExpectation == nil {
  2230. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  2231. }
  2232. if mmUpdate.defaultExpectation.paramPtrs != nil {
  2233. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by ExpectParams functions")
  2234. }
  2235. mmUpdate.defaultExpectation.params = &ThingRepositoryMockUpdateParams{ctx, req, tx}
  2236. for _, e := range mmUpdate.expectations {
  2237. if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
  2238. mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
  2239. }
  2240. }
  2241. return mmUpdate
  2242. }
  2243. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Update
  2244. func (mmUpdate *mThingRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockUpdate {
  2245. if mmUpdate.mock.funcUpdate != nil {
  2246. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  2247. }
  2248. if mmUpdate.defaultExpectation == nil {
  2249. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  2250. }
  2251. if mmUpdate.defaultExpectation.params != nil {
  2252. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
  2253. }
  2254. if mmUpdate.defaultExpectation.paramPtrs == nil {
  2255. mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
  2256. }
  2257. mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx
  2258. return mmUpdate
  2259. }
  2260. // ExpectReqParam2 sets up expected param req for ThingRepository.Update
  2261. func (mmUpdate *mThingRepositoryMockUpdate) ExpectReqParam2(req models.UpdateThingRequest) *mThingRepositoryMockUpdate {
  2262. if mmUpdate.mock.funcUpdate != nil {
  2263. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  2264. }
  2265. if mmUpdate.defaultExpectation == nil {
  2266. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  2267. }
  2268. if mmUpdate.defaultExpectation.params != nil {
  2269. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
  2270. }
  2271. if mmUpdate.defaultExpectation.paramPtrs == nil {
  2272. mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
  2273. }
  2274. mmUpdate.defaultExpectation.paramPtrs.req = &req
  2275. return mmUpdate
  2276. }
  2277. // ExpectTxParam3 sets up expected param tx for ThingRepository.Update
  2278. func (mmUpdate *mThingRepositoryMockUpdate) ExpectTxParam3(tx *sql.Tx) *mThingRepositoryMockUpdate {
  2279. if mmUpdate.mock.funcUpdate != nil {
  2280. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  2281. }
  2282. if mmUpdate.defaultExpectation == nil {
  2283. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  2284. }
  2285. if mmUpdate.defaultExpectation.params != nil {
  2286. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
  2287. }
  2288. if mmUpdate.defaultExpectation.paramPtrs == nil {
  2289. mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
  2290. }
  2291. mmUpdate.defaultExpectation.paramPtrs.tx = &tx
  2292. return mmUpdate
  2293. }
  2294. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Update
  2295. func (mmUpdate *mThingRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)) *mThingRepositoryMockUpdate {
  2296. if mmUpdate.mock.inspectFuncUpdate != nil {
  2297. mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Update")
  2298. }
  2299. mmUpdate.mock.inspectFuncUpdate = f
  2300. return mmUpdate
  2301. }
  2302. // Return sets up results that will be returned by ThingRepository.Update
  2303. func (mmUpdate *mThingRepositoryMockUpdate) Return(err error) *ThingRepositoryMock {
  2304. if mmUpdate.mock.funcUpdate != nil {
  2305. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  2306. }
  2307. if mmUpdate.defaultExpectation == nil {
  2308. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
  2309. }
  2310. mmUpdate.defaultExpectation.results = &ThingRepositoryMockUpdateResults{err}
  2311. return mmUpdate.mock
  2312. }
  2313. // Set uses given function f to mock the ThingRepository.Update method
  2314. func (mmUpdate *mThingRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)) *ThingRepositoryMock {
  2315. if mmUpdate.defaultExpectation != nil {
  2316. mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Update method")
  2317. }
  2318. if len(mmUpdate.expectations) > 0 {
  2319. mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Update method")
  2320. }
  2321. mmUpdate.mock.funcUpdate = f
  2322. return mmUpdate.mock
  2323. }
  2324. // When sets expectation for the ThingRepository.Update which will trigger the result defined by the following
  2325. // Then helper
  2326. func (mmUpdate *mThingRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *ThingRepositoryMockUpdateExpectation {
  2327. if mmUpdate.mock.funcUpdate != nil {
  2328. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  2329. }
  2330. expectation := &ThingRepositoryMockUpdateExpectation{
  2331. mock: mmUpdate.mock,
  2332. params: &ThingRepositoryMockUpdateParams{ctx, req, tx},
  2333. }
  2334. mmUpdate.expectations = append(mmUpdate.expectations, expectation)
  2335. return expectation
  2336. }
  2337. // Then sets up ThingRepository.Update return parameters for the expectation previously defined by the When method
  2338. func (e *ThingRepositoryMockUpdateExpectation) Then(err error) *ThingRepositoryMock {
  2339. e.results = &ThingRepositoryMockUpdateResults{err}
  2340. return e.mock
  2341. }
  2342. // Times sets number of times ThingRepository.Update should be invoked
  2343. func (mmUpdate *mThingRepositoryMockUpdate) Times(n uint64) *mThingRepositoryMockUpdate {
  2344. if n == 0 {
  2345. mmUpdate.mock.t.Fatalf("Times of ThingRepositoryMock.Update mock can not be zero")
  2346. }
  2347. mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
  2348. return mmUpdate
  2349. }
  2350. func (mmUpdate *mThingRepositoryMockUpdate) invocationsDone() bool {
  2351. if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
  2352. return true
  2353. }
  2354. totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
  2355. expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)
  2356. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  2357. }
  2358. // Update implements thing.ThingRepository
  2359. func (mmUpdate *ThingRepositoryMock) Update(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error) {
  2360. mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
  2361. defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
  2362. if mmUpdate.inspectFuncUpdate != nil {
  2363. mmUpdate.inspectFuncUpdate(ctx, req, tx)
  2364. }
  2365. mm_params := ThingRepositoryMockUpdateParams{ctx, req, tx}
  2366. // Record call args
  2367. mmUpdate.UpdateMock.mutex.Lock()
  2368. mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, &mm_params)
  2369. mmUpdate.UpdateMock.mutex.Unlock()
  2370. for _, e := range mmUpdate.UpdateMock.expectations {
  2371. if minimock.Equal(*e.params, mm_params) {
  2372. mm_atomic.AddUint64(&e.Counter, 1)
  2373. return e.results.err
  2374. }
  2375. }
  2376. if mmUpdate.UpdateMock.defaultExpectation != nil {
  2377. mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
  2378. mm_want := mmUpdate.UpdateMock.defaultExpectation.params
  2379. mm_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs
  2380. mm_got := ThingRepositoryMockUpdateParams{ctx, req, tx}
  2381. if mm_want_ptrs != nil {
  2382. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  2383. 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))
  2384. }
  2385. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  2386. 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))
  2387. }
  2388. if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
  2389. 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))
  2390. }
  2391. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  2392. mmUpdate.t.Errorf("ThingRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  2393. }
  2394. mm_results := mmUpdate.UpdateMock.defaultExpectation.results
  2395. if mm_results == nil {
  2396. mmUpdate.t.Fatal("No results are set for the ThingRepositoryMock.Update")
  2397. }
  2398. return (*mm_results).err
  2399. }
  2400. if mmUpdate.funcUpdate != nil {
  2401. return mmUpdate.funcUpdate(ctx, req, tx)
  2402. }
  2403. mmUpdate.t.Fatalf("Unexpected call to ThingRepositoryMock.Update. %v %v %v", ctx, req, tx)
  2404. return
  2405. }
  2406. // UpdateAfterCounter returns a count of finished ThingRepositoryMock.Update invocations
  2407. func (mmUpdate *ThingRepositoryMock) UpdateAfterCounter() uint64 {
  2408. return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
  2409. }
  2410. // UpdateBeforeCounter returns a count of ThingRepositoryMock.Update invocations
  2411. func (mmUpdate *ThingRepositoryMock) UpdateBeforeCounter() uint64 {
  2412. return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
  2413. }
  2414. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Update.
  2415. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  2416. func (mmUpdate *mThingRepositoryMockUpdate) Calls() []*ThingRepositoryMockUpdateParams {
  2417. mmUpdate.mutex.RLock()
  2418. argCopy := make([]*ThingRepositoryMockUpdateParams, len(mmUpdate.callArgs))
  2419. copy(argCopy, mmUpdate.callArgs)
  2420. mmUpdate.mutex.RUnlock()
  2421. return argCopy
  2422. }
  2423. // MinimockUpdateDone returns true if the count of the Update invocations corresponds
  2424. // the number of defined expectations
  2425. func (m *ThingRepositoryMock) MinimockUpdateDone() bool {
  2426. if m.UpdateMock.optional {
  2427. // Optional methods provide '0 or more' call count restriction.
  2428. return true
  2429. }
  2430. for _, e := range m.UpdateMock.expectations {
  2431. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  2432. return false
  2433. }
  2434. }
  2435. return m.UpdateMock.invocationsDone()
  2436. }
  2437. // MinimockUpdateInspect logs each unmet expectation
  2438. func (m *ThingRepositoryMock) MinimockUpdateInspect() {
  2439. for _, e := range m.UpdateMock.expectations {
  2440. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  2441. m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *e.params)
  2442. }
  2443. }
  2444. afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
  2445. // if default expectation was set then invocations count should be greater than zero
  2446. if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
  2447. if m.UpdateMock.defaultExpectation.params == nil {
  2448. m.t.Error("Expected call to ThingRepositoryMock.Update")
  2449. } else {
  2450. m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
  2451. }
  2452. }
  2453. // if func was set then invocations count should be greater than zero
  2454. if m.funcUpdate != nil && afterUpdateCounter < 1 {
  2455. m.t.Error("Expected call to ThingRepositoryMock.Update")
  2456. }
  2457. if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
  2458. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Update but found %d calls",
  2459. mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
  2460. }
  2461. }
  2462. // MinimockFinish checks that all mocked methods have been called the expected number of times
  2463. func (m *ThingRepositoryMock) MinimockFinish() {
  2464. m.finishOnce.Do(func() {
  2465. if !m.minimockDone() {
  2466. m.MinimockAddInspect()
  2467. m.MinimockBeginTxInspect()
  2468. m.MinimockCommitTxInspect()
  2469. m.MinimockDeleteInspect()
  2470. m.MinimockGetInspect()
  2471. m.MinimockGetAllByPlaceIDInspect()
  2472. m.MinimockGetByPlaceIDInspect()
  2473. m.MinimockSearchInspect()
  2474. m.MinimockUpdateInspect()
  2475. }
  2476. })
  2477. }
  2478. // MinimockWait waits for all mocked methods to be called the expected number of times
  2479. func (m *ThingRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  2480. timeoutCh := mm_time.After(timeout)
  2481. for {
  2482. if m.minimockDone() {
  2483. return
  2484. }
  2485. select {
  2486. case <-timeoutCh:
  2487. m.MinimockFinish()
  2488. return
  2489. case <-mm_time.After(10 * mm_time.Millisecond):
  2490. }
  2491. }
  2492. }
  2493. func (m *ThingRepositoryMock) minimockDone() bool {
  2494. done := true
  2495. return done &&
  2496. m.MinimockAddDone() &&
  2497. m.MinimockBeginTxDone() &&
  2498. m.MinimockCommitTxDone() &&
  2499. m.MinimockDeleteDone() &&
  2500. m.MinimockGetDone() &&
  2501. m.MinimockGetAllByPlaceIDDone() &&
  2502. m.MinimockGetByPlaceIDDone() &&
  2503. m.MinimockSearchDone() &&
  2504. m.MinimockUpdateDone()
  2505. }