place_image_repository_minimock.go 80 KB

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