place_image_repository_minimock.go 30 KB

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