place_repository_minimock.go 103 KB

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