thing_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.ThingImageRepository -o thing_image_repository_minimock.go -n ThingImageRepositoryMock -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. // ThingImageRepositoryMock implements place.ThingImageRepository
  14. type ThingImageRepositoryMock 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 mThingImageRepositoryMockDelete
  22. funcGetByThingID func(ctx context.Context, thingID int) (ia1 []models.Image, err error)
  23. inspectFuncGetByThingID func(ctx context.Context, thingID int)
  24. afterGetByThingIDCounter uint64
  25. beforeGetByThingIDCounter uint64
  26. GetByThingIDMock mThingImageRepositoryMockGetByThingID
  27. }
  28. // NewThingImageRepositoryMock returns a mock for place.ThingImageRepository
  29. func NewThingImageRepositoryMock(t minimock.Tester) *ThingImageRepositoryMock {
  30. m := &ThingImageRepositoryMock{t: t}
  31. if controller, ok := t.(minimock.MockController); ok {
  32. controller.RegisterMocker(m)
  33. }
  34. m.DeleteMock = mThingImageRepositoryMockDelete{mock: m}
  35. m.DeleteMock.callArgs = []*ThingImageRepositoryMockDeleteParams{}
  36. m.GetByThingIDMock = mThingImageRepositoryMockGetByThingID{mock: m}
  37. m.GetByThingIDMock.callArgs = []*ThingImageRepositoryMockGetByThingIDParams{}
  38. t.Cleanup(m.MinimockFinish)
  39. return m
  40. }
  41. type mThingImageRepositoryMockDelete struct {
  42. optional bool
  43. mock *ThingImageRepositoryMock
  44. defaultExpectation *ThingImageRepositoryMockDeleteExpectation
  45. expectations []*ThingImageRepositoryMockDeleteExpectation
  46. callArgs []*ThingImageRepositoryMockDeleteParams
  47. mutex sync.RWMutex
  48. expectedInvocations uint64
  49. }
  50. // ThingImageRepositoryMockDeleteExpectation specifies expectation struct of the ThingImageRepository.Delete
  51. type ThingImageRepositoryMockDeleteExpectation struct {
  52. mock *ThingImageRepositoryMock
  53. params *ThingImageRepositoryMockDeleteParams
  54. paramPtrs *ThingImageRepositoryMockDeleteParamPtrs
  55. results *ThingImageRepositoryMockDeleteResults
  56. Counter uint64
  57. }
  58. // ThingImageRepositoryMockDeleteParams contains parameters of the ThingImageRepository.Delete
  59. type ThingImageRepositoryMockDeleteParams struct {
  60. ctx context.Context
  61. imageID int
  62. tx *sql.Tx
  63. }
  64. // ThingImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingImageRepository.Delete
  65. type ThingImageRepositoryMockDeleteParamPtrs struct {
  66. ctx *context.Context
  67. imageID *int
  68. tx **sql.Tx
  69. }
  70. // ThingImageRepositoryMockDeleteResults contains results of the ThingImageRepository.Delete
  71. type ThingImageRepositoryMockDeleteResults 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 *mThingImageRepositoryMockDelete) Optional() *mThingImageRepositoryMockDelete {
  80. mmDelete.optional = true
  81. return mmDelete
  82. }
  83. // Expect sets up expected params for ThingImageRepository.Delete
  84. func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, imageID int, tx *sql.Tx) *mThingImageRepositoryMockDelete {
  85. if mmDelete.mock.funcDelete != nil {
  86. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  87. }
  88. if mmDelete.defaultExpectation == nil {
  89. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
  90. }
  91. if mmDelete.defaultExpectation.paramPtrs != nil {
  92. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by ExpectParams functions")
  93. }
  94. mmDelete.defaultExpectation.params = &ThingImageRepositoryMockDeleteParams{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 ThingImageRepository.Delete
  103. func (mmDelete *mThingImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockDelete {
  104. if mmDelete.mock.funcDelete != nil {
  105. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  106. }
  107. if mmDelete.defaultExpectation == nil {
  108. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
  109. }
  110. if mmDelete.defaultExpectation.params != nil {
  111. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
  112. }
  113. if mmDelete.defaultExpectation.paramPtrs == nil {
  114. mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
  115. }
  116. mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
  117. return mmDelete
  118. }
  119. // ExpectImageIDParam2 sets up expected param imageID for ThingImageRepository.Delete
  120. func (mmDelete *mThingImageRepositoryMockDelete) ExpectImageIDParam2(imageID int) *mThingImageRepositoryMockDelete {
  121. if mmDelete.mock.funcDelete != nil {
  122. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  123. }
  124. if mmDelete.defaultExpectation == nil {
  125. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
  126. }
  127. if mmDelete.defaultExpectation.params != nil {
  128. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
  129. }
  130. if mmDelete.defaultExpectation.paramPtrs == nil {
  131. mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
  132. }
  133. mmDelete.defaultExpectation.paramPtrs.imageID = &imageID
  134. return mmDelete
  135. }
  136. // ExpectTxParam3 sets up expected param tx for ThingImageRepository.Delete
  137. func (mmDelete *mThingImageRepositoryMockDelete) ExpectTxParam3(tx *sql.Tx) *mThingImageRepositoryMockDelete {
  138. if mmDelete.mock.funcDelete != nil {
  139. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  140. }
  141. if mmDelete.defaultExpectation == nil {
  142. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
  143. }
  144. if mmDelete.defaultExpectation.params != nil {
  145. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
  146. }
  147. if mmDelete.defaultExpectation.paramPtrs == nil {
  148. mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
  149. }
  150. mmDelete.defaultExpectation.paramPtrs.tx = &tx
  151. return mmDelete
  152. }
  153. // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Delete
  154. func (mmDelete *mThingImageRepositoryMockDelete) Inspect(f func(ctx context.Context, imageID int, tx *sql.Tx)) *mThingImageRepositoryMockDelete {
  155. if mmDelete.mock.inspectFuncDelete != nil {
  156. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Delete")
  157. }
  158. mmDelete.mock.inspectFuncDelete = f
  159. return mmDelete
  160. }
  161. // Return sets up results that will be returned by ThingImageRepository.Delete
  162. func (mmDelete *mThingImageRepositoryMockDelete) Return(err error) *ThingImageRepositoryMock {
  163. if mmDelete.mock.funcDelete != nil {
  164. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  165. }
  166. if mmDelete.defaultExpectation == nil {
  167. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  168. }
  169. mmDelete.defaultExpectation.results = &ThingImageRepositoryMockDeleteResults{err}
  170. return mmDelete.mock
  171. }
  172. // Set uses given function f to mock the ThingImageRepository.Delete method
  173. func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context, imageID int, tx *sql.Tx) (err error)) *ThingImageRepositoryMock {
  174. if mmDelete.defaultExpectation != nil {
  175. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Delete method")
  176. }
  177. if len(mmDelete.expectations) > 0 {
  178. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.Delete method")
  179. }
  180. mmDelete.mock.funcDelete = f
  181. return mmDelete.mock
  182. }
  183. // When sets expectation for the ThingImageRepository.Delete which will trigger the result defined by the following
  184. // Then helper
  185. func (mmDelete *mThingImageRepositoryMockDelete) When(ctx context.Context, imageID int, tx *sql.Tx) *ThingImageRepositoryMockDeleteExpectation {
  186. if mmDelete.mock.funcDelete != nil {
  187. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  188. }
  189. expectation := &ThingImageRepositoryMockDeleteExpectation{
  190. mock: mmDelete.mock,
  191. params: &ThingImageRepositoryMockDeleteParams{ctx, imageID, tx},
  192. }
  193. mmDelete.expectations = append(mmDelete.expectations, expectation)
  194. return expectation
  195. }
  196. // Then sets up ThingImageRepository.Delete return parameters for the expectation previously defined by the When method
  197. func (e *ThingImageRepositoryMockDeleteExpectation) Then(err error) *ThingImageRepositoryMock {
  198. e.results = &ThingImageRepositoryMockDeleteResults{err}
  199. return e.mock
  200. }
  201. // Times sets number of times ThingImageRepository.Delete should be invoked
  202. func (mmDelete *mThingImageRepositoryMockDelete) Times(n uint64) *mThingImageRepositoryMockDelete {
  203. if n == 0 {
  204. mmDelete.mock.t.Fatalf("Times of ThingImageRepositoryMock.Delete mock can not be zero")
  205. }
  206. mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
  207. return mmDelete
  208. }
  209. func (mmDelete *mThingImageRepositoryMockDelete) 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.ThingImageRepository
  218. func (mmDelete *ThingImageRepositoryMock) 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 := ThingImageRepositoryMockDeleteParams{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 := ThingImageRepositoryMockDeleteParams{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("ThingImageRepositoryMock.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("ThingImageRepositoryMock.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("ThingImageRepositoryMock.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("ThingImageRepositoryMock.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 ThingImageRepositoryMock.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 ThingImageRepositoryMock.Delete. %v %v %v", ctx, imageID, tx)
  263. return
  264. }
  265. // DeleteAfterCounter returns a count of finished ThingImageRepositoryMock.Delete invocations
  266. func (mmDelete *ThingImageRepositoryMock) DeleteAfterCounter() uint64 {
  267. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  268. }
  269. // DeleteBeforeCounter returns a count of ThingImageRepositoryMock.Delete invocations
  270. func (mmDelete *ThingImageRepositoryMock) DeleteBeforeCounter() uint64 {
  271. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  272. }
  273. // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.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 *mThingImageRepositoryMockDelete) Calls() []*ThingImageRepositoryMockDeleteParams {
  276. mmDelete.mutex.RLock()
  277. argCopy := make([]*ThingImageRepositoryMockDeleteParams, 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 *ThingImageRepositoryMock) 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 *ThingImageRepositoryMock) MinimockDeleteInspect() {
  298. for _, e := range m.DeleteMock.expectations {
  299. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  300. m.t.Errorf("Expected call to ThingImageRepositoryMock.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 ThingImageRepositoryMock.Delete")
  308. } else {
  309. m.t.Errorf("Expected call to ThingImageRepositoryMock.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 ThingImageRepositoryMock.Delete")
  315. }
  316. if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
  317. m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.Delete but found %d calls",
  318. mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
  319. }
  320. }
  321. type mThingImageRepositoryMockGetByThingID struct {
  322. optional bool
  323. mock *ThingImageRepositoryMock
  324. defaultExpectation *ThingImageRepositoryMockGetByThingIDExpectation
  325. expectations []*ThingImageRepositoryMockGetByThingIDExpectation
  326. callArgs []*ThingImageRepositoryMockGetByThingIDParams
  327. mutex sync.RWMutex
  328. expectedInvocations uint64
  329. }
  330. // ThingImageRepositoryMockGetByThingIDExpectation specifies expectation struct of the ThingImageRepository.GetByThingID
  331. type ThingImageRepositoryMockGetByThingIDExpectation struct {
  332. mock *ThingImageRepositoryMock
  333. params *ThingImageRepositoryMockGetByThingIDParams
  334. paramPtrs *ThingImageRepositoryMockGetByThingIDParamPtrs
  335. results *ThingImageRepositoryMockGetByThingIDResults
  336. Counter uint64
  337. }
  338. // ThingImageRepositoryMockGetByThingIDParams contains parameters of the ThingImageRepository.GetByThingID
  339. type ThingImageRepositoryMockGetByThingIDParams struct {
  340. ctx context.Context
  341. thingID int
  342. }
  343. // ThingImageRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the ThingImageRepository.GetByThingID
  344. type ThingImageRepositoryMockGetByThingIDParamPtrs struct {
  345. ctx *context.Context
  346. thingID *int
  347. }
  348. // ThingImageRepositoryMockGetByThingIDResults contains results of the ThingImageRepository.GetByThingID
  349. type ThingImageRepositoryMockGetByThingIDResults 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 (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Optional() *mThingImageRepositoryMockGetByThingID {
  359. mmGetByThingID.optional = true
  360. return mmGetByThingID
  361. }
  362. // Expect sets up expected params for ThingImageRepository.GetByThingID
  363. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.Context, thingID int) *mThingImageRepositoryMockGetByThingID {
  364. if mmGetByThingID.mock.funcGetByThingID != nil {
  365. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  366. }
  367. if mmGetByThingID.defaultExpectation == nil {
  368. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
  369. }
  370. if mmGetByThingID.defaultExpectation.paramPtrs != nil {
  371. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
  372. }
  373. mmGetByThingID.defaultExpectation.params = &ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
  374. for _, e := range mmGetByThingID.expectations {
  375. if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
  376. mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
  377. }
  378. }
  379. return mmGetByThingID
  380. }
  381. // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.GetByThingID
  382. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockGetByThingID {
  383. if mmGetByThingID.mock.funcGetByThingID != nil {
  384. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  385. }
  386. if mmGetByThingID.defaultExpectation == nil {
  387. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
  388. }
  389. if mmGetByThingID.defaultExpectation.params != nil {
  390. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Expect")
  391. }
  392. if mmGetByThingID.defaultExpectation.paramPtrs == nil {
  393. mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
  394. }
  395. mmGetByThingID.defaultExpectation.paramPtrs.ctx = &ctx
  396. return mmGetByThingID
  397. }
  398. // ExpectThingIDParam2 sets up expected param thingID for ThingImageRepository.GetByThingID
  399. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectThingIDParam2(thingID int) *mThingImageRepositoryMockGetByThingID {
  400. if mmGetByThingID.mock.funcGetByThingID != nil {
  401. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  402. }
  403. if mmGetByThingID.defaultExpectation == nil {
  404. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
  405. }
  406. if mmGetByThingID.defaultExpectation.params != nil {
  407. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Expect")
  408. }
  409. if mmGetByThingID.defaultExpectation.paramPtrs == nil {
  410. mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
  411. }
  412. mmGetByThingID.defaultExpectation.paramPtrs.thingID = &thingID
  413. return mmGetByThingID
  414. }
  415. // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.GetByThingID
  416. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, thingID int)) *mThingImageRepositoryMockGetByThingID {
  417. if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
  418. mmGetByThingID.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.GetByThingID")
  419. }
  420. mmGetByThingID.mock.inspectFuncGetByThingID = f
  421. return mmGetByThingID
  422. }
  423. // Return sets up results that will be returned by ThingImageRepository.GetByThingID
  424. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Return(ia1 []models.Image, err error) *ThingImageRepositoryMock {
  425. if mmGetByThingID.mock.funcGetByThingID != nil {
  426. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  427. }
  428. if mmGetByThingID.defaultExpectation == nil {
  429. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{mock: mmGetByThingID.mock}
  430. }
  431. mmGetByThingID.defaultExpectation.results = &ThingImageRepositoryMockGetByThingIDResults{ia1, err}
  432. return mmGetByThingID.mock
  433. }
  434. // Set uses given function f to mock the ThingImageRepository.GetByThingID method
  435. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx context.Context, thingID int) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
  436. if mmGetByThingID.defaultExpectation != nil {
  437. mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.GetByThingID method")
  438. }
  439. if len(mmGetByThingID.expectations) > 0 {
  440. mmGetByThingID.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.GetByThingID method")
  441. }
  442. mmGetByThingID.mock.funcGetByThingID = f
  443. return mmGetByThingID.mock
  444. }
  445. // When sets expectation for the ThingImageRepository.GetByThingID which will trigger the result defined by the following
  446. // Then helper
  447. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) When(ctx context.Context, thingID int) *ThingImageRepositoryMockGetByThingIDExpectation {
  448. if mmGetByThingID.mock.funcGetByThingID != nil {
  449. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  450. }
  451. expectation := &ThingImageRepositoryMockGetByThingIDExpectation{
  452. mock: mmGetByThingID.mock,
  453. params: &ThingImageRepositoryMockGetByThingIDParams{ctx, thingID},
  454. }
  455. mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
  456. return expectation
  457. }
  458. // Then sets up ThingImageRepository.GetByThingID return parameters for the expectation previously defined by the When method
  459. func (e *ThingImageRepositoryMockGetByThingIDExpectation) Then(ia1 []models.Image, err error) *ThingImageRepositoryMock {
  460. e.results = &ThingImageRepositoryMockGetByThingIDResults{ia1, err}
  461. return e.mock
  462. }
  463. // Times sets number of times ThingImageRepository.GetByThingID should be invoked
  464. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Times(n uint64) *mThingImageRepositoryMockGetByThingID {
  465. if n == 0 {
  466. mmGetByThingID.mock.t.Fatalf("Times of ThingImageRepositoryMock.GetByThingID mock can not be zero")
  467. }
  468. mm_atomic.StoreUint64(&mmGetByThingID.expectedInvocations, n)
  469. return mmGetByThingID
  470. }
  471. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) invocationsDone() bool {
  472. if len(mmGetByThingID.expectations) == 0 && mmGetByThingID.defaultExpectation == nil && mmGetByThingID.mock.funcGetByThingID == nil {
  473. return true
  474. }
  475. totalInvocations := mm_atomic.LoadUint64(&mmGetByThingID.mock.afterGetByThingIDCounter)
  476. expectedInvocations := mm_atomic.LoadUint64(&mmGetByThingID.expectedInvocations)
  477. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  478. }
  479. // GetByThingID implements place.ThingImageRepository
  480. func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context, thingID int) (ia1 []models.Image, err error) {
  481. mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
  482. defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)
  483. if mmGetByThingID.inspectFuncGetByThingID != nil {
  484. mmGetByThingID.inspectFuncGetByThingID(ctx, thingID)
  485. }
  486. mm_params := ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
  487. // Record call args
  488. mmGetByThingID.GetByThingIDMock.mutex.Lock()
  489. mmGetByThingID.GetByThingIDMock.callArgs = append(mmGetByThingID.GetByThingIDMock.callArgs, &mm_params)
  490. mmGetByThingID.GetByThingIDMock.mutex.Unlock()
  491. for _, e := range mmGetByThingID.GetByThingIDMock.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 mmGetByThingID.GetByThingIDMock.defaultExpectation != nil {
  498. mm_atomic.AddUint64(&mmGetByThingID.GetByThingIDMock.defaultExpectation.Counter, 1)
  499. mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
  500. mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs
  501. mm_got := ThingImageRepositoryMockGetByThingIDParams{ctx, thingID}
  502. if mm_want_ptrs != nil {
  503. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  504. mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID 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.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
  507. mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
  508. }
  509. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  510. mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  511. }
  512. mm_results := mmGetByThingID.GetByThingIDMock.defaultExpectation.results
  513. if mm_results == nil {
  514. mmGetByThingID.t.Fatal("No results are set for the ThingImageRepositoryMock.GetByThingID")
  515. }
  516. return (*mm_results).ia1, (*mm_results).err
  517. }
  518. if mmGetByThingID.funcGetByThingID != nil {
  519. return mmGetByThingID.funcGetByThingID(ctx, thingID)
  520. }
  521. mmGetByThingID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByThingID. %v %v", ctx, thingID)
  522. return
  523. }
  524. // GetByThingIDAfterCounter returns a count of finished ThingImageRepositoryMock.GetByThingID invocations
  525. func (mmGetByThingID *ThingImageRepositoryMock) GetByThingIDAfterCounter() uint64 {
  526. return mm_atomic.LoadUint64(&mmGetByThingID.afterGetByThingIDCounter)
  527. }
  528. // GetByThingIDBeforeCounter returns a count of ThingImageRepositoryMock.GetByThingID invocations
  529. func (mmGetByThingID *ThingImageRepositoryMock) GetByThingIDBeforeCounter() uint64 {
  530. return mm_atomic.LoadUint64(&mmGetByThingID.beforeGetByThingIDCounter)
  531. }
  532. // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.GetByThingID.
  533. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  534. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Calls() []*ThingImageRepositoryMockGetByThingIDParams {
  535. mmGetByThingID.mutex.RLock()
  536. argCopy := make([]*ThingImageRepositoryMockGetByThingIDParams, len(mmGetByThingID.callArgs))
  537. copy(argCopy, mmGetByThingID.callArgs)
  538. mmGetByThingID.mutex.RUnlock()
  539. return argCopy
  540. }
  541. // MinimockGetByThingIDDone returns true if the count of the GetByThingID invocations corresponds
  542. // the number of defined expectations
  543. func (m *ThingImageRepositoryMock) MinimockGetByThingIDDone() bool {
  544. if m.GetByThingIDMock.optional {
  545. // Optional methods provide '0 or more' call count restriction.
  546. return true
  547. }
  548. for _, e := range m.GetByThingIDMock.expectations {
  549. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  550. return false
  551. }
  552. }
  553. return m.GetByThingIDMock.invocationsDone()
  554. }
  555. // MinimockGetByThingIDInspect logs each unmet expectation
  556. func (m *ThingImageRepositoryMock) MinimockGetByThingIDInspect() {
  557. for _, e := range m.GetByThingIDMock.expectations {
  558. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  559. m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByThingID with params: %#v", *e.params)
  560. }
  561. }
  562. afterGetByThingIDCounter := mm_atomic.LoadUint64(&m.afterGetByThingIDCounter)
  563. // if default expectation was set then invocations count should be greater than zero
  564. if m.GetByThingIDMock.defaultExpectation != nil && afterGetByThingIDCounter < 1 {
  565. if m.GetByThingIDMock.defaultExpectation.params == nil {
  566. m.t.Error("Expected call to ThingImageRepositoryMock.GetByThingID")
  567. } else {
  568. m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByThingID with params: %#v", *m.GetByThingIDMock.defaultExpectation.params)
  569. }
  570. }
  571. // if func was set then invocations count should be greater than zero
  572. if m.funcGetByThingID != nil && afterGetByThingIDCounter < 1 {
  573. m.t.Error("Expected call to ThingImageRepositoryMock.GetByThingID")
  574. }
  575. if !m.GetByThingIDMock.invocationsDone() && afterGetByThingIDCounter > 0 {
  576. m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.GetByThingID but found %d calls",
  577. mm_atomic.LoadUint64(&m.GetByThingIDMock.expectedInvocations), afterGetByThingIDCounter)
  578. }
  579. }
  580. // MinimockFinish checks that all mocked methods have been called the expected number of times
  581. func (m *ThingImageRepositoryMock) MinimockFinish() {
  582. m.finishOnce.Do(func() {
  583. if !m.minimockDone() {
  584. m.MinimockDeleteInspect()
  585. m.MinimockGetByThingIDInspect()
  586. }
  587. })
  588. }
  589. // MinimockWait waits for all mocked methods to be called the expected number of times
  590. func (m *ThingImageRepositoryMock) 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 *ThingImageRepositoryMock) minimockDone() bool {
  605. done := true
  606. return done &&
  607. m.MinimockDeleteDone() &&
  608. m.MinimockGetByThingIDDone()
  609. }