thing_image_repository_minimock.go 95 KB

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