place_repository_minimock.go 75 KB

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