thing_repository_minimock.go 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391
  1. // Code generated by http://github.com/gojuno/minimock (v3.3.14). 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. "sync"
  7. mm_atomic "sync/atomic"
  8. mm_time "time"
  9. "git.dmitriygnatenko.ru/dima/homethings/internal/models"
  10. "github.com/gojuno/minimock/v3"
  11. )
  12. // ThingRepositoryMock implements thing.ThingRepository
  13. type ThingRepositoryMock struct {
  14. t minimock.Tester
  15. finishOnce sync.Once
  16. funcAdd func(ctx context.Context, req models.AddThingRequest) (u1 uint64, err error)
  17. inspectFuncAdd func(ctx context.Context, req models.AddThingRequest)
  18. afterAddCounter uint64
  19. beforeAddCounter uint64
  20. AddMock mThingRepositoryMockAdd
  21. funcDelete func(ctx context.Context, id uint64) (err error)
  22. inspectFuncDelete func(ctx context.Context, id uint64)
  23. afterDeleteCounter uint64
  24. beforeDeleteCounter uint64
  25. DeleteMock mThingRepositoryMockDelete
  26. funcGet func(ctx context.Context, id uint64) (tp1 *models.Thing, err error)
  27. inspectFuncGet func(ctx context.Context, id uint64)
  28. afterGetCounter uint64
  29. beforeGetCounter uint64
  30. GetMock mThingRepositoryMockGet
  31. funcGetAllByPlaceID func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)
  32. inspectFuncGetAllByPlaceID func(ctx context.Context, id uint64)
  33. afterGetAllByPlaceIDCounter uint64
  34. beforeGetAllByPlaceIDCounter uint64
  35. GetAllByPlaceIDMock mThingRepositoryMockGetAllByPlaceID
  36. funcGetByPlaceID func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)
  37. inspectFuncGetByPlaceID func(ctx context.Context, id uint64)
  38. afterGetByPlaceIDCounter uint64
  39. beforeGetByPlaceIDCounter uint64
  40. GetByPlaceIDMock mThingRepositoryMockGetByPlaceID
  41. funcSearch func(ctx context.Context, search string) (ta1 []models.Thing, err error)
  42. inspectFuncSearch func(ctx context.Context, search string)
  43. afterSearchCounter uint64
  44. beforeSearchCounter uint64
  45. SearchMock mThingRepositoryMockSearch
  46. funcUpdate func(ctx context.Context, req models.UpdateThingRequest) (err error)
  47. inspectFuncUpdate func(ctx context.Context, req models.UpdateThingRequest)
  48. afterUpdateCounter uint64
  49. beforeUpdateCounter uint64
  50. UpdateMock mThingRepositoryMockUpdate
  51. }
  52. // NewThingRepositoryMock returns a mock for thing.ThingRepository
  53. func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock {
  54. m := &ThingRepositoryMock{t: t}
  55. if controller, ok := t.(minimock.MockController); ok {
  56. controller.RegisterMocker(m)
  57. }
  58. m.AddMock = mThingRepositoryMockAdd{mock: m}
  59. m.AddMock.callArgs = []*ThingRepositoryMockAddParams{}
  60. m.DeleteMock = mThingRepositoryMockDelete{mock: m}
  61. m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{}
  62. m.GetMock = mThingRepositoryMockGet{mock: m}
  63. m.GetMock.callArgs = []*ThingRepositoryMockGetParams{}
  64. m.GetAllByPlaceIDMock = mThingRepositoryMockGetAllByPlaceID{mock: m}
  65. m.GetAllByPlaceIDMock.callArgs = []*ThingRepositoryMockGetAllByPlaceIDParams{}
  66. m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m}
  67. m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{}
  68. m.SearchMock = mThingRepositoryMockSearch{mock: m}
  69. m.SearchMock.callArgs = []*ThingRepositoryMockSearchParams{}
  70. m.UpdateMock = mThingRepositoryMockUpdate{mock: m}
  71. m.UpdateMock.callArgs = []*ThingRepositoryMockUpdateParams{}
  72. t.Cleanup(m.MinimockFinish)
  73. return m
  74. }
  75. type mThingRepositoryMockAdd struct {
  76. optional bool
  77. mock *ThingRepositoryMock
  78. defaultExpectation *ThingRepositoryMockAddExpectation
  79. expectations []*ThingRepositoryMockAddExpectation
  80. callArgs []*ThingRepositoryMockAddParams
  81. mutex sync.RWMutex
  82. expectedInvocations uint64
  83. }
  84. // ThingRepositoryMockAddExpectation specifies expectation struct of the ThingRepository.Add
  85. type ThingRepositoryMockAddExpectation struct {
  86. mock *ThingRepositoryMock
  87. params *ThingRepositoryMockAddParams
  88. paramPtrs *ThingRepositoryMockAddParamPtrs
  89. results *ThingRepositoryMockAddResults
  90. Counter uint64
  91. }
  92. // ThingRepositoryMockAddParams contains parameters of the ThingRepository.Add
  93. type ThingRepositoryMockAddParams struct {
  94. ctx context.Context
  95. req models.AddThingRequest
  96. }
  97. // ThingRepositoryMockAddParamPtrs contains pointers to parameters of the ThingRepository.Add
  98. type ThingRepositoryMockAddParamPtrs struct {
  99. ctx *context.Context
  100. req *models.AddThingRequest
  101. }
  102. // ThingRepositoryMockAddResults contains results of the ThingRepository.Add
  103. type ThingRepositoryMockAddResults struct {
  104. u1 uint64
  105. err error
  106. }
  107. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  108. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  109. // Optional() makes method check to work in '0 or more' mode.
  110. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  111. // catch the problems when the expected method call is totally skipped during test run.
  112. func (mmAdd *mThingRepositoryMockAdd) Optional() *mThingRepositoryMockAdd {
  113. mmAdd.optional = true
  114. return mmAdd
  115. }
  116. // Expect sets up expected params for ThingRepository.Add
  117. func (mmAdd *mThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingRequest) *mThingRepositoryMockAdd {
  118. if mmAdd.mock.funcAdd != nil {
  119. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  120. }
  121. if mmAdd.defaultExpectation == nil {
  122. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
  123. }
  124. if mmAdd.defaultExpectation.paramPtrs != nil {
  125. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by ExpectParams functions")
  126. }
  127. mmAdd.defaultExpectation.params = &ThingRepositoryMockAddParams{ctx, req}
  128. for _, e := range mmAdd.expectations {
  129. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  130. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  131. }
  132. }
  133. return mmAdd
  134. }
  135. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Add
  136. func (mmAdd *mThingRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockAdd {
  137. if mmAdd.mock.funcAdd != nil {
  138. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  139. }
  140. if mmAdd.defaultExpectation == nil {
  141. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
  142. }
  143. if mmAdd.defaultExpectation.params != nil {
  144. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
  145. }
  146. if mmAdd.defaultExpectation.paramPtrs == nil {
  147. mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
  148. }
  149. mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
  150. return mmAdd
  151. }
  152. // ExpectReqParam2 sets up expected param req for ThingRepository.Add
  153. func (mmAdd *mThingRepositoryMockAdd) ExpectReqParam2(req models.AddThingRequest) *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.req = &req
  167. return mmAdd
  168. }
  169. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Add
  170. func (mmAdd *mThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingRequest)) *mThingRepositoryMockAdd {
  171. if mmAdd.mock.inspectFuncAdd != nil {
  172. mmAdd.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Add")
  173. }
  174. mmAdd.mock.inspectFuncAdd = f
  175. return mmAdd
  176. }
  177. // Return sets up results that will be returned by ThingRepository.Add
  178. func (mmAdd *mThingRepositoryMockAdd) Return(u1 uint64, err error) *ThingRepositoryMock {
  179. if mmAdd.mock.funcAdd != nil {
  180. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  181. }
  182. if mmAdd.defaultExpectation == nil {
  183. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{mock: mmAdd.mock}
  184. }
  185. mmAdd.defaultExpectation.results = &ThingRepositoryMockAddResults{u1, err}
  186. return mmAdd.mock
  187. }
  188. // Set uses given function f to mock the ThingRepository.Add method
  189. func (mmAdd *mThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingRequest) (u1 uint64, err error)) *ThingRepositoryMock {
  190. if mmAdd.defaultExpectation != nil {
  191. mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Add method")
  192. }
  193. if len(mmAdd.expectations) > 0 {
  194. mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Add method")
  195. }
  196. mmAdd.mock.funcAdd = f
  197. return mmAdd.mock
  198. }
  199. // When sets expectation for the ThingRepository.Add which will trigger the result defined by the following
  200. // Then helper
  201. func (mmAdd *mThingRepositoryMockAdd) When(ctx context.Context, req models.AddThingRequest) *ThingRepositoryMockAddExpectation {
  202. if mmAdd.mock.funcAdd != nil {
  203. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  204. }
  205. expectation := &ThingRepositoryMockAddExpectation{
  206. mock: mmAdd.mock,
  207. params: &ThingRepositoryMockAddParams{ctx, req},
  208. }
  209. mmAdd.expectations = append(mmAdd.expectations, expectation)
  210. return expectation
  211. }
  212. // Then sets up ThingRepository.Add return parameters for the expectation previously defined by the When method
  213. func (e *ThingRepositoryMockAddExpectation) Then(u1 uint64, err error) *ThingRepositoryMock {
  214. e.results = &ThingRepositoryMockAddResults{u1, err}
  215. return e.mock
  216. }
  217. // Times sets number of times ThingRepository.Add should be invoked
  218. func (mmAdd *mThingRepositoryMockAdd) Times(n uint64) *mThingRepositoryMockAdd {
  219. if n == 0 {
  220. mmAdd.mock.t.Fatalf("Times of ThingRepositoryMock.Add mock can not be zero")
  221. }
  222. mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
  223. return mmAdd
  224. }
  225. func (mmAdd *mThingRepositoryMockAdd) invocationsDone() bool {
  226. if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
  227. return true
  228. }
  229. totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
  230. expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
  231. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  232. }
  233. // Add implements thing.ThingRepository
  234. func (mmAdd *ThingRepositoryMock) Add(ctx context.Context, req models.AddThingRequest) (u1 uint64, err error) {
  235. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  236. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  237. if mmAdd.inspectFuncAdd != nil {
  238. mmAdd.inspectFuncAdd(ctx, req)
  239. }
  240. mm_params := ThingRepositoryMockAddParams{ctx, req}
  241. // Record call args
  242. mmAdd.AddMock.mutex.Lock()
  243. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
  244. mmAdd.AddMock.mutex.Unlock()
  245. for _, e := range mmAdd.AddMock.expectations {
  246. if minimock.Equal(*e.params, mm_params) {
  247. mm_atomic.AddUint64(&e.Counter, 1)
  248. return e.results.u1, e.results.err
  249. }
  250. }
  251. if mmAdd.AddMock.defaultExpectation != nil {
  252. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  253. mm_want := mmAdd.AddMock.defaultExpectation.params
  254. mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
  255. mm_got := ThingRepositoryMockAddParams{ctx, req}
  256. if mm_want_ptrs != nil {
  257. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  258. 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))
  259. }
  260. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  261. 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))
  262. }
  263. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  264. mmAdd.t.Errorf("ThingRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  265. }
  266. mm_results := mmAdd.AddMock.defaultExpectation.results
  267. if mm_results == nil {
  268. mmAdd.t.Fatal("No results are set for the ThingRepositoryMock.Add")
  269. }
  270. return (*mm_results).u1, (*mm_results).err
  271. }
  272. if mmAdd.funcAdd != nil {
  273. return mmAdd.funcAdd(ctx, req)
  274. }
  275. mmAdd.t.Fatalf("Unexpected call to ThingRepositoryMock.Add. %v %v", ctx, req)
  276. return
  277. }
  278. // AddAfterCounter returns a count of finished ThingRepositoryMock.Add invocations
  279. func (mmAdd *ThingRepositoryMock) AddAfterCounter() uint64 {
  280. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  281. }
  282. // AddBeforeCounter returns a count of ThingRepositoryMock.Add invocations
  283. func (mmAdd *ThingRepositoryMock) AddBeforeCounter() uint64 {
  284. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  285. }
  286. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Add.
  287. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  288. func (mmAdd *mThingRepositoryMockAdd) Calls() []*ThingRepositoryMockAddParams {
  289. mmAdd.mutex.RLock()
  290. argCopy := make([]*ThingRepositoryMockAddParams, len(mmAdd.callArgs))
  291. copy(argCopy, mmAdd.callArgs)
  292. mmAdd.mutex.RUnlock()
  293. return argCopy
  294. }
  295. // MinimockAddDone returns true if the count of the Add invocations corresponds
  296. // the number of defined expectations
  297. func (m *ThingRepositoryMock) MinimockAddDone() bool {
  298. if m.AddMock.optional {
  299. // Optional methods provide '0 or more' call count restriction.
  300. return true
  301. }
  302. for _, e := range m.AddMock.expectations {
  303. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  304. return false
  305. }
  306. }
  307. return m.AddMock.invocationsDone()
  308. }
  309. // MinimockAddInspect logs each unmet expectation
  310. func (m *ThingRepositoryMock) MinimockAddInspect() {
  311. for _, e := range m.AddMock.expectations {
  312. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  313. m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *e.params)
  314. }
  315. }
  316. afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
  317. // if default expectation was set then invocations count should be greater than zero
  318. if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
  319. if m.AddMock.defaultExpectation.params == nil {
  320. m.t.Error("Expected call to ThingRepositoryMock.Add")
  321. } else {
  322. m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  323. }
  324. }
  325. // if func was set then invocations count should be greater than zero
  326. if m.funcAdd != nil && afterAddCounter < 1 {
  327. m.t.Error("Expected call to ThingRepositoryMock.Add")
  328. }
  329. if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
  330. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Add but found %d calls",
  331. mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
  332. }
  333. }
  334. type mThingRepositoryMockDelete struct {
  335. optional bool
  336. mock *ThingRepositoryMock
  337. defaultExpectation *ThingRepositoryMockDeleteExpectation
  338. expectations []*ThingRepositoryMockDeleteExpectation
  339. callArgs []*ThingRepositoryMockDeleteParams
  340. mutex sync.RWMutex
  341. expectedInvocations uint64
  342. }
  343. // ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete
  344. type ThingRepositoryMockDeleteExpectation struct {
  345. mock *ThingRepositoryMock
  346. params *ThingRepositoryMockDeleteParams
  347. paramPtrs *ThingRepositoryMockDeleteParamPtrs
  348. results *ThingRepositoryMockDeleteResults
  349. Counter uint64
  350. }
  351. // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
  352. type ThingRepositoryMockDeleteParams struct {
  353. ctx context.Context
  354. id uint64
  355. }
  356. // ThingRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingRepository.Delete
  357. type ThingRepositoryMockDeleteParamPtrs struct {
  358. ctx *context.Context
  359. id *uint64
  360. }
  361. // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
  362. type ThingRepositoryMockDeleteResults struct {
  363. err error
  364. }
  365. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  366. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  367. // Optional() makes method check to work in '0 or more' mode.
  368. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  369. // catch the problems when the expected method call is totally skipped during test run.
  370. func (mmDelete *mThingRepositoryMockDelete) Optional() *mThingRepositoryMockDelete {
  371. mmDelete.optional = true
  372. return mmDelete
  373. }
  374. // Expect sets up expected params for ThingRepository.Delete
  375. func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingRepositoryMockDelete {
  376. if mmDelete.mock.funcDelete != nil {
  377. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  378. }
  379. if mmDelete.defaultExpectation == nil {
  380. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  381. }
  382. if mmDelete.defaultExpectation.paramPtrs != nil {
  383. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by ExpectParams functions")
  384. }
  385. mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, id}
  386. for _, e := range mmDelete.expectations {
  387. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  388. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  389. }
  390. }
  391. return mmDelete
  392. }
  393. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Delete
  394. func (mmDelete *mThingRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockDelete {
  395. if mmDelete.mock.funcDelete != nil {
  396. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  397. }
  398. if mmDelete.defaultExpectation == nil {
  399. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  400. }
  401. if mmDelete.defaultExpectation.params != nil {
  402. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
  403. }
  404. if mmDelete.defaultExpectation.paramPtrs == nil {
  405. mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
  406. }
  407. mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
  408. return mmDelete
  409. }
  410. // ExpectIdParam2 sets up expected param id for ThingRepository.Delete
  411. func (mmDelete *mThingRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingRepositoryMockDelete {
  412. if mmDelete.mock.funcDelete != nil {
  413. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  414. }
  415. if mmDelete.defaultExpectation == nil {
  416. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  417. }
  418. if mmDelete.defaultExpectation.params != nil {
  419. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
  420. }
  421. if mmDelete.defaultExpectation.paramPtrs == nil {
  422. mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
  423. }
  424. mmDelete.defaultExpectation.paramPtrs.id = &id
  425. return mmDelete
  426. }
  427. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
  428. func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockDelete {
  429. if mmDelete.mock.inspectFuncDelete != nil {
  430. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
  431. }
  432. mmDelete.mock.inspectFuncDelete = f
  433. return mmDelete
  434. }
  435. // Return sets up results that will be returned by ThingRepository.Delete
  436. func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock {
  437. if mmDelete.mock.funcDelete != nil {
  438. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  439. }
  440. if mmDelete.defaultExpectation == nil {
  441. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  442. }
  443. mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err}
  444. return mmDelete.mock
  445. }
  446. // Set uses given function f to mock the ThingRepository.Delete method
  447. func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingRepositoryMock {
  448. if mmDelete.defaultExpectation != nil {
  449. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
  450. }
  451. if len(mmDelete.expectations) > 0 {
  452. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method")
  453. }
  454. mmDelete.mock.funcDelete = f
  455. return mmDelete.mock
  456. }
  457. // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
  458. // Then helper
  459. func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingRepositoryMockDeleteExpectation {
  460. if mmDelete.mock.funcDelete != nil {
  461. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  462. }
  463. expectation := &ThingRepositoryMockDeleteExpectation{
  464. mock: mmDelete.mock,
  465. params: &ThingRepositoryMockDeleteParams{ctx, id},
  466. }
  467. mmDelete.expectations = append(mmDelete.expectations, expectation)
  468. return expectation
  469. }
  470. // Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method
  471. func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock {
  472. e.results = &ThingRepositoryMockDeleteResults{err}
  473. return e.mock
  474. }
  475. // Times sets number of times ThingRepository.Delete should be invoked
  476. func (mmDelete *mThingRepositoryMockDelete) Times(n uint64) *mThingRepositoryMockDelete {
  477. if n == 0 {
  478. mmDelete.mock.t.Fatalf("Times of ThingRepositoryMock.Delete mock can not be zero")
  479. }
  480. mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
  481. return mmDelete
  482. }
  483. func (mmDelete *mThingRepositoryMockDelete) invocationsDone() bool {
  484. if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
  485. return true
  486. }
  487. totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
  488. expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
  489. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  490. }
  491. // Delete implements thing.ThingRepository
  492. func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
  493. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  494. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  495. if mmDelete.inspectFuncDelete != nil {
  496. mmDelete.inspectFuncDelete(ctx, id)
  497. }
  498. mm_params := ThingRepositoryMockDeleteParams{ctx, id}
  499. // Record call args
  500. mmDelete.DeleteMock.mutex.Lock()
  501. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
  502. mmDelete.DeleteMock.mutex.Unlock()
  503. for _, e := range mmDelete.DeleteMock.expectations {
  504. if minimock.Equal(*e.params, mm_params) {
  505. mm_atomic.AddUint64(&e.Counter, 1)
  506. return e.results.err
  507. }
  508. }
  509. if mmDelete.DeleteMock.defaultExpectation != nil {
  510. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  511. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  512. mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
  513. mm_got := ThingRepositoryMockDeleteParams{ctx, id}
  514. if mm_want_ptrs != nil {
  515. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  516. 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))
  517. }
  518. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  519. mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  520. }
  521. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  522. mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  523. }
  524. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  525. if mm_results == nil {
  526. mmDelete.t.Fatal("No results are set for the ThingRepositoryMock.Delete")
  527. }
  528. return (*mm_results).err
  529. }
  530. if mmDelete.funcDelete != nil {
  531. return mmDelete.funcDelete(ctx, id)
  532. }
  533. mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v", ctx, id)
  534. return
  535. }
  536. // DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations
  537. func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 {
  538. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  539. }
  540. // DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations
  541. func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 {
  542. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  543. }
  544. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete.
  545. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  546. func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams {
  547. mmDelete.mutex.RLock()
  548. argCopy := make([]*ThingRepositoryMockDeleteParams, len(mmDelete.callArgs))
  549. copy(argCopy, mmDelete.callArgs)
  550. mmDelete.mutex.RUnlock()
  551. return argCopy
  552. }
  553. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  554. // the number of defined expectations
  555. func (m *ThingRepositoryMock) MinimockDeleteDone() bool {
  556. if m.DeleteMock.optional {
  557. // Optional methods provide '0 or more' call count restriction.
  558. return true
  559. }
  560. for _, e := range m.DeleteMock.expectations {
  561. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  562. return false
  563. }
  564. }
  565. return m.DeleteMock.invocationsDone()
  566. }
  567. // MinimockDeleteInspect logs each unmet expectation
  568. func (m *ThingRepositoryMock) MinimockDeleteInspect() {
  569. for _, e := range m.DeleteMock.expectations {
  570. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  571. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *e.params)
  572. }
  573. }
  574. afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
  575. // if default expectation was set then invocations count should be greater than zero
  576. if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
  577. if m.DeleteMock.defaultExpectation.params == nil {
  578. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  579. } else {
  580. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  581. }
  582. }
  583. // if func was set then invocations count should be greater than zero
  584. if m.funcDelete != nil && afterDeleteCounter < 1 {
  585. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  586. }
  587. if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
  588. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Delete but found %d calls",
  589. mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
  590. }
  591. }
  592. type mThingRepositoryMockGet struct {
  593. optional bool
  594. mock *ThingRepositoryMock
  595. defaultExpectation *ThingRepositoryMockGetExpectation
  596. expectations []*ThingRepositoryMockGetExpectation
  597. callArgs []*ThingRepositoryMockGetParams
  598. mutex sync.RWMutex
  599. expectedInvocations uint64
  600. }
  601. // ThingRepositoryMockGetExpectation specifies expectation struct of the ThingRepository.Get
  602. type ThingRepositoryMockGetExpectation struct {
  603. mock *ThingRepositoryMock
  604. params *ThingRepositoryMockGetParams
  605. paramPtrs *ThingRepositoryMockGetParamPtrs
  606. results *ThingRepositoryMockGetResults
  607. Counter uint64
  608. }
  609. // ThingRepositoryMockGetParams contains parameters of the ThingRepository.Get
  610. type ThingRepositoryMockGetParams struct {
  611. ctx context.Context
  612. id uint64
  613. }
  614. // ThingRepositoryMockGetParamPtrs contains pointers to parameters of the ThingRepository.Get
  615. type ThingRepositoryMockGetParamPtrs struct {
  616. ctx *context.Context
  617. id *uint64
  618. }
  619. // ThingRepositoryMockGetResults contains results of the ThingRepository.Get
  620. type ThingRepositoryMockGetResults struct {
  621. tp1 *models.Thing
  622. err error
  623. }
  624. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  625. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  626. // Optional() makes method check to work in '0 or more' mode.
  627. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  628. // catch the problems when the expected method call is totally skipped during test run.
  629. func (mmGet *mThingRepositoryMockGet) Optional() *mThingRepositoryMockGet {
  630. mmGet.optional = true
  631. return mmGet
  632. }
  633. // Expect sets up expected params for ThingRepository.Get
  634. func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGet {
  635. if mmGet.mock.funcGet != nil {
  636. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  637. }
  638. if mmGet.defaultExpectation == nil {
  639. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
  640. }
  641. if mmGet.defaultExpectation.paramPtrs != nil {
  642. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by ExpectParams functions")
  643. }
  644. mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, id}
  645. for _, e := range mmGet.expectations {
  646. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  647. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  648. }
  649. }
  650. return mmGet
  651. }
  652. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Get
  653. func (mmGet *mThingRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGet {
  654. if mmGet.mock.funcGet != nil {
  655. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  656. }
  657. if mmGet.defaultExpectation == nil {
  658. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
  659. }
  660. if mmGet.defaultExpectation.params != nil {
  661. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
  662. }
  663. if mmGet.defaultExpectation.paramPtrs == nil {
  664. mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
  665. }
  666. mmGet.defaultExpectation.paramPtrs.ctx = &ctx
  667. return mmGet
  668. }
  669. // ExpectIdParam2 sets up expected param id for ThingRepository.Get
  670. func (mmGet *mThingRepositoryMockGet) ExpectIdParam2(id uint64) *mThingRepositoryMockGet {
  671. if mmGet.mock.funcGet != nil {
  672. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  673. }
  674. if mmGet.defaultExpectation == nil {
  675. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
  676. }
  677. if mmGet.defaultExpectation.params != nil {
  678. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
  679. }
  680. if mmGet.defaultExpectation.paramPtrs == nil {
  681. mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
  682. }
  683. mmGet.defaultExpectation.paramPtrs.id = &id
  684. return mmGet
  685. }
  686. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Get
  687. func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGet {
  688. if mmGet.mock.inspectFuncGet != nil {
  689. mmGet.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Get")
  690. }
  691. mmGet.mock.inspectFuncGet = f
  692. return mmGet
  693. }
  694. // Return sets up results that will be returned by ThingRepository.Get
  695. func (mmGet *mThingRepositoryMockGet) Return(tp1 *models.Thing, err error) *ThingRepositoryMock {
  696. if mmGet.mock.funcGet != nil {
  697. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  698. }
  699. if mmGet.defaultExpectation == nil {
  700. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{mock: mmGet.mock}
  701. }
  702. mmGet.defaultExpectation.results = &ThingRepositoryMockGetResults{tp1, err}
  703. return mmGet.mock
  704. }
  705. // Set uses given function f to mock the ThingRepository.Get method
  706. func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
  707. if mmGet.defaultExpectation != nil {
  708. mmGet.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Get method")
  709. }
  710. if len(mmGet.expectations) > 0 {
  711. mmGet.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Get method")
  712. }
  713. mmGet.mock.funcGet = f
  714. return mmGet.mock
  715. }
  716. // When sets expectation for the ThingRepository.Get which will trigger the result defined by the following
  717. // Then helper
  718. func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, id uint64) *ThingRepositoryMockGetExpectation {
  719. if mmGet.mock.funcGet != nil {
  720. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  721. }
  722. expectation := &ThingRepositoryMockGetExpectation{
  723. mock: mmGet.mock,
  724. params: &ThingRepositoryMockGetParams{ctx, id},
  725. }
  726. mmGet.expectations = append(mmGet.expectations, expectation)
  727. return expectation
  728. }
  729. // Then sets up ThingRepository.Get return parameters for the expectation previously defined by the When method
  730. func (e *ThingRepositoryMockGetExpectation) Then(tp1 *models.Thing, err error) *ThingRepositoryMock {
  731. e.results = &ThingRepositoryMockGetResults{tp1, err}
  732. return e.mock
  733. }
  734. // Times sets number of times ThingRepository.Get should be invoked
  735. func (mmGet *mThingRepositoryMockGet) Times(n uint64) *mThingRepositoryMockGet {
  736. if n == 0 {
  737. mmGet.mock.t.Fatalf("Times of ThingRepositoryMock.Get mock can not be zero")
  738. }
  739. mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
  740. return mmGet
  741. }
  742. func (mmGet *mThingRepositoryMockGet) invocationsDone() bool {
  743. if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
  744. return true
  745. }
  746. totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
  747. expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
  748. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  749. }
  750. // Get implements thing.ThingRepository
  751. func (mmGet *ThingRepositoryMock) Get(ctx context.Context, id uint64) (tp1 *models.Thing, err error) {
  752. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  753. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  754. if mmGet.inspectFuncGet != nil {
  755. mmGet.inspectFuncGet(ctx, id)
  756. }
  757. mm_params := ThingRepositoryMockGetParams{ctx, id}
  758. // Record call args
  759. mmGet.GetMock.mutex.Lock()
  760. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
  761. mmGet.GetMock.mutex.Unlock()
  762. for _, e := range mmGet.GetMock.expectations {
  763. if minimock.Equal(*e.params, mm_params) {
  764. mm_atomic.AddUint64(&e.Counter, 1)
  765. return e.results.tp1, e.results.err
  766. }
  767. }
  768. if mmGet.GetMock.defaultExpectation != nil {
  769. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  770. mm_want := mmGet.GetMock.defaultExpectation.params
  771. mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
  772. mm_got := ThingRepositoryMockGetParams{ctx, id}
  773. if mm_want_ptrs != nil {
  774. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  775. 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))
  776. }
  777. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  778. mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  779. }
  780. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  781. mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  782. }
  783. mm_results := mmGet.GetMock.defaultExpectation.results
  784. if mm_results == nil {
  785. mmGet.t.Fatal("No results are set for the ThingRepositoryMock.Get")
  786. }
  787. return (*mm_results).tp1, (*mm_results).err
  788. }
  789. if mmGet.funcGet != nil {
  790. return mmGet.funcGet(ctx, id)
  791. }
  792. mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, id)
  793. return
  794. }
  795. // GetAfterCounter returns a count of finished ThingRepositoryMock.Get invocations
  796. func (mmGet *ThingRepositoryMock) GetAfterCounter() uint64 {
  797. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  798. }
  799. // GetBeforeCounter returns a count of ThingRepositoryMock.Get invocations
  800. func (mmGet *ThingRepositoryMock) GetBeforeCounter() uint64 {
  801. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  802. }
  803. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Get.
  804. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  805. func (mmGet *mThingRepositoryMockGet) Calls() []*ThingRepositoryMockGetParams {
  806. mmGet.mutex.RLock()
  807. argCopy := make([]*ThingRepositoryMockGetParams, len(mmGet.callArgs))
  808. copy(argCopy, mmGet.callArgs)
  809. mmGet.mutex.RUnlock()
  810. return argCopy
  811. }
  812. // MinimockGetDone returns true if the count of the Get invocations corresponds
  813. // the number of defined expectations
  814. func (m *ThingRepositoryMock) MinimockGetDone() bool {
  815. if m.GetMock.optional {
  816. // Optional methods provide '0 or more' call count restriction.
  817. return true
  818. }
  819. for _, e := range m.GetMock.expectations {
  820. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  821. return false
  822. }
  823. }
  824. return m.GetMock.invocationsDone()
  825. }
  826. // MinimockGetInspect logs each unmet expectation
  827. func (m *ThingRepositoryMock) MinimockGetInspect() {
  828. for _, e := range m.GetMock.expectations {
  829. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  830. m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *e.params)
  831. }
  832. }
  833. afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
  834. // if default expectation was set then invocations count should be greater than zero
  835. if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
  836. if m.GetMock.defaultExpectation.params == nil {
  837. m.t.Error("Expected call to ThingRepositoryMock.Get")
  838. } else {
  839. m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  840. }
  841. }
  842. // if func was set then invocations count should be greater than zero
  843. if m.funcGet != nil && afterGetCounter < 1 {
  844. m.t.Error("Expected call to ThingRepositoryMock.Get")
  845. }
  846. if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
  847. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Get but found %d calls",
  848. mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
  849. }
  850. }
  851. type mThingRepositoryMockGetAllByPlaceID struct {
  852. optional bool
  853. mock *ThingRepositoryMock
  854. defaultExpectation *ThingRepositoryMockGetAllByPlaceIDExpectation
  855. expectations []*ThingRepositoryMockGetAllByPlaceIDExpectation
  856. callArgs []*ThingRepositoryMockGetAllByPlaceIDParams
  857. mutex sync.RWMutex
  858. expectedInvocations uint64
  859. }
  860. // ThingRepositoryMockGetAllByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetAllByPlaceID
  861. type ThingRepositoryMockGetAllByPlaceIDExpectation struct {
  862. mock *ThingRepositoryMock
  863. params *ThingRepositoryMockGetAllByPlaceIDParams
  864. paramPtrs *ThingRepositoryMockGetAllByPlaceIDParamPtrs
  865. results *ThingRepositoryMockGetAllByPlaceIDResults
  866. Counter uint64
  867. }
  868. // ThingRepositoryMockGetAllByPlaceIDParams contains parameters of the ThingRepository.GetAllByPlaceID
  869. type ThingRepositoryMockGetAllByPlaceIDParams struct {
  870. ctx context.Context
  871. id uint64
  872. }
  873. // ThingRepositoryMockGetAllByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetAllByPlaceID
  874. type ThingRepositoryMockGetAllByPlaceIDParamPtrs struct {
  875. ctx *context.Context
  876. id *uint64
  877. }
  878. // ThingRepositoryMockGetAllByPlaceIDResults contains results of the ThingRepository.GetAllByPlaceID
  879. type ThingRepositoryMockGetAllByPlaceIDResults struct {
  880. ta1 []models.Thing
  881. err error
  882. }
  883. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  884. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  885. // Optional() makes method check to work in '0 or more' mode.
  886. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  887. // catch the problems when the expected method call is totally skipped during test run.
  888. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Optional() *mThingRepositoryMockGetAllByPlaceID {
  889. mmGetAllByPlaceID.optional = true
  890. return mmGetAllByPlaceID
  891. }
  892. // Expect sets up expected params for ThingRepository.GetAllByPlaceID
  893. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGetAllByPlaceID {
  894. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  895. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  896. }
  897. if mmGetAllByPlaceID.defaultExpectation == nil {
  898. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
  899. }
  900. if mmGetAllByPlaceID.defaultExpectation.paramPtrs != nil {
  901. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by ExpectParams functions")
  902. }
  903. mmGetAllByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetAllByPlaceIDParams{ctx, id}
  904. for _, e := range mmGetAllByPlaceID.expectations {
  905. if minimock.Equal(e.params, mmGetAllByPlaceID.defaultExpectation.params) {
  906. mmGetAllByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllByPlaceID.defaultExpectation.params)
  907. }
  908. }
  909. return mmGetAllByPlaceID
  910. }
  911. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetAllByPlaceID
  912. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetAllByPlaceID {
  913. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  914. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  915. }
  916. if mmGetAllByPlaceID.defaultExpectation == nil {
  917. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
  918. }
  919. if mmGetAllByPlaceID.defaultExpectation.params != nil {
  920. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
  921. }
  922. if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
  923. mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
  924. }
  925. mmGetAllByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
  926. return mmGetAllByPlaceID
  927. }
  928. // ExpectIdParam2 sets up expected param id for ThingRepository.GetAllByPlaceID
  929. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectIdParam2(id uint64) *mThingRepositoryMockGetAllByPlaceID {
  930. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  931. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  932. }
  933. if mmGetAllByPlaceID.defaultExpectation == nil {
  934. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
  935. }
  936. if mmGetAllByPlaceID.defaultExpectation.params != nil {
  937. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
  938. }
  939. if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
  940. mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
  941. }
  942. mmGetAllByPlaceID.defaultExpectation.paramPtrs.id = &id
  943. return mmGetAllByPlaceID
  944. }
  945. // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetAllByPlaceID
  946. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGetAllByPlaceID {
  947. if mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID != nil {
  948. mmGetAllByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetAllByPlaceID")
  949. }
  950. mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID = f
  951. return mmGetAllByPlaceID
  952. }
  953. // Return sets up results that will be returned by ThingRepository.GetAllByPlaceID
  954. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  955. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  956. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  957. }
  958. if mmGetAllByPlaceID.defaultExpectation == nil {
  959. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{mock: mmGetAllByPlaceID.mock}
  960. }
  961. mmGetAllByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
  962. return mmGetAllByPlaceID.mock
  963. }
  964. // Set uses given function f to mock the ThingRepository.GetAllByPlaceID method
  965. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  966. if mmGetAllByPlaceID.defaultExpectation != nil {
  967. mmGetAllByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetAllByPlaceID method")
  968. }
  969. if len(mmGetAllByPlaceID.expectations) > 0 {
  970. mmGetAllByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetAllByPlaceID method")
  971. }
  972. mmGetAllByPlaceID.mock.funcGetAllByPlaceID = f
  973. return mmGetAllByPlaceID.mock
  974. }
  975. // When sets expectation for the ThingRepository.GetAllByPlaceID which will trigger the result defined by the following
  976. // Then helper
  977. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) When(ctx context.Context, id uint64) *ThingRepositoryMockGetAllByPlaceIDExpectation {
  978. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  979. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  980. }
  981. expectation := &ThingRepositoryMockGetAllByPlaceIDExpectation{
  982. mock: mmGetAllByPlaceID.mock,
  983. params: &ThingRepositoryMockGetAllByPlaceIDParams{ctx, id},
  984. }
  985. mmGetAllByPlaceID.expectations = append(mmGetAllByPlaceID.expectations, expectation)
  986. return expectation
  987. }
  988. // Then sets up ThingRepository.GetAllByPlaceID return parameters for the expectation previously defined by the When method
  989. func (e *ThingRepositoryMockGetAllByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  990. e.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
  991. return e.mock
  992. }
  993. // Times sets number of times ThingRepository.GetAllByPlaceID should be invoked
  994. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Times(n uint64) *mThingRepositoryMockGetAllByPlaceID {
  995. if n == 0 {
  996. mmGetAllByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetAllByPlaceID mock can not be zero")
  997. }
  998. mm_atomic.StoreUint64(&mmGetAllByPlaceID.expectedInvocations, n)
  999. return mmGetAllByPlaceID
  1000. }
  1001. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) invocationsDone() bool {
  1002. if len(mmGetAllByPlaceID.expectations) == 0 && mmGetAllByPlaceID.defaultExpectation == nil && mmGetAllByPlaceID.mock.funcGetAllByPlaceID == nil {
  1003. return true
  1004. }
  1005. totalInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.mock.afterGetAllByPlaceIDCounter)
  1006. expectedInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.expectedInvocations)
  1007. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1008. }
  1009. // GetAllByPlaceID implements thing.ThingRepository
  1010. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceID(ctx context.Context, id uint64) (ta1 []models.Thing, err error) {
  1011. mm_atomic.AddUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter, 1)
  1012. defer mm_atomic.AddUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter, 1)
  1013. if mmGetAllByPlaceID.inspectFuncGetAllByPlaceID != nil {
  1014. mmGetAllByPlaceID.inspectFuncGetAllByPlaceID(ctx, id)
  1015. }
  1016. mm_params := ThingRepositoryMockGetAllByPlaceIDParams{ctx, id}
  1017. // Record call args
  1018. mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Lock()
  1019. mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs = append(mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs, &mm_params)
  1020. mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Unlock()
  1021. for _, e := range mmGetAllByPlaceID.GetAllByPlaceIDMock.expectations {
  1022. if minimock.Equal(*e.params, mm_params) {
  1023. mm_atomic.AddUint64(&e.Counter, 1)
  1024. return e.results.ta1, e.results.err
  1025. }
  1026. }
  1027. if mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation != nil {
  1028. mm_atomic.AddUint64(&mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.Counter, 1)
  1029. mm_want := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.params
  1030. mm_want_ptrs := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.paramPtrs
  1031. mm_got := ThingRepositoryMockGetAllByPlaceIDParams{ctx, id}
  1032. if mm_want_ptrs != nil {
  1033. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1034. 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))
  1035. }
  1036. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  1037. mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  1038. }
  1039. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1040. mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1041. }
  1042. mm_results := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.results
  1043. if mm_results == nil {
  1044. mmGetAllByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetAllByPlaceID")
  1045. }
  1046. return (*mm_results).ta1, (*mm_results).err
  1047. }
  1048. if mmGetAllByPlaceID.funcGetAllByPlaceID != nil {
  1049. return mmGetAllByPlaceID.funcGetAllByPlaceID(ctx, id)
  1050. }
  1051. mmGetAllByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetAllByPlaceID. %v %v", ctx, id)
  1052. return
  1053. }
  1054. // GetAllByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetAllByPlaceID invocations
  1055. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDAfterCounter() uint64 {
  1056. return mm_atomic.LoadUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter)
  1057. }
  1058. // GetAllByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetAllByPlaceID invocations
  1059. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDBeforeCounter() uint64 {
  1060. return mm_atomic.LoadUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter)
  1061. }
  1062. // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetAllByPlaceID.
  1063. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1064. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Calls() []*ThingRepositoryMockGetAllByPlaceIDParams {
  1065. mmGetAllByPlaceID.mutex.RLock()
  1066. argCopy := make([]*ThingRepositoryMockGetAllByPlaceIDParams, len(mmGetAllByPlaceID.callArgs))
  1067. copy(argCopy, mmGetAllByPlaceID.callArgs)
  1068. mmGetAllByPlaceID.mutex.RUnlock()
  1069. return argCopy
  1070. }
  1071. // MinimockGetAllByPlaceIDDone returns true if the count of the GetAllByPlaceID invocations corresponds
  1072. // the number of defined expectations
  1073. func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDDone() bool {
  1074. if m.GetAllByPlaceIDMock.optional {
  1075. // Optional methods provide '0 or more' call count restriction.
  1076. return true
  1077. }
  1078. for _, e := range m.GetAllByPlaceIDMock.expectations {
  1079. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1080. return false
  1081. }
  1082. }
  1083. return m.GetAllByPlaceIDMock.invocationsDone()
  1084. }
  1085. // MinimockGetAllByPlaceIDInspect logs each unmet expectation
  1086. func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDInspect() {
  1087. for _, e := range m.GetAllByPlaceIDMock.expectations {
  1088. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1089. m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *e.params)
  1090. }
  1091. }
  1092. afterGetAllByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter)
  1093. // if default expectation was set then invocations count should be greater than zero
  1094. if m.GetAllByPlaceIDMock.defaultExpectation != nil && afterGetAllByPlaceIDCounter < 1 {
  1095. if m.GetAllByPlaceIDMock.defaultExpectation.params == nil {
  1096. m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
  1097. } else {
  1098. m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *m.GetAllByPlaceIDMock.defaultExpectation.params)
  1099. }
  1100. }
  1101. // if func was set then invocations count should be greater than zero
  1102. if m.funcGetAllByPlaceID != nil && afterGetAllByPlaceIDCounter < 1 {
  1103. m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
  1104. }
  1105. if !m.GetAllByPlaceIDMock.invocationsDone() && afterGetAllByPlaceIDCounter > 0 {
  1106. m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetAllByPlaceID but found %d calls",
  1107. mm_atomic.LoadUint64(&m.GetAllByPlaceIDMock.expectedInvocations), afterGetAllByPlaceIDCounter)
  1108. }
  1109. }
  1110. type mThingRepositoryMockGetByPlaceID struct {
  1111. optional bool
  1112. mock *ThingRepositoryMock
  1113. defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation
  1114. expectations []*ThingRepositoryMockGetByPlaceIDExpectation
  1115. callArgs []*ThingRepositoryMockGetByPlaceIDParams
  1116. mutex sync.RWMutex
  1117. expectedInvocations uint64
  1118. }
  1119. // ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID
  1120. type ThingRepositoryMockGetByPlaceIDExpectation struct {
  1121. mock *ThingRepositoryMock
  1122. params *ThingRepositoryMockGetByPlaceIDParams
  1123. paramPtrs *ThingRepositoryMockGetByPlaceIDParamPtrs
  1124. results *ThingRepositoryMockGetByPlaceIDResults
  1125. Counter uint64
  1126. }
  1127. // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
  1128. type ThingRepositoryMockGetByPlaceIDParams struct {
  1129. ctx context.Context
  1130. id uint64
  1131. }
  1132. // ThingRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetByPlaceID
  1133. type ThingRepositoryMockGetByPlaceIDParamPtrs struct {
  1134. ctx *context.Context
  1135. id *uint64
  1136. }
  1137. // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
  1138. type ThingRepositoryMockGetByPlaceIDResults struct {
  1139. ta1 []models.Thing
  1140. err error
  1141. }
  1142. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1143. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1144. // Optional() makes method check to work in '0 or more' mode.
  1145. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1146. // catch the problems when the expected method call is totally skipped during test run.
  1147. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Optional() *mThingRepositoryMockGetByPlaceID {
  1148. mmGetByPlaceID.optional = true
  1149. return mmGetByPlaceID
  1150. }
  1151. // Expect sets up expected params for ThingRepository.GetByPlaceID
  1152. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGetByPlaceID {
  1153. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1154. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1155. }
  1156. if mmGetByPlaceID.defaultExpectation == nil {
  1157. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  1158. }
  1159. if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
  1160. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
  1161. }
  1162. mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, id}
  1163. for _, e := range mmGetByPlaceID.expectations {
  1164. if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
  1165. mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
  1166. }
  1167. }
  1168. return mmGetByPlaceID
  1169. }
  1170. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetByPlaceID
  1171. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetByPlaceID {
  1172. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1173. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1174. }
  1175. if mmGetByPlaceID.defaultExpectation == nil {
  1176. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  1177. }
  1178. if mmGetByPlaceID.defaultExpectation.params != nil {
  1179. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
  1180. }
  1181. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  1182. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
  1183. }
  1184. mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
  1185. return mmGetByPlaceID
  1186. }
  1187. // ExpectIdParam2 sets up expected param id for ThingRepository.GetByPlaceID
  1188. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingRepositoryMockGetByPlaceID {
  1189. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1190. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1191. }
  1192. if mmGetByPlaceID.defaultExpectation == nil {
  1193. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  1194. }
  1195. if mmGetByPlaceID.defaultExpectation.params != nil {
  1196. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
  1197. }
  1198. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  1199. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
  1200. }
  1201. mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
  1202. return mmGetByPlaceID
  1203. }
  1204. // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
  1205. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGetByPlaceID {
  1206. if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
  1207. mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
  1208. }
  1209. mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
  1210. return mmGetByPlaceID
  1211. }
  1212. // Return sets up results that will be returned by ThingRepository.GetByPlaceID
  1213. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1214. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1215. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1216. }
  1217. if mmGetByPlaceID.defaultExpectation == nil {
  1218. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
  1219. }
  1220. mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  1221. return mmGetByPlaceID.mock
  1222. }
  1223. // Set uses given function f to mock the ThingRepository.GetByPlaceID method
  1224. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  1225. if mmGetByPlaceID.defaultExpectation != nil {
  1226. mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
  1227. }
  1228. if len(mmGetByPlaceID.expectations) > 0 {
  1229. mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method")
  1230. }
  1231. mmGetByPlaceID.mock.funcGetByPlaceID = f
  1232. return mmGetByPlaceID.mock
  1233. }
  1234. // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
  1235. // Then helper
  1236. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingRepositoryMockGetByPlaceIDExpectation {
  1237. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1238. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1239. }
  1240. expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
  1241. mock: mmGetByPlaceID.mock,
  1242. params: &ThingRepositoryMockGetByPlaceIDParams{ctx, id},
  1243. }
  1244. mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
  1245. return expectation
  1246. }
  1247. // Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
  1248. func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1249. e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  1250. return e.mock
  1251. }
  1252. // Times sets number of times ThingRepository.GetByPlaceID should be invoked
  1253. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Times(n uint64) *mThingRepositoryMockGetByPlaceID {
  1254. if n == 0 {
  1255. mmGetByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetByPlaceID mock can not be zero")
  1256. }
  1257. mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
  1258. return mmGetByPlaceID
  1259. }
  1260. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) invocationsDone() bool {
  1261. if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
  1262. return true
  1263. }
  1264. totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
  1265. expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)
  1266. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1267. }
  1268. // GetByPlaceID implements thing.ThingRepository
  1269. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ta1 []models.Thing, err error) {
  1270. mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
  1271. defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
  1272. if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
  1273. mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
  1274. }
  1275. mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, id}
  1276. // Record call args
  1277. mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
  1278. mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
  1279. mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
  1280. for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
  1281. if minimock.Equal(*e.params, mm_params) {
  1282. mm_atomic.AddUint64(&e.Counter, 1)
  1283. return e.results.ta1, e.results.err
  1284. }
  1285. }
  1286. if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
  1287. mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
  1288. mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
  1289. mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
  1290. mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, id}
  1291. if mm_want_ptrs != nil {
  1292. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1293. 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))
  1294. }
  1295. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  1296. mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  1297. }
  1298. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1299. mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1300. }
  1301. mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
  1302. if mm_results == nil {
  1303. mmGetByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetByPlaceID")
  1304. }
  1305. return (*mm_results).ta1, (*mm_results).err
  1306. }
  1307. if mmGetByPlaceID.funcGetByPlaceID != nil {
  1308. return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
  1309. }
  1310. mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, id)
  1311. return
  1312. }
  1313. // GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations
  1314. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
  1315. return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
  1316. }
  1317. // GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations
  1318. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
  1319. return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
  1320. }
  1321. // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID.
  1322. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1323. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams {
  1324. mmGetByPlaceID.mutex.RLock()
  1325. argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
  1326. copy(argCopy, mmGetByPlaceID.callArgs)
  1327. mmGetByPlaceID.mutex.RUnlock()
  1328. return argCopy
  1329. }
  1330. // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
  1331. // the number of defined expectations
  1332. func (m *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool {
  1333. if m.GetByPlaceIDMock.optional {
  1334. // Optional methods provide '0 or more' call count restriction.
  1335. return true
  1336. }
  1337. for _, e := range m.GetByPlaceIDMock.expectations {
  1338. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1339. return false
  1340. }
  1341. }
  1342. return m.GetByPlaceIDMock.invocationsDone()
  1343. }
  1344. // MinimockGetByPlaceIDInspect logs each unmet expectation
  1345. func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() {
  1346. for _, e := range m.GetByPlaceIDMock.expectations {
  1347. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1348. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params)
  1349. }
  1350. }
  1351. afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
  1352. // if default expectation was set then invocations count should be greater than zero
  1353. if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
  1354. if m.GetByPlaceIDMock.defaultExpectation.params == nil {
  1355. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  1356. } else {
  1357. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
  1358. }
  1359. }
  1360. // if func was set then invocations count should be greater than zero
  1361. if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
  1362. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  1363. }
  1364. if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
  1365. m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetByPlaceID but found %d calls",
  1366. mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
  1367. }
  1368. }
  1369. type mThingRepositoryMockSearch struct {
  1370. optional bool
  1371. mock *ThingRepositoryMock
  1372. defaultExpectation *ThingRepositoryMockSearchExpectation
  1373. expectations []*ThingRepositoryMockSearchExpectation
  1374. callArgs []*ThingRepositoryMockSearchParams
  1375. mutex sync.RWMutex
  1376. expectedInvocations uint64
  1377. }
  1378. // ThingRepositoryMockSearchExpectation specifies expectation struct of the ThingRepository.Search
  1379. type ThingRepositoryMockSearchExpectation struct {
  1380. mock *ThingRepositoryMock
  1381. params *ThingRepositoryMockSearchParams
  1382. paramPtrs *ThingRepositoryMockSearchParamPtrs
  1383. results *ThingRepositoryMockSearchResults
  1384. Counter uint64
  1385. }
  1386. // ThingRepositoryMockSearchParams contains parameters of the ThingRepository.Search
  1387. type ThingRepositoryMockSearchParams struct {
  1388. ctx context.Context
  1389. search string
  1390. }
  1391. // ThingRepositoryMockSearchParamPtrs contains pointers to parameters of the ThingRepository.Search
  1392. type ThingRepositoryMockSearchParamPtrs struct {
  1393. ctx *context.Context
  1394. search *string
  1395. }
  1396. // ThingRepositoryMockSearchResults contains results of the ThingRepository.Search
  1397. type ThingRepositoryMockSearchResults struct {
  1398. ta1 []models.Thing
  1399. err error
  1400. }
  1401. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1402. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1403. // Optional() makes method check to work in '0 or more' mode.
  1404. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1405. // catch the problems when the expected method call is totally skipped during test run.
  1406. func (mmSearch *mThingRepositoryMockSearch) Optional() *mThingRepositoryMockSearch {
  1407. mmSearch.optional = true
  1408. return mmSearch
  1409. }
  1410. // Expect sets up expected params for ThingRepository.Search
  1411. func (mmSearch *mThingRepositoryMockSearch) Expect(ctx context.Context, search string) *mThingRepositoryMockSearch {
  1412. if mmSearch.mock.funcSearch != nil {
  1413. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1414. }
  1415. if mmSearch.defaultExpectation == nil {
  1416. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
  1417. }
  1418. if mmSearch.defaultExpectation.paramPtrs != nil {
  1419. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by ExpectParams functions")
  1420. }
  1421. mmSearch.defaultExpectation.params = &ThingRepositoryMockSearchParams{ctx, search}
  1422. for _, e := range mmSearch.expectations {
  1423. if minimock.Equal(e.params, mmSearch.defaultExpectation.params) {
  1424. mmSearch.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSearch.defaultExpectation.params)
  1425. }
  1426. }
  1427. return mmSearch
  1428. }
  1429. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Search
  1430. func (mmSearch *mThingRepositoryMockSearch) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockSearch {
  1431. if mmSearch.mock.funcSearch != nil {
  1432. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1433. }
  1434. if mmSearch.defaultExpectation == nil {
  1435. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
  1436. }
  1437. if mmSearch.defaultExpectation.params != nil {
  1438. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
  1439. }
  1440. if mmSearch.defaultExpectation.paramPtrs == nil {
  1441. mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
  1442. }
  1443. mmSearch.defaultExpectation.paramPtrs.ctx = &ctx
  1444. return mmSearch
  1445. }
  1446. // ExpectSearchParam2 sets up expected param search for ThingRepository.Search
  1447. func (mmSearch *mThingRepositoryMockSearch) ExpectSearchParam2(search string) *mThingRepositoryMockSearch {
  1448. if mmSearch.mock.funcSearch != nil {
  1449. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1450. }
  1451. if mmSearch.defaultExpectation == nil {
  1452. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
  1453. }
  1454. if mmSearch.defaultExpectation.params != nil {
  1455. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
  1456. }
  1457. if mmSearch.defaultExpectation.paramPtrs == nil {
  1458. mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
  1459. }
  1460. mmSearch.defaultExpectation.paramPtrs.search = &search
  1461. return mmSearch
  1462. }
  1463. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Search
  1464. func (mmSearch *mThingRepositoryMockSearch) Inspect(f func(ctx context.Context, search string)) *mThingRepositoryMockSearch {
  1465. if mmSearch.mock.inspectFuncSearch != nil {
  1466. mmSearch.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Search")
  1467. }
  1468. mmSearch.mock.inspectFuncSearch = f
  1469. return mmSearch
  1470. }
  1471. // Return sets up results that will be returned by ThingRepository.Search
  1472. func (mmSearch *mThingRepositoryMockSearch) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1473. if mmSearch.mock.funcSearch != nil {
  1474. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1475. }
  1476. if mmSearch.defaultExpectation == nil {
  1477. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{mock: mmSearch.mock}
  1478. }
  1479. mmSearch.defaultExpectation.results = &ThingRepositoryMockSearchResults{ta1, err}
  1480. return mmSearch.mock
  1481. }
  1482. // Set uses given function f to mock the ThingRepository.Search method
  1483. func (mmSearch *mThingRepositoryMockSearch) Set(f func(ctx context.Context, search string) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  1484. if mmSearch.defaultExpectation != nil {
  1485. mmSearch.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Search method")
  1486. }
  1487. if len(mmSearch.expectations) > 0 {
  1488. mmSearch.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Search method")
  1489. }
  1490. mmSearch.mock.funcSearch = f
  1491. return mmSearch.mock
  1492. }
  1493. // When sets expectation for the ThingRepository.Search which will trigger the result defined by the following
  1494. // Then helper
  1495. func (mmSearch *mThingRepositoryMockSearch) When(ctx context.Context, search string) *ThingRepositoryMockSearchExpectation {
  1496. if mmSearch.mock.funcSearch != nil {
  1497. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1498. }
  1499. expectation := &ThingRepositoryMockSearchExpectation{
  1500. mock: mmSearch.mock,
  1501. params: &ThingRepositoryMockSearchParams{ctx, search},
  1502. }
  1503. mmSearch.expectations = append(mmSearch.expectations, expectation)
  1504. return expectation
  1505. }
  1506. // Then sets up ThingRepository.Search return parameters for the expectation previously defined by the When method
  1507. func (e *ThingRepositoryMockSearchExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1508. e.results = &ThingRepositoryMockSearchResults{ta1, err}
  1509. return e.mock
  1510. }
  1511. // Times sets number of times ThingRepository.Search should be invoked
  1512. func (mmSearch *mThingRepositoryMockSearch) Times(n uint64) *mThingRepositoryMockSearch {
  1513. if n == 0 {
  1514. mmSearch.mock.t.Fatalf("Times of ThingRepositoryMock.Search mock can not be zero")
  1515. }
  1516. mm_atomic.StoreUint64(&mmSearch.expectedInvocations, n)
  1517. return mmSearch
  1518. }
  1519. func (mmSearch *mThingRepositoryMockSearch) invocationsDone() bool {
  1520. if len(mmSearch.expectations) == 0 && mmSearch.defaultExpectation == nil && mmSearch.mock.funcSearch == nil {
  1521. return true
  1522. }
  1523. totalInvocations := mm_atomic.LoadUint64(&mmSearch.mock.afterSearchCounter)
  1524. expectedInvocations := mm_atomic.LoadUint64(&mmSearch.expectedInvocations)
  1525. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1526. }
  1527. // Search implements thing.ThingRepository
  1528. func (mmSearch *ThingRepositoryMock) Search(ctx context.Context, search string) (ta1 []models.Thing, err error) {
  1529. mm_atomic.AddUint64(&mmSearch.beforeSearchCounter, 1)
  1530. defer mm_atomic.AddUint64(&mmSearch.afterSearchCounter, 1)
  1531. if mmSearch.inspectFuncSearch != nil {
  1532. mmSearch.inspectFuncSearch(ctx, search)
  1533. }
  1534. mm_params := ThingRepositoryMockSearchParams{ctx, search}
  1535. // Record call args
  1536. mmSearch.SearchMock.mutex.Lock()
  1537. mmSearch.SearchMock.callArgs = append(mmSearch.SearchMock.callArgs, &mm_params)
  1538. mmSearch.SearchMock.mutex.Unlock()
  1539. for _, e := range mmSearch.SearchMock.expectations {
  1540. if minimock.Equal(*e.params, mm_params) {
  1541. mm_atomic.AddUint64(&e.Counter, 1)
  1542. return e.results.ta1, e.results.err
  1543. }
  1544. }
  1545. if mmSearch.SearchMock.defaultExpectation != nil {
  1546. mm_atomic.AddUint64(&mmSearch.SearchMock.defaultExpectation.Counter, 1)
  1547. mm_want := mmSearch.SearchMock.defaultExpectation.params
  1548. mm_want_ptrs := mmSearch.SearchMock.defaultExpectation.paramPtrs
  1549. mm_got := ThingRepositoryMockSearchParams{ctx, search}
  1550. if mm_want_ptrs != nil {
  1551. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1552. 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))
  1553. }
  1554. if mm_want_ptrs.search != nil && !minimock.Equal(*mm_want_ptrs.search, mm_got.search) {
  1555. 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))
  1556. }
  1557. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1558. mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1559. }
  1560. mm_results := mmSearch.SearchMock.defaultExpectation.results
  1561. if mm_results == nil {
  1562. mmSearch.t.Fatal("No results are set for the ThingRepositoryMock.Search")
  1563. }
  1564. return (*mm_results).ta1, (*mm_results).err
  1565. }
  1566. if mmSearch.funcSearch != nil {
  1567. return mmSearch.funcSearch(ctx, search)
  1568. }
  1569. mmSearch.t.Fatalf("Unexpected call to ThingRepositoryMock.Search. %v %v", ctx, search)
  1570. return
  1571. }
  1572. // SearchAfterCounter returns a count of finished ThingRepositoryMock.Search invocations
  1573. func (mmSearch *ThingRepositoryMock) SearchAfterCounter() uint64 {
  1574. return mm_atomic.LoadUint64(&mmSearch.afterSearchCounter)
  1575. }
  1576. // SearchBeforeCounter returns a count of ThingRepositoryMock.Search invocations
  1577. func (mmSearch *ThingRepositoryMock) SearchBeforeCounter() uint64 {
  1578. return mm_atomic.LoadUint64(&mmSearch.beforeSearchCounter)
  1579. }
  1580. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Search.
  1581. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1582. func (mmSearch *mThingRepositoryMockSearch) Calls() []*ThingRepositoryMockSearchParams {
  1583. mmSearch.mutex.RLock()
  1584. argCopy := make([]*ThingRepositoryMockSearchParams, len(mmSearch.callArgs))
  1585. copy(argCopy, mmSearch.callArgs)
  1586. mmSearch.mutex.RUnlock()
  1587. return argCopy
  1588. }
  1589. // MinimockSearchDone returns true if the count of the Search invocations corresponds
  1590. // the number of defined expectations
  1591. func (m *ThingRepositoryMock) MinimockSearchDone() bool {
  1592. if m.SearchMock.optional {
  1593. // Optional methods provide '0 or more' call count restriction.
  1594. return true
  1595. }
  1596. for _, e := range m.SearchMock.expectations {
  1597. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1598. return false
  1599. }
  1600. }
  1601. return m.SearchMock.invocationsDone()
  1602. }
  1603. // MinimockSearchInspect logs each unmet expectation
  1604. func (m *ThingRepositoryMock) MinimockSearchInspect() {
  1605. for _, e := range m.SearchMock.expectations {
  1606. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1607. m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *e.params)
  1608. }
  1609. }
  1610. afterSearchCounter := mm_atomic.LoadUint64(&m.afterSearchCounter)
  1611. // if default expectation was set then invocations count should be greater than zero
  1612. if m.SearchMock.defaultExpectation != nil && afterSearchCounter < 1 {
  1613. if m.SearchMock.defaultExpectation.params == nil {
  1614. m.t.Error("Expected call to ThingRepositoryMock.Search")
  1615. } else {
  1616. m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *m.SearchMock.defaultExpectation.params)
  1617. }
  1618. }
  1619. // if func was set then invocations count should be greater than zero
  1620. if m.funcSearch != nil && afterSearchCounter < 1 {
  1621. m.t.Error("Expected call to ThingRepositoryMock.Search")
  1622. }
  1623. if !m.SearchMock.invocationsDone() && afterSearchCounter > 0 {
  1624. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Search but found %d calls",
  1625. mm_atomic.LoadUint64(&m.SearchMock.expectedInvocations), afterSearchCounter)
  1626. }
  1627. }
  1628. type mThingRepositoryMockUpdate struct {
  1629. optional bool
  1630. mock *ThingRepositoryMock
  1631. defaultExpectation *ThingRepositoryMockUpdateExpectation
  1632. expectations []*ThingRepositoryMockUpdateExpectation
  1633. callArgs []*ThingRepositoryMockUpdateParams
  1634. mutex sync.RWMutex
  1635. expectedInvocations uint64
  1636. }
  1637. // ThingRepositoryMockUpdateExpectation specifies expectation struct of the ThingRepository.Update
  1638. type ThingRepositoryMockUpdateExpectation struct {
  1639. mock *ThingRepositoryMock
  1640. params *ThingRepositoryMockUpdateParams
  1641. paramPtrs *ThingRepositoryMockUpdateParamPtrs
  1642. results *ThingRepositoryMockUpdateResults
  1643. Counter uint64
  1644. }
  1645. // ThingRepositoryMockUpdateParams contains parameters of the ThingRepository.Update
  1646. type ThingRepositoryMockUpdateParams struct {
  1647. ctx context.Context
  1648. req models.UpdateThingRequest
  1649. }
  1650. // ThingRepositoryMockUpdateParamPtrs contains pointers to parameters of the ThingRepository.Update
  1651. type ThingRepositoryMockUpdateParamPtrs struct {
  1652. ctx *context.Context
  1653. req *models.UpdateThingRequest
  1654. }
  1655. // ThingRepositoryMockUpdateResults contains results of the ThingRepository.Update
  1656. type ThingRepositoryMockUpdateResults struct {
  1657. err error
  1658. }
  1659. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1660. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1661. // Optional() makes method check to work in '0 or more' mode.
  1662. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1663. // catch the problems when the expected method call is totally skipped during test run.
  1664. func (mmUpdate *mThingRepositoryMockUpdate) Optional() *mThingRepositoryMockUpdate {
  1665. mmUpdate.optional = true
  1666. return mmUpdate
  1667. }
  1668. // Expect sets up expected params for ThingRepository.Update
  1669. func (mmUpdate *mThingRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingRequest) *mThingRepositoryMockUpdate {
  1670. if mmUpdate.mock.funcUpdate != nil {
  1671. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1672. }
  1673. if mmUpdate.defaultExpectation == nil {
  1674. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  1675. }
  1676. if mmUpdate.defaultExpectation.paramPtrs != nil {
  1677. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by ExpectParams functions")
  1678. }
  1679. mmUpdate.defaultExpectation.params = &ThingRepositoryMockUpdateParams{ctx, req}
  1680. for _, e := range mmUpdate.expectations {
  1681. if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
  1682. mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
  1683. }
  1684. }
  1685. return mmUpdate
  1686. }
  1687. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Update
  1688. func (mmUpdate *mThingRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockUpdate {
  1689. if mmUpdate.mock.funcUpdate != nil {
  1690. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1691. }
  1692. if mmUpdate.defaultExpectation == nil {
  1693. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  1694. }
  1695. if mmUpdate.defaultExpectation.params != nil {
  1696. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
  1697. }
  1698. if mmUpdate.defaultExpectation.paramPtrs == nil {
  1699. mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
  1700. }
  1701. mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx
  1702. return mmUpdate
  1703. }
  1704. // ExpectReqParam2 sets up expected param req for ThingRepository.Update
  1705. func (mmUpdate *mThingRepositoryMockUpdate) ExpectReqParam2(req models.UpdateThingRequest) *mThingRepositoryMockUpdate {
  1706. if mmUpdate.mock.funcUpdate != nil {
  1707. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1708. }
  1709. if mmUpdate.defaultExpectation == nil {
  1710. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  1711. }
  1712. if mmUpdate.defaultExpectation.params != nil {
  1713. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
  1714. }
  1715. if mmUpdate.defaultExpectation.paramPtrs == nil {
  1716. mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
  1717. }
  1718. mmUpdate.defaultExpectation.paramPtrs.req = &req
  1719. return mmUpdate
  1720. }
  1721. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Update
  1722. func (mmUpdate *mThingRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingRequest)) *mThingRepositoryMockUpdate {
  1723. if mmUpdate.mock.inspectFuncUpdate != nil {
  1724. mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Update")
  1725. }
  1726. mmUpdate.mock.inspectFuncUpdate = f
  1727. return mmUpdate
  1728. }
  1729. // Return sets up results that will be returned by ThingRepository.Update
  1730. func (mmUpdate *mThingRepositoryMockUpdate) Return(err error) *ThingRepositoryMock {
  1731. if mmUpdate.mock.funcUpdate != nil {
  1732. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1733. }
  1734. if mmUpdate.defaultExpectation == nil {
  1735. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
  1736. }
  1737. mmUpdate.defaultExpectation.results = &ThingRepositoryMockUpdateResults{err}
  1738. return mmUpdate.mock
  1739. }
  1740. // Set uses given function f to mock the ThingRepository.Update method
  1741. func (mmUpdate *mThingRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingRequest) (err error)) *ThingRepositoryMock {
  1742. if mmUpdate.defaultExpectation != nil {
  1743. mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Update method")
  1744. }
  1745. if len(mmUpdate.expectations) > 0 {
  1746. mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Update method")
  1747. }
  1748. mmUpdate.mock.funcUpdate = f
  1749. return mmUpdate.mock
  1750. }
  1751. // When sets expectation for the ThingRepository.Update which will trigger the result defined by the following
  1752. // Then helper
  1753. func (mmUpdate *mThingRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingRequest) *ThingRepositoryMockUpdateExpectation {
  1754. if mmUpdate.mock.funcUpdate != nil {
  1755. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1756. }
  1757. expectation := &ThingRepositoryMockUpdateExpectation{
  1758. mock: mmUpdate.mock,
  1759. params: &ThingRepositoryMockUpdateParams{ctx, req},
  1760. }
  1761. mmUpdate.expectations = append(mmUpdate.expectations, expectation)
  1762. return expectation
  1763. }
  1764. // Then sets up ThingRepository.Update return parameters for the expectation previously defined by the When method
  1765. func (e *ThingRepositoryMockUpdateExpectation) Then(err error) *ThingRepositoryMock {
  1766. e.results = &ThingRepositoryMockUpdateResults{err}
  1767. return e.mock
  1768. }
  1769. // Times sets number of times ThingRepository.Update should be invoked
  1770. func (mmUpdate *mThingRepositoryMockUpdate) Times(n uint64) *mThingRepositoryMockUpdate {
  1771. if n == 0 {
  1772. mmUpdate.mock.t.Fatalf("Times of ThingRepositoryMock.Update mock can not be zero")
  1773. }
  1774. mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
  1775. return mmUpdate
  1776. }
  1777. func (mmUpdate *mThingRepositoryMockUpdate) invocationsDone() bool {
  1778. if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
  1779. return true
  1780. }
  1781. totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
  1782. expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)
  1783. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1784. }
  1785. // Update implements thing.ThingRepository
  1786. func (mmUpdate *ThingRepositoryMock) Update(ctx context.Context, req models.UpdateThingRequest) (err error) {
  1787. mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
  1788. defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
  1789. if mmUpdate.inspectFuncUpdate != nil {
  1790. mmUpdate.inspectFuncUpdate(ctx, req)
  1791. }
  1792. mm_params := ThingRepositoryMockUpdateParams{ctx, req}
  1793. // Record call args
  1794. mmUpdate.UpdateMock.mutex.Lock()
  1795. mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, &mm_params)
  1796. mmUpdate.UpdateMock.mutex.Unlock()
  1797. for _, e := range mmUpdate.UpdateMock.expectations {
  1798. if minimock.Equal(*e.params, mm_params) {
  1799. mm_atomic.AddUint64(&e.Counter, 1)
  1800. return e.results.err
  1801. }
  1802. }
  1803. if mmUpdate.UpdateMock.defaultExpectation != nil {
  1804. mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
  1805. mm_want := mmUpdate.UpdateMock.defaultExpectation.params
  1806. mm_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs
  1807. mm_got := ThingRepositoryMockUpdateParams{ctx, req}
  1808. if mm_want_ptrs != nil {
  1809. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1810. 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))
  1811. }
  1812. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  1813. 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))
  1814. }
  1815. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1816. mmUpdate.t.Errorf("ThingRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1817. }
  1818. mm_results := mmUpdate.UpdateMock.defaultExpectation.results
  1819. if mm_results == nil {
  1820. mmUpdate.t.Fatal("No results are set for the ThingRepositoryMock.Update")
  1821. }
  1822. return (*mm_results).err
  1823. }
  1824. if mmUpdate.funcUpdate != nil {
  1825. return mmUpdate.funcUpdate(ctx, req)
  1826. }
  1827. mmUpdate.t.Fatalf("Unexpected call to ThingRepositoryMock.Update. %v %v", ctx, req)
  1828. return
  1829. }
  1830. // UpdateAfterCounter returns a count of finished ThingRepositoryMock.Update invocations
  1831. func (mmUpdate *ThingRepositoryMock) UpdateAfterCounter() uint64 {
  1832. return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
  1833. }
  1834. // UpdateBeforeCounter returns a count of ThingRepositoryMock.Update invocations
  1835. func (mmUpdate *ThingRepositoryMock) UpdateBeforeCounter() uint64 {
  1836. return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
  1837. }
  1838. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Update.
  1839. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1840. func (mmUpdate *mThingRepositoryMockUpdate) Calls() []*ThingRepositoryMockUpdateParams {
  1841. mmUpdate.mutex.RLock()
  1842. argCopy := make([]*ThingRepositoryMockUpdateParams, len(mmUpdate.callArgs))
  1843. copy(argCopy, mmUpdate.callArgs)
  1844. mmUpdate.mutex.RUnlock()
  1845. return argCopy
  1846. }
  1847. // MinimockUpdateDone returns true if the count of the Update invocations corresponds
  1848. // the number of defined expectations
  1849. func (m *ThingRepositoryMock) MinimockUpdateDone() bool {
  1850. if m.UpdateMock.optional {
  1851. // Optional methods provide '0 or more' call count restriction.
  1852. return true
  1853. }
  1854. for _, e := range m.UpdateMock.expectations {
  1855. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1856. return false
  1857. }
  1858. }
  1859. return m.UpdateMock.invocationsDone()
  1860. }
  1861. // MinimockUpdateInspect logs each unmet expectation
  1862. func (m *ThingRepositoryMock) MinimockUpdateInspect() {
  1863. for _, e := range m.UpdateMock.expectations {
  1864. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1865. m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *e.params)
  1866. }
  1867. }
  1868. afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
  1869. // if default expectation was set then invocations count should be greater than zero
  1870. if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
  1871. if m.UpdateMock.defaultExpectation.params == nil {
  1872. m.t.Error("Expected call to ThingRepositoryMock.Update")
  1873. } else {
  1874. m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
  1875. }
  1876. }
  1877. // if func was set then invocations count should be greater than zero
  1878. if m.funcUpdate != nil && afterUpdateCounter < 1 {
  1879. m.t.Error("Expected call to ThingRepositoryMock.Update")
  1880. }
  1881. if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
  1882. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Update but found %d calls",
  1883. mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
  1884. }
  1885. }
  1886. // MinimockFinish checks that all mocked methods have been called the expected number of times
  1887. func (m *ThingRepositoryMock) MinimockFinish() {
  1888. m.finishOnce.Do(func() {
  1889. if !m.minimockDone() {
  1890. m.MinimockAddInspect()
  1891. m.MinimockDeleteInspect()
  1892. m.MinimockGetInspect()
  1893. m.MinimockGetAllByPlaceIDInspect()
  1894. m.MinimockGetByPlaceIDInspect()
  1895. m.MinimockSearchInspect()
  1896. m.MinimockUpdateInspect()
  1897. }
  1898. })
  1899. }
  1900. // MinimockWait waits for all mocked methods to be called the expected number of times
  1901. func (m *ThingRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  1902. timeoutCh := mm_time.After(timeout)
  1903. for {
  1904. if m.minimockDone() {
  1905. return
  1906. }
  1907. select {
  1908. case <-timeoutCh:
  1909. m.MinimockFinish()
  1910. return
  1911. case <-mm_time.After(10 * mm_time.Millisecond):
  1912. }
  1913. }
  1914. }
  1915. func (m *ThingRepositoryMock) minimockDone() bool {
  1916. done := true
  1917. return done &&
  1918. m.MinimockAddDone() &&
  1919. m.MinimockDeleteDone() &&
  1920. m.MinimockGetDone() &&
  1921. m.MinimockGetAllByPlaceIDDone() &&
  1922. m.MinimockGetByPlaceIDDone() &&
  1923. m.MinimockSearchDone() &&
  1924. m.MinimockUpdateDone()
  1925. }