place_image_repository_minimock.go 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  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.PlaceImageRepository -o place_image_repository_minimock.go -n PlaceImageRepositoryMock -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. // PlaceImageRepositoryMock implements place.PlaceImageRepository
  13. type PlaceImageRepositoryMock struct {
  14. t minimock.Tester
  15. finishOnce sync.Once
  16. funcDelete func(ctx context.Context, id uint64) (err error)
  17. inspectFuncDelete func(ctx context.Context, id uint64)
  18. afterDeleteCounter uint64
  19. beforeDeleteCounter uint64
  20. DeleteMock mPlaceImageRepositoryMockDelete
  21. funcGetByPlaceID func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
  22. inspectFuncGetByPlaceID func(ctx context.Context, id uint64)
  23. afterGetByPlaceIDCounter uint64
  24. beforeGetByPlaceIDCounter uint64
  25. GetByPlaceIDMock mPlaceImageRepositoryMockGetByPlaceID
  26. }
  27. // NewPlaceImageRepositoryMock returns a mock for place.PlaceImageRepository
  28. func NewPlaceImageRepositoryMock(t minimock.Tester) *PlaceImageRepositoryMock {
  29. m := &PlaceImageRepositoryMock{t: t}
  30. if controller, ok := t.(minimock.MockController); ok {
  31. controller.RegisterMocker(m)
  32. }
  33. m.DeleteMock = mPlaceImageRepositoryMockDelete{mock: m}
  34. m.DeleteMock.callArgs = []*PlaceImageRepositoryMockDeleteParams{}
  35. m.GetByPlaceIDMock = mPlaceImageRepositoryMockGetByPlaceID{mock: m}
  36. m.GetByPlaceIDMock.callArgs = []*PlaceImageRepositoryMockGetByPlaceIDParams{}
  37. t.Cleanup(m.MinimockFinish)
  38. return m
  39. }
  40. type mPlaceImageRepositoryMockDelete struct {
  41. optional bool
  42. mock *PlaceImageRepositoryMock
  43. defaultExpectation *PlaceImageRepositoryMockDeleteExpectation
  44. expectations []*PlaceImageRepositoryMockDeleteExpectation
  45. callArgs []*PlaceImageRepositoryMockDeleteParams
  46. mutex sync.RWMutex
  47. expectedInvocations uint64
  48. }
  49. // PlaceImageRepositoryMockDeleteExpectation specifies expectation struct of the PlaceImageRepository.Delete
  50. type PlaceImageRepositoryMockDeleteExpectation struct {
  51. mock *PlaceImageRepositoryMock
  52. params *PlaceImageRepositoryMockDeleteParams
  53. paramPtrs *PlaceImageRepositoryMockDeleteParamPtrs
  54. results *PlaceImageRepositoryMockDeleteResults
  55. Counter uint64
  56. }
  57. // PlaceImageRepositoryMockDeleteParams contains parameters of the PlaceImageRepository.Delete
  58. type PlaceImageRepositoryMockDeleteParams struct {
  59. ctx context.Context
  60. id uint64
  61. }
  62. // PlaceImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the PlaceImageRepository.Delete
  63. type PlaceImageRepositoryMockDeleteParamPtrs struct {
  64. ctx *context.Context
  65. id *uint64
  66. }
  67. // PlaceImageRepositoryMockDeleteResults contains results of the PlaceImageRepository.Delete
  68. type PlaceImageRepositoryMockDeleteResults struct {
  69. err error
  70. }
  71. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  72. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  73. // Optional() makes method check to work in '0 or more' mode.
  74. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  75. // catch the problems when the expected method call is totally skipped during test run.
  76. func (mmDelete *mPlaceImageRepositoryMockDelete) Optional() *mPlaceImageRepositoryMockDelete {
  77. mmDelete.optional = true
  78. return mmDelete
  79. }
  80. // Expect sets up expected params for PlaceImageRepository.Delete
  81. func (mmDelete *mPlaceImageRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mPlaceImageRepositoryMockDelete {
  82. if mmDelete.mock.funcDelete != nil {
  83. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
  84. }
  85. if mmDelete.defaultExpectation == nil {
  86. mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{}
  87. }
  88. if mmDelete.defaultExpectation.paramPtrs != nil {
  89. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by ExpectParams functions")
  90. }
  91. mmDelete.defaultExpectation.params = &PlaceImageRepositoryMockDeleteParams{ctx, id}
  92. for _, e := range mmDelete.expectations {
  93. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  94. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  95. }
  96. }
  97. return mmDelete
  98. }
  99. // ExpectCtxParam1 sets up expected param ctx for PlaceImageRepository.Delete
  100. func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockDelete {
  101. if mmDelete.mock.funcDelete != nil {
  102. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
  103. }
  104. if mmDelete.defaultExpectation == nil {
  105. mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{}
  106. }
  107. if mmDelete.defaultExpectation.params != nil {
  108. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect")
  109. }
  110. if mmDelete.defaultExpectation.paramPtrs == nil {
  111. mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{}
  112. }
  113. mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
  114. return mmDelete
  115. }
  116. // ExpectIdParam2 sets up expected param id for PlaceImageRepository.Delete
  117. func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectIdParam2(id uint64) *mPlaceImageRepositoryMockDelete {
  118. if mmDelete.mock.funcDelete != nil {
  119. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
  120. }
  121. if mmDelete.defaultExpectation == nil {
  122. mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{}
  123. }
  124. if mmDelete.defaultExpectation.params != nil {
  125. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect")
  126. }
  127. if mmDelete.defaultExpectation.paramPtrs == nil {
  128. mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{}
  129. }
  130. mmDelete.defaultExpectation.paramPtrs.id = &id
  131. return mmDelete
  132. }
  133. // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.Delete
  134. func (mmDelete *mPlaceImageRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mPlaceImageRepositoryMockDelete {
  135. if mmDelete.mock.inspectFuncDelete != nil {
  136. mmDelete.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.Delete")
  137. }
  138. mmDelete.mock.inspectFuncDelete = f
  139. return mmDelete
  140. }
  141. // Return sets up results that will be returned by PlaceImageRepository.Delete
  142. func (mmDelete *mPlaceImageRepositoryMockDelete) Return(err error) *PlaceImageRepositoryMock {
  143. if mmDelete.mock.funcDelete != nil {
  144. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
  145. }
  146. if mmDelete.defaultExpectation == nil {
  147. mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  148. }
  149. mmDelete.defaultExpectation.results = &PlaceImageRepositoryMockDeleteResults{err}
  150. return mmDelete.mock
  151. }
  152. // Set uses given function f to mock the PlaceImageRepository.Delete method
  153. func (mmDelete *mPlaceImageRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *PlaceImageRepositoryMock {
  154. if mmDelete.defaultExpectation != nil {
  155. mmDelete.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.Delete method")
  156. }
  157. if len(mmDelete.expectations) > 0 {
  158. mmDelete.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.Delete method")
  159. }
  160. mmDelete.mock.funcDelete = f
  161. return mmDelete.mock
  162. }
  163. // When sets expectation for the PlaceImageRepository.Delete which will trigger the result defined by the following
  164. // Then helper
  165. func (mmDelete *mPlaceImageRepositoryMockDelete) When(ctx context.Context, id uint64) *PlaceImageRepositoryMockDeleteExpectation {
  166. if mmDelete.mock.funcDelete != nil {
  167. mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
  168. }
  169. expectation := &PlaceImageRepositoryMockDeleteExpectation{
  170. mock: mmDelete.mock,
  171. params: &PlaceImageRepositoryMockDeleteParams{ctx, id},
  172. }
  173. mmDelete.expectations = append(mmDelete.expectations, expectation)
  174. return expectation
  175. }
  176. // Then sets up PlaceImageRepository.Delete return parameters for the expectation previously defined by the When method
  177. func (e *PlaceImageRepositoryMockDeleteExpectation) Then(err error) *PlaceImageRepositoryMock {
  178. e.results = &PlaceImageRepositoryMockDeleteResults{err}
  179. return e.mock
  180. }
  181. // Times sets number of times PlaceImageRepository.Delete should be invoked
  182. func (mmDelete *mPlaceImageRepositoryMockDelete) Times(n uint64) *mPlaceImageRepositoryMockDelete {
  183. if n == 0 {
  184. mmDelete.mock.t.Fatalf("Times of PlaceImageRepositoryMock.Delete mock can not be zero")
  185. }
  186. mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
  187. return mmDelete
  188. }
  189. func (mmDelete *mPlaceImageRepositoryMockDelete) invocationsDone() bool {
  190. if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
  191. return true
  192. }
  193. totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
  194. expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
  195. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  196. }
  197. // Delete implements place.PlaceImageRepository
  198. func (mmDelete *PlaceImageRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
  199. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  200. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  201. if mmDelete.inspectFuncDelete != nil {
  202. mmDelete.inspectFuncDelete(ctx, id)
  203. }
  204. mm_params := PlaceImageRepositoryMockDeleteParams{ctx, id}
  205. // Record call args
  206. mmDelete.DeleteMock.mutex.Lock()
  207. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
  208. mmDelete.DeleteMock.mutex.Unlock()
  209. for _, e := range mmDelete.DeleteMock.expectations {
  210. if minimock.Equal(*e.params, mm_params) {
  211. mm_atomic.AddUint64(&e.Counter, 1)
  212. return e.results.err
  213. }
  214. }
  215. if mmDelete.DeleteMock.defaultExpectation != nil {
  216. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  217. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  218. mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
  219. mm_got := PlaceImageRepositoryMockDeleteParams{ctx, id}
  220. if mm_want_ptrs != nil {
  221. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  222. mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  223. }
  224. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  225. mmDelete.t.Errorf("PlaceImageRepositoryMock.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))
  226. }
  227. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  228. mmDelete.t.Errorf("PlaceImageRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  229. }
  230. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  231. if mm_results == nil {
  232. mmDelete.t.Fatal("No results are set for the PlaceImageRepositoryMock.Delete")
  233. }
  234. return (*mm_results).err
  235. }
  236. if mmDelete.funcDelete != nil {
  237. return mmDelete.funcDelete(ctx, id)
  238. }
  239. mmDelete.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.Delete. %v %v", ctx, id)
  240. return
  241. }
  242. // DeleteAfterCounter returns a count of finished PlaceImageRepositoryMock.Delete invocations
  243. func (mmDelete *PlaceImageRepositoryMock) DeleteAfterCounter() uint64 {
  244. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  245. }
  246. // DeleteBeforeCounter returns a count of PlaceImageRepositoryMock.Delete invocations
  247. func (mmDelete *PlaceImageRepositoryMock) DeleteBeforeCounter() uint64 {
  248. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  249. }
  250. // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.Delete.
  251. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  252. func (mmDelete *mPlaceImageRepositoryMockDelete) Calls() []*PlaceImageRepositoryMockDeleteParams {
  253. mmDelete.mutex.RLock()
  254. argCopy := make([]*PlaceImageRepositoryMockDeleteParams, len(mmDelete.callArgs))
  255. copy(argCopy, mmDelete.callArgs)
  256. mmDelete.mutex.RUnlock()
  257. return argCopy
  258. }
  259. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  260. // the number of defined expectations
  261. func (m *PlaceImageRepositoryMock) MinimockDeleteDone() bool {
  262. if m.DeleteMock.optional {
  263. // Optional methods provide '0 or more' call count restriction.
  264. return true
  265. }
  266. for _, e := range m.DeleteMock.expectations {
  267. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  268. return false
  269. }
  270. }
  271. return m.DeleteMock.invocationsDone()
  272. }
  273. // MinimockDeleteInspect logs each unmet expectation
  274. func (m *PlaceImageRepositoryMock) MinimockDeleteInspect() {
  275. for _, e := range m.DeleteMock.expectations {
  276. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  277. m.t.Errorf("Expected call to PlaceImageRepositoryMock.Delete with params: %#v", *e.params)
  278. }
  279. }
  280. afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
  281. // if default expectation was set then invocations count should be greater than zero
  282. if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
  283. if m.DeleteMock.defaultExpectation.params == nil {
  284. m.t.Error("Expected call to PlaceImageRepositoryMock.Delete")
  285. } else {
  286. m.t.Errorf("Expected call to PlaceImageRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  287. }
  288. }
  289. // if func was set then invocations count should be greater than zero
  290. if m.funcDelete != nil && afterDeleteCounter < 1 {
  291. m.t.Error("Expected call to PlaceImageRepositoryMock.Delete")
  292. }
  293. if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
  294. m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.Delete but found %d calls",
  295. mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
  296. }
  297. }
  298. type mPlaceImageRepositoryMockGetByPlaceID struct {
  299. optional bool
  300. mock *PlaceImageRepositoryMock
  301. defaultExpectation *PlaceImageRepositoryMockGetByPlaceIDExpectation
  302. expectations []*PlaceImageRepositoryMockGetByPlaceIDExpectation
  303. callArgs []*PlaceImageRepositoryMockGetByPlaceIDParams
  304. mutex sync.RWMutex
  305. expectedInvocations uint64
  306. }
  307. // PlaceImageRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the PlaceImageRepository.GetByPlaceID
  308. type PlaceImageRepositoryMockGetByPlaceIDExpectation struct {
  309. mock *PlaceImageRepositoryMock
  310. params *PlaceImageRepositoryMockGetByPlaceIDParams
  311. paramPtrs *PlaceImageRepositoryMockGetByPlaceIDParamPtrs
  312. results *PlaceImageRepositoryMockGetByPlaceIDResults
  313. Counter uint64
  314. }
  315. // PlaceImageRepositoryMockGetByPlaceIDParams contains parameters of the PlaceImageRepository.GetByPlaceID
  316. type PlaceImageRepositoryMockGetByPlaceIDParams struct {
  317. ctx context.Context
  318. id uint64
  319. }
  320. // PlaceImageRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the PlaceImageRepository.GetByPlaceID
  321. type PlaceImageRepositoryMockGetByPlaceIDParamPtrs struct {
  322. ctx *context.Context
  323. id *uint64
  324. }
  325. // PlaceImageRepositoryMockGetByPlaceIDResults contains results of the PlaceImageRepository.GetByPlaceID
  326. type PlaceImageRepositoryMockGetByPlaceIDResults struct {
  327. ia1 []models.Image
  328. err error
  329. }
  330. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  331. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  332. // Optional() makes method check to work in '0 or more' mode.
  333. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  334. // catch the problems when the expected method call is totally skipped during test run.
  335. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Optional() *mPlaceImageRepositoryMockGetByPlaceID {
  336. mmGetByPlaceID.optional = true
  337. return mmGetByPlaceID
  338. }
  339. // Expect sets up expected params for PlaceImageRepository.GetByPlaceID
  340. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mPlaceImageRepositoryMockGetByPlaceID {
  341. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  342. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
  343. }
  344. if mmGetByPlaceID.defaultExpectation == nil {
  345. mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{}
  346. }
  347. if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
  348. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
  349. }
  350. mmGetByPlaceID.defaultExpectation.params = &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id}
  351. for _, e := range mmGetByPlaceID.expectations {
  352. if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
  353. mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
  354. }
  355. }
  356. return mmGetByPlaceID
  357. }
  358. // ExpectCtxParam1 sets up expected param ctx for PlaceImageRepository.GetByPlaceID
  359. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockGetByPlaceID {
  360. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  361. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
  362. }
  363. if mmGetByPlaceID.defaultExpectation == nil {
  364. mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{}
  365. }
  366. if mmGetByPlaceID.defaultExpectation.params != nil {
  367. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Expect")
  368. }
  369. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  370. mmGetByPlaceID.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetByPlaceIDParamPtrs{}
  371. }
  372. mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
  373. return mmGetByPlaceID
  374. }
  375. // ExpectIdParam2 sets up expected param id for PlaceImageRepository.GetByPlaceID
  376. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mPlaceImageRepositoryMockGetByPlaceID {
  377. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  378. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
  379. }
  380. if mmGetByPlaceID.defaultExpectation == nil {
  381. mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{}
  382. }
  383. if mmGetByPlaceID.defaultExpectation.params != nil {
  384. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Expect")
  385. }
  386. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  387. mmGetByPlaceID.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetByPlaceIDParamPtrs{}
  388. }
  389. mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
  390. return mmGetByPlaceID
  391. }
  392. // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.GetByPlaceID
  393. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mPlaceImageRepositoryMockGetByPlaceID {
  394. if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
  395. mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.GetByPlaceID")
  396. }
  397. mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
  398. return mmGetByPlaceID
  399. }
  400. // Return sets up results that will be returned by PlaceImageRepository.GetByPlaceID
  401. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Return(ia1 []models.Image, err error) *PlaceImageRepositoryMock {
  402. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  403. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
  404. }
  405. if mmGetByPlaceID.defaultExpectation == nil {
  406. mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
  407. }
  408. mmGetByPlaceID.defaultExpectation.results = &PlaceImageRepositoryMockGetByPlaceIDResults{ia1, err}
  409. return mmGetByPlaceID.mock
  410. }
  411. // Set uses given function f to mock the PlaceImageRepository.GetByPlaceID method
  412. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *PlaceImageRepositoryMock {
  413. if mmGetByPlaceID.defaultExpectation != nil {
  414. mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.GetByPlaceID method")
  415. }
  416. if len(mmGetByPlaceID.expectations) > 0 {
  417. mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.GetByPlaceID method")
  418. }
  419. mmGetByPlaceID.mock.funcGetByPlaceID = f
  420. return mmGetByPlaceID.mock
  421. }
  422. // When sets expectation for the PlaceImageRepository.GetByPlaceID which will trigger the result defined by the following
  423. // Then helper
  424. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *PlaceImageRepositoryMockGetByPlaceIDExpectation {
  425. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  426. mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
  427. }
  428. expectation := &PlaceImageRepositoryMockGetByPlaceIDExpectation{
  429. mock: mmGetByPlaceID.mock,
  430. params: &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id},
  431. }
  432. mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
  433. return expectation
  434. }
  435. // Then sets up PlaceImageRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
  436. func (e *PlaceImageRepositoryMockGetByPlaceIDExpectation) Then(ia1 []models.Image, err error) *PlaceImageRepositoryMock {
  437. e.results = &PlaceImageRepositoryMockGetByPlaceIDResults{ia1, err}
  438. return e.mock
  439. }
  440. // Times sets number of times PlaceImageRepository.GetByPlaceID should be invoked
  441. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Times(n uint64) *mPlaceImageRepositoryMockGetByPlaceID {
  442. if n == 0 {
  443. mmGetByPlaceID.mock.t.Fatalf("Times of PlaceImageRepositoryMock.GetByPlaceID mock can not be zero")
  444. }
  445. mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
  446. return mmGetByPlaceID
  447. }
  448. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) invocationsDone() bool {
  449. if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
  450. return true
  451. }
  452. totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
  453. expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)
  454. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  455. }
  456. // GetByPlaceID implements place.PlaceImageRepository
  457. func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
  458. mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
  459. defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
  460. if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
  461. mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
  462. }
  463. mm_params := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id}
  464. // Record call args
  465. mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
  466. mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
  467. mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
  468. for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
  469. if minimock.Equal(*e.params, mm_params) {
  470. mm_atomic.AddUint64(&e.Counter, 1)
  471. return e.results.ia1, e.results.err
  472. }
  473. }
  474. if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
  475. mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
  476. mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
  477. mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
  478. mm_got := PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id}
  479. if mm_want_ptrs != nil {
  480. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  481. mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.GetByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  482. }
  483. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  484. mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  485. }
  486. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  487. mmGetByPlaceID.t.Errorf("PlaceImageRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  488. }
  489. mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
  490. if mm_results == nil {
  491. mmGetByPlaceID.t.Fatal("No results are set for the PlaceImageRepositoryMock.GetByPlaceID")
  492. }
  493. return (*mm_results).ia1, (*mm_results).err
  494. }
  495. if mmGetByPlaceID.funcGetByPlaceID != nil {
  496. return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
  497. }
  498. mmGetByPlaceID.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.GetByPlaceID. %v %v", ctx, id)
  499. return
  500. }
  501. // GetByPlaceIDAfterCounter returns a count of finished PlaceImageRepositoryMock.GetByPlaceID invocations
  502. func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
  503. return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
  504. }
  505. // GetByPlaceIDBeforeCounter returns a count of PlaceImageRepositoryMock.GetByPlaceID invocations
  506. func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
  507. return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
  508. }
  509. // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.GetByPlaceID.
  510. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  511. func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Calls() []*PlaceImageRepositoryMockGetByPlaceIDParams {
  512. mmGetByPlaceID.mutex.RLock()
  513. argCopy := make([]*PlaceImageRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
  514. copy(argCopy, mmGetByPlaceID.callArgs)
  515. mmGetByPlaceID.mutex.RUnlock()
  516. return argCopy
  517. }
  518. // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
  519. // the number of defined expectations
  520. func (m *PlaceImageRepositoryMock) MinimockGetByPlaceIDDone() bool {
  521. if m.GetByPlaceIDMock.optional {
  522. // Optional methods provide '0 or more' call count restriction.
  523. return true
  524. }
  525. for _, e := range m.GetByPlaceIDMock.expectations {
  526. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  527. return false
  528. }
  529. }
  530. return m.GetByPlaceIDMock.invocationsDone()
  531. }
  532. // MinimockGetByPlaceIDInspect logs each unmet expectation
  533. func (m *PlaceImageRepositoryMock) MinimockGetByPlaceIDInspect() {
  534. for _, e := range m.GetByPlaceIDMock.expectations {
  535. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  536. m.t.Errorf("Expected call to PlaceImageRepositoryMock.GetByPlaceID with params: %#v", *e.params)
  537. }
  538. }
  539. afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
  540. // if default expectation was set then invocations count should be greater than zero
  541. if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
  542. if m.GetByPlaceIDMock.defaultExpectation.params == nil {
  543. m.t.Error("Expected call to PlaceImageRepositoryMock.GetByPlaceID")
  544. } else {
  545. m.t.Errorf("Expected call to PlaceImageRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
  546. }
  547. }
  548. // if func was set then invocations count should be greater than zero
  549. if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
  550. m.t.Error("Expected call to PlaceImageRepositoryMock.GetByPlaceID")
  551. }
  552. if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
  553. m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.GetByPlaceID but found %d calls",
  554. mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
  555. }
  556. }
  557. // MinimockFinish checks that all mocked methods have been called the expected number of times
  558. func (m *PlaceImageRepositoryMock) MinimockFinish() {
  559. m.finishOnce.Do(func() {
  560. if !m.minimockDone() {
  561. m.MinimockDeleteInspect()
  562. m.MinimockGetByPlaceIDInspect()
  563. }
  564. })
  565. }
  566. // MinimockWait waits for all mocked methods to be called the expected number of times
  567. func (m *PlaceImageRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  568. timeoutCh := mm_time.After(timeout)
  569. for {
  570. if m.minimockDone() {
  571. return
  572. }
  573. select {
  574. case <-timeoutCh:
  575. m.MinimockFinish()
  576. return
  577. case <-mm_time.After(10 * mm_time.Millisecond):
  578. }
  579. }
  580. }
  581. func (m *PlaceImageRepositoryMock) minimockDone() bool {
  582. done := true
  583. return done &&
  584. m.MinimockDeleteDone() &&
  585. m.MinimockGetByPlaceIDDone()
  586. }