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