thing_image_repository_minimock.go 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725
  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/image.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 image.ThingImageRepository
  13. type ThingImageRepositoryMock struct {
  14. t minimock.Tester
  15. finishOnce sync.Once
  16. funcAdd func(ctx context.Context, req models.AddThingImageRequest) (err error)
  17. inspectFuncAdd func(ctx context.Context, req models.AddThingImageRequest)
  18. afterAddCounter uint64
  19. beforeAddCounter uint64
  20. AddMock mThingImageRepositoryMockAdd
  21. funcDelete func(ctx context.Context, id uint64) (err error)
  22. inspectFuncDelete func(ctx context.Context, id uint64)
  23. afterDeleteCounter uint64
  24. beforeDeleteCounter uint64
  25. DeleteMock mThingImageRepositoryMockDelete
  26. funcGet func(ctx context.Context, id uint64) (ip1 *models.Image, err error)
  27. inspectFuncGet func(ctx context.Context, id uint64)
  28. afterGetCounter uint64
  29. beforeGetCounter uint64
  30. GetMock mThingImageRepositoryMockGet
  31. funcGetByPlaceID func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
  32. inspectFuncGetByPlaceID func(ctx context.Context, id uint64)
  33. afterGetByPlaceIDCounter uint64
  34. beforeGetByPlaceIDCounter uint64
  35. GetByPlaceIDMock mThingImageRepositoryMockGetByPlaceID
  36. funcGetByThingID func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
  37. inspectFuncGetByThingID func(ctx context.Context, id uint64)
  38. afterGetByThingIDCounter uint64
  39. beforeGetByThingIDCounter uint64
  40. GetByThingIDMock mThingImageRepositoryMockGetByThingID
  41. }
  42. // NewThingImageRepositoryMock returns a mock for image.ThingImageRepository
  43. func NewThingImageRepositoryMock(t minimock.Tester) *ThingImageRepositoryMock {
  44. m := &ThingImageRepositoryMock{t: t}
  45. if controller, ok := t.(minimock.MockController); ok {
  46. controller.RegisterMocker(m)
  47. }
  48. m.AddMock = mThingImageRepositoryMockAdd{mock: m}
  49. m.AddMock.callArgs = []*ThingImageRepositoryMockAddParams{}
  50. m.DeleteMock = mThingImageRepositoryMockDelete{mock: m}
  51. m.DeleteMock.callArgs = []*ThingImageRepositoryMockDeleteParams{}
  52. m.GetMock = mThingImageRepositoryMockGet{mock: m}
  53. m.GetMock.callArgs = []*ThingImageRepositoryMockGetParams{}
  54. m.GetByPlaceIDMock = mThingImageRepositoryMockGetByPlaceID{mock: m}
  55. m.GetByPlaceIDMock.callArgs = []*ThingImageRepositoryMockGetByPlaceIDParams{}
  56. m.GetByThingIDMock = mThingImageRepositoryMockGetByThingID{mock: m}
  57. m.GetByThingIDMock.callArgs = []*ThingImageRepositoryMockGetByThingIDParams{}
  58. t.Cleanup(m.MinimockFinish)
  59. return m
  60. }
  61. type mThingImageRepositoryMockAdd struct {
  62. optional bool
  63. mock *ThingImageRepositoryMock
  64. defaultExpectation *ThingImageRepositoryMockAddExpectation
  65. expectations []*ThingImageRepositoryMockAddExpectation
  66. callArgs []*ThingImageRepositoryMockAddParams
  67. mutex sync.RWMutex
  68. expectedInvocations uint64
  69. }
  70. // ThingImageRepositoryMockAddExpectation specifies expectation struct of the ThingImageRepository.Add
  71. type ThingImageRepositoryMockAddExpectation struct {
  72. mock *ThingImageRepositoryMock
  73. params *ThingImageRepositoryMockAddParams
  74. paramPtrs *ThingImageRepositoryMockAddParamPtrs
  75. results *ThingImageRepositoryMockAddResults
  76. Counter uint64
  77. }
  78. // ThingImageRepositoryMockAddParams contains parameters of the ThingImageRepository.Add
  79. type ThingImageRepositoryMockAddParams struct {
  80. ctx context.Context
  81. req models.AddThingImageRequest
  82. }
  83. // ThingImageRepositoryMockAddParamPtrs contains pointers to parameters of the ThingImageRepository.Add
  84. type ThingImageRepositoryMockAddParamPtrs struct {
  85. ctx *context.Context
  86. req *models.AddThingImageRequest
  87. }
  88. // ThingImageRepositoryMockAddResults contains results of the ThingImageRepository.Add
  89. type ThingImageRepositoryMockAddResults struct {
  90. err error
  91. }
  92. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  93. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  94. // Optional() makes method check to work in '0 or more' mode.
  95. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  96. // catch the problems when the expected method call is totally skipped during test run.
  97. func (mmAdd *mThingImageRepositoryMockAdd) Optional() *mThingImageRepositoryMockAdd {
  98. mmAdd.optional = true
  99. return mmAdd
  100. }
  101. // Expect sets up expected params for ThingImageRepository.Add
  102. func (mmAdd *mThingImageRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingImageRequest) *mThingImageRepositoryMockAdd {
  103. if mmAdd.mock.funcAdd != nil {
  104. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
  105. }
  106. if mmAdd.defaultExpectation == nil {
  107. mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{}
  108. }
  109. if mmAdd.defaultExpectation.paramPtrs != nil {
  110. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by ExpectParams functions")
  111. }
  112. mmAdd.defaultExpectation.params = &ThingImageRepositoryMockAddParams{ctx, req}
  113. for _, e := range mmAdd.expectations {
  114. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  115. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  116. }
  117. }
  118. return mmAdd
  119. }
  120. // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.Add
  121. func (mmAdd *mThingImageRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockAdd {
  122. if mmAdd.mock.funcAdd != nil {
  123. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
  124. }
  125. if mmAdd.defaultExpectation == nil {
  126. mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{}
  127. }
  128. if mmAdd.defaultExpectation.params != nil {
  129. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Expect")
  130. }
  131. if mmAdd.defaultExpectation.paramPtrs == nil {
  132. mmAdd.defaultExpectation.paramPtrs = &ThingImageRepositoryMockAddParamPtrs{}
  133. }
  134. mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
  135. return mmAdd
  136. }
  137. // ExpectReqParam2 sets up expected param req for ThingImageRepository.Add
  138. func (mmAdd *mThingImageRepositoryMockAdd) ExpectReqParam2(req models.AddThingImageRequest) *mThingImageRepositoryMockAdd {
  139. if mmAdd.mock.funcAdd != nil {
  140. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
  141. }
  142. if mmAdd.defaultExpectation == nil {
  143. mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{}
  144. }
  145. if mmAdd.defaultExpectation.params != nil {
  146. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Expect")
  147. }
  148. if mmAdd.defaultExpectation.paramPtrs == nil {
  149. mmAdd.defaultExpectation.paramPtrs = &ThingImageRepositoryMockAddParamPtrs{}
  150. }
  151. mmAdd.defaultExpectation.paramPtrs.req = &req
  152. return mmAdd
  153. }
  154. // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Add
  155. func (mmAdd *mThingImageRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingImageRequest)) *mThingImageRepositoryMockAdd {
  156. if mmAdd.mock.inspectFuncAdd != nil {
  157. mmAdd.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Add")
  158. }
  159. mmAdd.mock.inspectFuncAdd = f
  160. return mmAdd
  161. }
  162. // Return sets up results that will be returned by ThingImageRepository.Add
  163. func (mmAdd *mThingImageRepositoryMockAdd) Return(err error) *ThingImageRepositoryMock {
  164. if mmAdd.mock.funcAdd != nil {
  165. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
  166. }
  167. if mmAdd.defaultExpectation == nil {
  168. mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{mock: mmAdd.mock}
  169. }
  170. mmAdd.defaultExpectation.results = &ThingImageRepositoryMockAddResults{err}
  171. return mmAdd.mock
  172. }
  173. // Set uses given function f to mock the ThingImageRepository.Add method
  174. func (mmAdd *mThingImageRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingImageRequest) (err error)) *ThingImageRepositoryMock {
  175. if mmAdd.defaultExpectation != nil {
  176. mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Add method")
  177. }
  178. if len(mmAdd.expectations) > 0 {
  179. mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.Add method")
  180. }
  181. mmAdd.mock.funcAdd = f
  182. return mmAdd.mock
  183. }
  184. // When sets expectation for the ThingImageRepository.Add which will trigger the result defined by the following
  185. // Then helper
  186. func (mmAdd *mThingImageRepositoryMockAdd) When(ctx context.Context, req models.AddThingImageRequest) *ThingImageRepositoryMockAddExpectation {
  187. if mmAdd.mock.funcAdd != nil {
  188. mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
  189. }
  190. expectation := &ThingImageRepositoryMockAddExpectation{
  191. mock: mmAdd.mock,
  192. params: &ThingImageRepositoryMockAddParams{ctx, req},
  193. }
  194. mmAdd.expectations = append(mmAdd.expectations, expectation)
  195. return expectation
  196. }
  197. // Then sets up ThingImageRepository.Add return parameters for the expectation previously defined by the When method
  198. func (e *ThingImageRepositoryMockAddExpectation) Then(err error) *ThingImageRepositoryMock {
  199. e.results = &ThingImageRepositoryMockAddResults{err}
  200. return e.mock
  201. }
  202. // Times sets number of times ThingImageRepository.Add should be invoked
  203. func (mmAdd *mThingImageRepositoryMockAdd) Times(n uint64) *mThingImageRepositoryMockAdd {
  204. if n == 0 {
  205. mmAdd.mock.t.Fatalf("Times of ThingImageRepositoryMock.Add mock can not be zero")
  206. }
  207. mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
  208. return mmAdd
  209. }
  210. func (mmAdd *mThingImageRepositoryMockAdd) invocationsDone() bool {
  211. if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
  212. return true
  213. }
  214. totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
  215. expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
  216. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  217. }
  218. // Add implements image.ThingImageRepository
  219. func (mmAdd *ThingImageRepositoryMock) Add(ctx context.Context, req models.AddThingImageRequest) (err error) {
  220. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  221. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  222. if mmAdd.inspectFuncAdd != nil {
  223. mmAdd.inspectFuncAdd(ctx, req)
  224. }
  225. mm_params := ThingImageRepositoryMockAddParams{ctx, req}
  226. // Record call args
  227. mmAdd.AddMock.mutex.Lock()
  228. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
  229. mmAdd.AddMock.mutex.Unlock()
  230. for _, e := range mmAdd.AddMock.expectations {
  231. if minimock.Equal(*e.params, mm_params) {
  232. mm_atomic.AddUint64(&e.Counter, 1)
  233. return e.results.err
  234. }
  235. }
  236. if mmAdd.AddMock.defaultExpectation != nil {
  237. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  238. mm_want := mmAdd.AddMock.defaultExpectation.params
  239. mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
  240. mm_got := ThingImageRepositoryMockAddParams{ctx, req}
  241. if mm_want_ptrs != nil {
  242. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  243. mmAdd.t.Errorf("ThingImageRepositoryMock.Add got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  244. }
  245. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  246. mmAdd.t.Errorf("ThingImageRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
  247. }
  248. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  249. mmAdd.t.Errorf("ThingImageRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  250. }
  251. mm_results := mmAdd.AddMock.defaultExpectation.results
  252. if mm_results == nil {
  253. mmAdd.t.Fatal("No results are set for the ThingImageRepositoryMock.Add")
  254. }
  255. return (*mm_results).err
  256. }
  257. if mmAdd.funcAdd != nil {
  258. return mmAdd.funcAdd(ctx, req)
  259. }
  260. mmAdd.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Add. %v %v", ctx, req)
  261. return
  262. }
  263. // AddAfterCounter returns a count of finished ThingImageRepositoryMock.Add invocations
  264. func (mmAdd *ThingImageRepositoryMock) AddAfterCounter() uint64 {
  265. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  266. }
  267. // AddBeforeCounter returns a count of ThingImageRepositoryMock.Add invocations
  268. func (mmAdd *ThingImageRepositoryMock) AddBeforeCounter() uint64 {
  269. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  270. }
  271. // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.Add.
  272. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  273. func (mmAdd *mThingImageRepositoryMockAdd) Calls() []*ThingImageRepositoryMockAddParams {
  274. mmAdd.mutex.RLock()
  275. argCopy := make([]*ThingImageRepositoryMockAddParams, len(mmAdd.callArgs))
  276. copy(argCopy, mmAdd.callArgs)
  277. mmAdd.mutex.RUnlock()
  278. return argCopy
  279. }
  280. // MinimockAddDone returns true if the count of the Add invocations corresponds
  281. // the number of defined expectations
  282. func (m *ThingImageRepositoryMock) MinimockAddDone() bool {
  283. if m.AddMock.optional {
  284. // Optional methods provide '0 or more' call count restriction.
  285. return true
  286. }
  287. for _, e := range m.AddMock.expectations {
  288. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  289. return false
  290. }
  291. }
  292. return m.AddMock.invocationsDone()
  293. }
  294. // MinimockAddInspect logs each unmet expectation
  295. func (m *ThingImageRepositoryMock) MinimockAddInspect() {
  296. for _, e := range m.AddMock.expectations {
  297. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  298. m.t.Errorf("Expected call to ThingImageRepositoryMock.Add with params: %#v", *e.params)
  299. }
  300. }
  301. afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
  302. // if default expectation was set then invocations count should be greater than zero
  303. if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
  304. if m.AddMock.defaultExpectation.params == nil {
  305. m.t.Error("Expected call to ThingImageRepositoryMock.Add")
  306. } else {
  307. m.t.Errorf("Expected call to ThingImageRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  308. }
  309. }
  310. // if func was set then invocations count should be greater than zero
  311. if m.funcAdd != nil && afterAddCounter < 1 {
  312. m.t.Error("Expected call to ThingImageRepositoryMock.Add")
  313. }
  314. if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
  315. m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.Add but found %d calls",
  316. mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
  317. }
  318. }
  319. type mThingImageRepositoryMockDelete struct {
  320. optional bool
  321. mock *ThingImageRepositoryMock
  322. defaultExpectation *ThingImageRepositoryMockDeleteExpectation
  323. expectations []*ThingImageRepositoryMockDeleteExpectation
  324. callArgs []*ThingImageRepositoryMockDeleteParams
  325. mutex sync.RWMutex
  326. expectedInvocations uint64
  327. }
  328. // ThingImageRepositoryMockDeleteExpectation specifies expectation struct of the ThingImageRepository.Delete
  329. type ThingImageRepositoryMockDeleteExpectation struct {
  330. mock *ThingImageRepositoryMock
  331. params *ThingImageRepositoryMockDeleteParams
  332. paramPtrs *ThingImageRepositoryMockDeleteParamPtrs
  333. results *ThingImageRepositoryMockDeleteResults
  334. Counter uint64
  335. }
  336. // ThingImageRepositoryMockDeleteParams contains parameters of the ThingImageRepository.Delete
  337. type ThingImageRepositoryMockDeleteParams struct {
  338. ctx context.Context
  339. id uint64
  340. }
  341. // ThingImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingImageRepository.Delete
  342. type ThingImageRepositoryMockDeleteParamPtrs struct {
  343. ctx *context.Context
  344. id *uint64
  345. }
  346. // ThingImageRepositoryMockDeleteResults contains results of the ThingImageRepository.Delete
  347. type ThingImageRepositoryMockDeleteResults struct {
  348. err error
  349. }
  350. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  351. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  352. // Optional() makes method check to work in '0 or more' mode.
  353. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  354. // catch the problems when the expected method call is totally skipped during test run.
  355. func (mmDelete *mThingImageRepositoryMockDelete) Optional() *mThingImageRepositoryMockDelete {
  356. mmDelete.optional = true
  357. return mmDelete
  358. }
  359. // Expect sets up expected params for ThingImageRepository.Delete
  360. func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockDelete {
  361. if mmDelete.mock.funcDelete != nil {
  362. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  363. }
  364. if mmDelete.defaultExpectation == nil {
  365. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
  366. }
  367. if mmDelete.defaultExpectation.paramPtrs != nil {
  368. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by ExpectParams functions")
  369. }
  370. mmDelete.defaultExpectation.params = &ThingImageRepositoryMockDeleteParams{ctx, id}
  371. for _, e := range mmDelete.expectations {
  372. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  373. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  374. }
  375. }
  376. return mmDelete
  377. }
  378. // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.Delete
  379. func (mmDelete *mThingImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockDelete {
  380. if mmDelete.mock.funcDelete != nil {
  381. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  382. }
  383. if mmDelete.defaultExpectation == nil {
  384. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
  385. }
  386. if mmDelete.defaultExpectation.params != nil {
  387. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
  388. }
  389. if mmDelete.defaultExpectation.paramPtrs == nil {
  390. mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
  391. }
  392. mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
  393. return mmDelete
  394. }
  395. // ExpectIdParam2 sets up expected param id for ThingImageRepository.Delete
  396. func (mmDelete *mThingImageRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingImageRepositoryMockDelete {
  397. if mmDelete.mock.funcDelete != nil {
  398. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  399. }
  400. if mmDelete.defaultExpectation == nil {
  401. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
  402. }
  403. if mmDelete.defaultExpectation.params != nil {
  404. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
  405. }
  406. if mmDelete.defaultExpectation.paramPtrs == nil {
  407. mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
  408. }
  409. mmDelete.defaultExpectation.paramPtrs.id = &id
  410. return mmDelete
  411. }
  412. // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Delete
  413. func (mmDelete *mThingImageRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockDelete {
  414. if mmDelete.mock.inspectFuncDelete != nil {
  415. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Delete")
  416. }
  417. mmDelete.mock.inspectFuncDelete = f
  418. return mmDelete
  419. }
  420. // Return sets up results that will be returned by ThingImageRepository.Delete
  421. func (mmDelete *mThingImageRepositoryMockDelete) Return(err error) *ThingImageRepositoryMock {
  422. if mmDelete.mock.funcDelete != nil {
  423. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  424. }
  425. if mmDelete.defaultExpectation == nil {
  426. mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  427. }
  428. mmDelete.defaultExpectation.results = &ThingImageRepositoryMockDeleteResults{err}
  429. return mmDelete.mock
  430. }
  431. // Set uses given function f to mock the ThingImageRepository.Delete method
  432. func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingImageRepositoryMock {
  433. if mmDelete.defaultExpectation != nil {
  434. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Delete method")
  435. }
  436. if len(mmDelete.expectations) > 0 {
  437. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.Delete method")
  438. }
  439. mmDelete.mock.funcDelete = f
  440. return mmDelete.mock
  441. }
  442. // When sets expectation for the ThingImageRepository.Delete which will trigger the result defined by the following
  443. // Then helper
  444. func (mmDelete *mThingImageRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingImageRepositoryMockDeleteExpectation {
  445. if mmDelete.mock.funcDelete != nil {
  446. mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
  447. }
  448. expectation := &ThingImageRepositoryMockDeleteExpectation{
  449. mock: mmDelete.mock,
  450. params: &ThingImageRepositoryMockDeleteParams{ctx, id},
  451. }
  452. mmDelete.expectations = append(mmDelete.expectations, expectation)
  453. return expectation
  454. }
  455. // Then sets up ThingImageRepository.Delete return parameters for the expectation previously defined by the When method
  456. func (e *ThingImageRepositoryMockDeleteExpectation) Then(err error) *ThingImageRepositoryMock {
  457. e.results = &ThingImageRepositoryMockDeleteResults{err}
  458. return e.mock
  459. }
  460. // Times sets number of times ThingImageRepository.Delete should be invoked
  461. func (mmDelete *mThingImageRepositoryMockDelete) Times(n uint64) *mThingImageRepositoryMockDelete {
  462. if n == 0 {
  463. mmDelete.mock.t.Fatalf("Times of ThingImageRepositoryMock.Delete mock can not be zero")
  464. }
  465. mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
  466. return mmDelete
  467. }
  468. func (mmDelete *mThingImageRepositoryMockDelete) invocationsDone() bool {
  469. if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
  470. return true
  471. }
  472. totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
  473. expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
  474. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  475. }
  476. // Delete implements image.ThingImageRepository
  477. func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
  478. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  479. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  480. if mmDelete.inspectFuncDelete != nil {
  481. mmDelete.inspectFuncDelete(ctx, id)
  482. }
  483. mm_params := ThingImageRepositoryMockDeleteParams{ctx, id}
  484. // Record call args
  485. mmDelete.DeleteMock.mutex.Lock()
  486. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
  487. mmDelete.DeleteMock.mutex.Unlock()
  488. for _, e := range mmDelete.DeleteMock.expectations {
  489. if minimock.Equal(*e.params, mm_params) {
  490. mm_atomic.AddUint64(&e.Counter, 1)
  491. return e.results.err
  492. }
  493. }
  494. if mmDelete.DeleteMock.defaultExpectation != nil {
  495. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  496. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  497. mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
  498. mm_got := ThingImageRepositoryMockDeleteParams{ctx, id}
  499. if mm_want_ptrs != nil {
  500. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  501. 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))
  502. }
  503. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  504. 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))
  505. }
  506. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  507. mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  508. }
  509. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  510. if mm_results == nil {
  511. mmDelete.t.Fatal("No results are set for the ThingImageRepositoryMock.Delete")
  512. }
  513. return (*mm_results).err
  514. }
  515. if mmDelete.funcDelete != nil {
  516. return mmDelete.funcDelete(ctx, id)
  517. }
  518. mmDelete.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Delete. %v %v", ctx, id)
  519. return
  520. }
  521. // DeleteAfterCounter returns a count of finished ThingImageRepositoryMock.Delete invocations
  522. func (mmDelete *ThingImageRepositoryMock) DeleteAfterCounter() uint64 {
  523. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  524. }
  525. // DeleteBeforeCounter returns a count of ThingImageRepositoryMock.Delete invocations
  526. func (mmDelete *ThingImageRepositoryMock) DeleteBeforeCounter() uint64 {
  527. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  528. }
  529. // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.Delete.
  530. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  531. func (mmDelete *mThingImageRepositoryMockDelete) Calls() []*ThingImageRepositoryMockDeleteParams {
  532. mmDelete.mutex.RLock()
  533. argCopy := make([]*ThingImageRepositoryMockDeleteParams, len(mmDelete.callArgs))
  534. copy(argCopy, mmDelete.callArgs)
  535. mmDelete.mutex.RUnlock()
  536. return argCopy
  537. }
  538. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  539. // the number of defined expectations
  540. func (m *ThingImageRepositoryMock) MinimockDeleteDone() bool {
  541. if m.DeleteMock.optional {
  542. // Optional methods provide '0 or more' call count restriction.
  543. return true
  544. }
  545. for _, e := range m.DeleteMock.expectations {
  546. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  547. return false
  548. }
  549. }
  550. return m.DeleteMock.invocationsDone()
  551. }
  552. // MinimockDeleteInspect logs each unmet expectation
  553. func (m *ThingImageRepositoryMock) MinimockDeleteInspect() {
  554. for _, e := range m.DeleteMock.expectations {
  555. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  556. m.t.Errorf("Expected call to ThingImageRepositoryMock.Delete with params: %#v", *e.params)
  557. }
  558. }
  559. afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
  560. // if default expectation was set then invocations count should be greater than zero
  561. if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
  562. if m.DeleteMock.defaultExpectation.params == nil {
  563. m.t.Error("Expected call to ThingImageRepositoryMock.Delete")
  564. } else {
  565. m.t.Errorf("Expected call to ThingImageRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  566. }
  567. }
  568. // if func was set then invocations count should be greater than zero
  569. if m.funcDelete != nil && afterDeleteCounter < 1 {
  570. m.t.Error("Expected call to ThingImageRepositoryMock.Delete")
  571. }
  572. if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
  573. m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.Delete but found %d calls",
  574. mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
  575. }
  576. }
  577. type mThingImageRepositoryMockGet struct {
  578. optional bool
  579. mock *ThingImageRepositoryMock
  580. defaultExpectation *ThingImageRepositoryMockGetExpectation
  581. expectations []*ThingImageRepositoryMockGetExpectation
  582. callArgs []*ThingImageRepositoryMockGetParams
  583. mutex sync.RWMutex
  584. expectedInvocations uint64
  585. }
  586. // ThingImageRepositoryMockGetExpectation specifies expectation struct of the ThingImageRepository.Get
  587. type ThingImageRepositoryMockGetExpectation struct {
  588. mock *ThingImageRepositoryMock
  589. params *ThingImageRepositoryMockGetParams
  590. paramPtrs *ThingImageRepositoryMockGetParamPtrs
  591. results *ThingImageRepositoryMockGetResults
  592. Counter uint64
  593. }
  594. // ThingImageRepositoryMockGetParams contains parameters of the ThingImageRepository.Get
  595. type ThingImageRepositoryMockGetParams struct {
  596. ctx context.Context
  597. id uint64
  598. }
  599. // ThingImageRepositoryMockGetParamPtrs contains pointers to parameters of the ThingImageRepository.Get
  600. type ThingImageRepositoryMockGetParamPtrs struct {
  601. ctx *context.Context
  602. id *uint64
  603. }
  604. // ThingImageRepositoryMockGetResults contains results of the ThingImageRepository.Get
  605. type ThingImageRepositoryMockGetResults struct {
  606. ip1 *models.Image
  607. err error
  608. }
  609. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  610. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  611. // Optional() makes method check to work in '0 or more' mode.
  612. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  613. // catch the problems when the expected method call is totally skipped during test run.
  614. func (mmGet *mThingImageRepositoryMockGet) Optional() *mThingImageRepositoryMockGet {
  615. mmGet.optional = true
  616. return mmGet
  617. }
  618. // Expect sets up expected params for ThingImageRepository.Get
  619. func (mmGet *mThingImageRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGet {
  620. if mmGet.mock.funcGet != nil {
  621. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
  622. }
  623. if mmGet.defaultExpectation == nil {
  624. mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{}
  625. }
  626. if mmGet.defaultExpectation.paramPtrs != nil {
  627. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by ExpectParams functions")
  628. }
  629. mmGet.defaultExpectation.params = &ThingImageRepositoryMockGetParams{ctx, id}
  630. for _, e := range mmGet.expectations {
  631. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  632. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  633. }
  634. }
  635. return mmGet
  636. }
  637. // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.Get
  638. func (mmGet *mThingImageRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockGet {
  639. if mmGet.mock.funcGet != nil {
  640. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
  641. }
  642. if mmGet.defaultExpectation == nil {
  643. mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{}
  644. }
  645. if mmGet.defaultExpectation.params != nil {
  646. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Expect")
  647. }
  648. if mmGet.defaultExpectation.paramPtrs == nil {
  649. mmGet.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetParamPtrs{}
  650. }
  651. mmGet.defaultExpectation.paramPtrs.ctx = &ctx
  652. return mmGet
  653. }
  654. // ExpectIdParam2 sets up expected param id for ThingImageRepository.Get
  655. func (mmGet *mThingImageRepositoryMockGet) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGet {
  656. if mmGet.mock.funcGet != nil {
  657. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
  658. }
  659. if mmGet.defaultExpectation == nil {
  660. mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{}
  661. }
  662. if mmGet.defaultExpectation.params != nil {
  663. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Expect")
  664. }
  665. if mmGet.defaultExpectation.paramPtrs == nil {
  666. mmGet.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetParamPtrs{}
  667. }
  668. mmGet.defaultExpectation.paramPtrs.id = &id
  669. return mmGet
  670. }
  671. // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Get
  672. func (mmGet *mThingImageRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGet {
  673. if mmGet.mock.inspectFuncGet != nil {
  674. mmGet.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Get")
  675. }
  676. mmGet.mock.inspectFuncGet = f
  677. return mmGet
  678. }
  679. // Return sets up results that will be returned by ThingImageRepository.Get
  680. func (mmGet *mThingImageRepositoryMockGet) Return(ip1 *models.Image, err error) *ThingImageRepositoryMock {
  681. if mmGet.mock.funcGet != nil {
  682. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
  683. }
  684. if mmGet.defaultExpectation == nil {
  685. mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{mock: mmGet.mock}
  686. }
  687. mmGet.defaultExpectation.results = &ThingImageRepositoryMockGetResults{ip1, err}
  688. return mmGet.mock
  689. }
  690. // Set uses given function f to mock the ThingImageRepository.Get method
  691. func (mmGet *mThingImageRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (ip1 *models.Image, err error)) *ThingImageRepositoryMock {
  692. if mmGet.defaultExpectation != nil {
  693. mmGet.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Get method")
  694. }
  695. if len(mmGet.expectations) > 0 {
  696. mmGet.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.Get method")
  697. }
  698. mmGet.mock.funcGet = f
  699. return mmGet.mock
  700. }
  701. // When sets expectation for the ThingImageRepository.Get which will trigger the result defined by the following
  702. // Then helper
  703. func (mmGet *mThingImageRepositoryMockGet) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetExpectation {
  704. if mmGet.mock.funcGet != nil {
  705. mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
  706. }
  707. expectation := &ThingImageRepositoryMockGetExpectation{
  708. mock: mmGet.mock,
  709. params: &ThingImageRepositoryMockGetParams{ctx, id},
  710. }
  711. mmGet.expectations = append(mmGet.expectations, expectation)
  712. return expectation
  713. }
  714. // Then sets up ThingImageRepository.Get return parameters for the expectation previously defined by the When method
  715. func (e *ThingImageRepositoryMockGetExpectation) Then(ip1 *models.Image, err error) *ThingImageRepositoryMock {
  716. e.results = &ThingImageRepositoryMockGetResults{ip1, err}
  717. return e.mock
  718. }
  719. // Times sets number of times ThingImageRepository.Get should be invoked
  720. func (mmGet *mThingImageRepositoryMockGet) Times(n uint64) *mThingImageRepositoryMockGet {
  721. if n == 0 {
  722. mmGet.mock.t.Fatalf("Times of ThingImageRepositoryMock.Get mock can not be zero")
  723. }
  724. mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
  725. return mmGet
  726. }
  727. func (mmGet *mThingImageRepositoryMockGet) invocationsDone() bool {
  728. if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
  729. return true
  730. }
  731. totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
  732. expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
  733. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  734. }
  735. // Get implements image.ThingImageRepository
  736. func (mmGet *ThingImageRepositoryMock) Get(ctx context.Context, id uint64) (ip1 *models.Image, err error) {
  737. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  738. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  739. if mmGet.inspectFuncGet != nil {
  740. mmGet.inspectFuncGet(ctx, id)
  741. }
  742. mm_params := ThingImageRepositoryMockGetParams{ctx, id}
  743. // Record call args
  744. mmGet.GetMock.mutex.Lock()
  745. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
  746. mmGet.GetMock.mutex.Unlock()
  747. for _, e := range mmGet.GetMock.expectations {
  748. if minimock.Equal(*e.params, mm_params) {
  749. mm_atomic.AddUint64(&e.Counter, 1)
  750. return e.results.ip1, e.results.err
  751. }
  752. }
  753. if mmGet.GetMock.defaultExpectation != nil {
  754. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  755. mm_want := mmGet.GetMock.defaultExpectation.params
  756. mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
  757. mm_got := ThingImageRepositoryMockGetParams{ctx, id}
  758. if mm_want_ptrs != nil {
  759. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  760. mmGet.t.Errorf("ThingImageRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  761. }
  762. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  763. mmGet.t.Errorf("ThingImageRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  764. }
  765. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  766. mmGet.t.Errorf("ThingImageRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  767. }
  768. mm_results := mmGet.GetMock.defaultExpectation.results
  769. if mm_results == nil {
  770. mmGet.t.Fatal("No results are set for the ThingImageRepositoryMock.Get")
  771. }
  772. return (*mm_results).ip1, (*mm_results).err
  773. }
  774. if mmGet.funcGet != nil {
  775. return mmGet.funcGet(ctx, id)
  776. }
  777. mmGet.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Get. %v %v", ctx, id)
  778. return
  779. }
  780. // GetAfterCounter returns a count of finished ThingImageRepositoryMock.Get invocations
  781. func (mmGet *ThingImageRepositoryMock) GetAfterCounter() uint64 {
  782. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  783. }
  784. // GetBeforeCounter returns a count of ThingImageRepositoryMock.Get invocations
  785. func (mmGet *ThingImageRepositoryMock) GetBeforeCounter() uint64 {
  786. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  787. }
  788. // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.Get.
  789. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  790. func (mmGet *mThingImageRepositoryMockGet) Calls() []*ThingImageRepositoryMockGetParams {
  791. mmGet.mutex.RLock()
  792. argCopy := make([]*ThingImageRepositoryMockGetParams, len(mmGet.callArgs))
  793. copy(argCopy, mmGet.callArgs)
  794. mmGet.mutex.RUnlock()
  795. return argCopy
  796. }
  797. // MinimockGetDone returns true if the count of the Get invocations corresponds
  798. // the number of defined expectations
  799. func (m *ThingImageRepositoryMock) MinimockGetDone() bool {
  800. if m.GetMock.optional {
  801. // Optional methods provide '0 or more' call count restriction.
  802. return true
  803. }
  804. for _, e := range m.GetMock.expectations {
  805. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  806. return false
  807. }
  808. }
  809. return m.GetMock.invocationsDone()
  810. }
  811. // MinimockGetInspect logs each unmet expectation
  812. func (m *ThingImageRepositoryMock) MinimockGetInspect() {
  813. for _, e := range m.GetMock.expectations {
  814. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  815. m.t.Errorf("Expected call to ThingImageRepositoryMock.Get with params: %#v", *e.params)
  816. }
  817. }
  818. afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
  819. // if default expectation was set then invocations count should be greater than zero
  820. if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
  821. if m.GetMock.defaultExpectation.params == nil {
  822. m.t.Error("Expected call to ThingImageRepositoryMock.Get")
  823. } else {
  824. m.t.Errorf("Expected call to ThingImageRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  825. }
  826. }
  827. // if func was set then invocations count should be greater than zero
  828. if m.funcGet != nil && afterGetCounter < 1 {
  829. m.t.Error("Expected call to ThingImageRepositoryMock.Get")
  830. }
  831. if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
  832. m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.Get but found %d calls",
  833. mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
  834. }
  835. }
  836. type mThingImageRepositoryMockGetByPlaceID struct {
  837. optional bool
  838. mock *ThingImageRepositoryMock
  839. defaultExpectation *ThingImageRepositoryMockGetByPlaceIDExpectation
  840. expectations []*ThingImageRepositoryMockGetByPlaceIDExpectation
  841. callArgs []*ThingImageRepositoryMockGetByPlaceIDParams
  842. mutex sync.RWMutex
  843. expectedInvocations uint64
  844. }
  845. // ThingImageRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingImageRepository.GetByPlaceID
  846. type ThingImageRepositoryMockGetByPlaceIDExpectation struct {
  847. mock *ThingImageRepositoryMock
  848. params *ThingImageRepositoryMockGetByPlaceIDParams
  849. paramPtrs *ThingImageRepositoryMockGetByPlaceIDParamPtrs
  850. results *ThingImageRepositoryMockGetByPlaceIDResults
  851. Counter uint64
  852. }
  853. // ThingImageRepositoryMockGetByPlaceIDParams contains parameters of the ThingImageRepository.GetByPlaceID
  854. type ThingImageRepositoryMockGetByPlaceIDParams struct {
  855. ctx context.Context
  856. id uint64
  857. }
  858. // ThingImageRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingImageRepository.GetByPlaceID
  859. type ThingImageRepositoryMockGetByPlaceIDParamPtrs struct {
  860. ctx *context.Context
  861. id *uint64
  862. }
  863. // ThingImageRepositoryMockGetByPlaceIDResults contains results of the ThingImageRepository.GetByPlaceID
  864. type ThingImageRepositoryMockGetByPlaceIDResults struct {
  865. ia1 []models.Image
  866. err error
  867. }
  868. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  869. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  870. // Optional() makes method check to work in '0 or more' mode.
  871. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  872. // catch the problems when the expected method call is totally skipped during test run.
  873. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Optional() *mThingImageRepositoryMockGetByPlaceID {
  874. mmGetByPlaceID.optional = true
  875. return mmGetByPlaceID
  876. }
  877. // Expect sets up expected params for ThingImageRepository.GetByPlaceID
  878. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGetByPlaceID {
  879. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  880. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
  881. }
  882. if mmGetByPlaceID.defaultExpectation == nil {
  883. mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{}
  884. }
  885. if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
  886. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
  887. }
  888. mmGetByPlaceID.defaultExpectation.params = &ThingImageRepositoryMockGetByPlaceIDParams{ctx, id}
  889. for _, e := range mmGetByPlaceID.expectations {
  890. if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
  891. mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
  892. }
  893. }
  894. return mmGetByPlaceID
  895. }
  896. // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.GetByPlaceID
  897. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockGetByPlaceID {
  898. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  899. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
  900. }
  901. if mmGetByPlaceID.defaultExpectation == nil {
  902. mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{}
  903. }
  904. if mmGetByPlaceID.defaultExpectation.params != nil {
  905. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Expect")
  906. }
  907. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  908. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByPlaceIDParamPtrs{}
  909. }
  910. mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
  911. return mmGetByPlaceID
  912. }
  913. // ExpectIdParam2 sets up expected param id for ThingImageRepository.GetByPlaceID
  914. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGetByPlaceID {
  915. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  916. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
  917. }
  918. if mmGetByPlaceID.defaultExpectation == nil {
  919. mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{}
  920. }
  921. if mmGetByPlaceID.defaultExpectation.params != nil {
  922. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Expect")
  923. }
  924. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  925. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByPlaceIDParamPtrs{}
  926. }
  927. mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
  928. return mmGetByPlaceID
  929. }
  930. // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.GetByPlaceID
  931. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGetByPlaceID {
  932. if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
  933. mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.GetByPlaceID")
  934. }
  935. mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
  936. return mmGetByPlaceID
  937. }
  938. // Return sets up results that will be returned by ThingImageRepository.GetByPlaceID
  939. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Return(ia1 []models.Image, err error) *ThingImageRepositoryMock {
  940. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  941. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
  942. }
  943. if mmGetByPlaceID.defaultExpectation == nil {
  944. mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
  945. }
  946. mmGetByPlaceID.defaultExpectation.results = &ThingImageRepositoryMockGetByPlaceIDResults{ia1, err}
  947. return mmGetByPlaceID.mock
  948. }
  949. // Set uses given function f to mock the ThingImageRepository.GetByPlaceID method
  950. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
  951. if mmGetByPlaceID.defaultExpectation != nil {
  952. mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.GetByPlaceID method")
  953. }
  954. if len(mmGetByPlaceID.expectations) > 0 {
  955. mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.GetByPlaceID method")
  956. }
  957. mmGetByPlaceID.mock.funcGetByPlaceID = f
  958. return mmGetByPlaceID.mock
  959. }
  960. // When sets expectation for the ThingImageRepository.GetByPlaceID which will trigger the result defined by the following
  961. // Then helper
  962. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetByPlaceIDExpectation {
  963. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  964. mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
  965. }
  966. expectation := &ThingImageRepositoryMockGetByPlaceIDExpectation{
  967. mock: mmGetByPlaceID.mock,
  968. params: &ThingImageRepositoryMockGetByPlaceIDParams{ctx, id},
  969. }
  970. mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
  971. return expectation
  972. }
  973. // Then sets up ThingImageRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
  974. func (e *ThingImageRepositoryMockGetByPlaceIDExpectation) Then(ia1 []models.Image, err error) *ThingImageRepositoryMock {
  975. e.results = &ThingImageRepositoryMockGetByPlaceIDResults{ia1, err}
  976. return e.mock
  977. }
  978. // Times sets number of times ThingImageRepository.GetByPlaceID should be invoked
  979. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Times(n uint64) *mThingImageRepositoryMockGetByPlaceID {
  980. if n == 0 {
  981. mmGetByPlaceID.mock.t.Fatalf("Times of ThingImageRepositoryMock.GetByPlaceID mock can not be zero")
  982. }
  983. mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
  984. return mmGetByPlaceID
  985. }
  986. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) invocationsDone() bool {
  987. if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
  988. return true
  989. }
  990. totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
  991. expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)
  992. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  993. }
  994. // GetByPlaceID implements image.ThingImageRepository
  995. func (mmGetByPlaceID *ThingImageRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
  996. mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
  997. defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
  998. if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
  999. mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
  1000. }
  1001. mm_params := ThingImageRepositoryMockGetByPlaceIDParams{ctx, id}
  1002. // Record call args
  1003. mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
  1004. mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
  1005. mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
  1006. for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
  1007. if minimock.Equal(*e.params, mm_params) {
  1008. mm_atomic.AddUint64(&e.Counter, 1)
  1009. return e.results.ia1, e.results.err
  1010. }
  1011. }
  1012. if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
  1013. mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
  1014. mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
  1015. mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
  1016. mm_got := ThingImageRepositoryMockGetByPlaceIDParams{ctx, id}
  1017. if mm_want_ptrs != nil {
  1018. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1019. mmGetByPlaceID.t.Errorf("ThingImageRepositoryMock.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))
  1020. }
  1021. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  1022. mmGetByPlaceID.t.Errorf("ThingImageRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  1023. }
  1024. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1025. mmGetByPlaceID.t.Errorf("ThingImageRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1026. }
  1027. mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
  1028. if mm_results == nil {
  1029. mmGetByPlaceID.t.Fatal("No results are set for the ThingImageRepositoryMock.GetByPlaceID")
  1030. }
  1031. return (*mm_results).ia1, (*mm_results).err
  1032. }
  1033. if mmGetByPlaceID.funcGetByPlaceID != nil {
  1034. return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
  1035. }
  1036. mmGetByPlaceID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByPlaceID. %v %v", ctx, id)
  1037. return
  1038. }
  1039. // GetByPlaceIDAfterCounter returns a count of finished ThingImageRepositoryMock.GetByPlaceID invocations
  1040. func (mmGetByPlaceID *ThingImageRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
  1041. return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
  1042. }
  1043. // GetByPlaceIDBeforeCounter returns a count of ThingImageRepositoryMock.GetByPlaceID invocations
  1044. func (mmGetByPlaceID *ThingImageRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
  1045. return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
  1046. }
  1047. // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.GetByPlaceID.
  1048. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1049. func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Calls() []*ThingImageRepositoryMockGetByPlaceIDParams {
  1050. mmGetByPlaceID.mutex.RLock()
  1051. argCopy := make([]*ThingImageRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
  1052. copy(argCopy, mmGetByPlaceID.callArgs)
  1053. mmGetByPlaceID.mutex.RUnlock()
  1054. return argCopy
  1055. }
  1056. // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
  1057. // the number of defined expectations
  1058. func (m *ThingImageRepositoryMock) MinimockGetByPlaceIDDone() bool {
  1059. if m.GetByPlaceIDMock.optional {
  1060. // Optional methods provide '0 or more' call count restriction.
  1061. return true
  1062. }
  1063. for _, e := range m.GetByPlaceIDMock.expectations {
  1064. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1065. return false
  1066. }
  1067. }
  1068. return m.GetByPlaceIDMock.invocationsDone()
  1069. }
  1070. // MinimockGetByPlaceIDInspect logs each unmet expectation
  1071. func (m *ThingImageRepositoryMock) MinimockGetByPlaceIDInspect() {
  1072. for _, e := range m.GetByPlaceIDMock.expectations {
  1073. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1074. m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByPlaceID with params: %#v", *e.params)
  1075. }
  1076. }
  1077. afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
  1078. // if default expectation was set then invocations count should be greater than zero
  1079. if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
  1080. if m.GetByPlaceIDMock.defaultExpectation.params == nil {
  1081. m.t.Error("Expected call to ThingImageRepositoryMock.GetByPlaceID")
  1082. } else {
  1083. m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
  1084. }
  1085. }
  1086. // if func was set then invocations count should be greater than zero
  1087. if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
  1088. m.t.Error("Expected call to ThingImageRepositoryMock.GetByPlaceID")
  1089. }
  1090. if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
  1091. m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.GetByPlaceID but found %d calls",
  1092. mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
  1093. }
  1094. }
  1095. type mThingImageRepositoryMockGetByThingID struct {
  1096. optional bool
  1097. mock *ThingImageRepositoryMock
  1098. defaultExpectation *ThingImageRepositoryMockGetByThingIDExpectation
  1099. expectations []*ThingImageRepositoryMockGetByThingIDExpectation
  1100. callArgs []*ThingImageRepositoryMockGetByThingIDParams
  1101. mutex sync.RWMutex
  1102. expectedInvocations uint64
  1103. }
  1104. // ThingImageRepositoryMockGetByThingIDExpectation specifies expectation struct of the ThingImageRepository.GetByThingID
  1105. type ThingImageRepositoryMockGetByThingIDExpectation struct {
  1106. mock *ThingImageRepositoryMock
  1107. params *ThingImageRepositoryMockGetByThingIDParams
  1108. paramPtrs *ThingImageRepositoryMockGetByThingIDParamPtrs
  1109. results *ThingImageRepositoryMockGetByThingIDResults
  1110. Counter uint64
  1111. }
  1112. // ThingImageRepositoryMockGetByThingIDParams contains parameters of the ThingImageRepository.GetByThingID
  1113. type ThingImageRepositoryMockGetByThingIDParams struct {
  1114. ctx context.Context
  1115. id uint64
  1116. }
  1117. // ThingImageRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the ThingImageRepository.GetByThingID
  1118. type ThingImageRepositoryMockGetByThingIDParamPtrs struct {
  1119. ctx *context.Context
  1120. id *uint64
  1121. }
  1122. // ThingImageRepositoryMockGetByThingIDResults contains results of the ThingImageRepository.GetByThingID
  1123. type ThingImageRepositoryMockGetByThingIDResults struct {
  1124. ia1 []models.Image
  1125. err error
  1126. }
  1127. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  1128. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  1129. // Optional() makes method check to work in '0 or more' mode.
  1130. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  1131. // catch the problems when the expected method call is totally skipped during test run.
  1132. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Optional() *mThingImageRepositoryMockGetByThingID {
  1133. mmGetByThingID.optional = true
  1134. return mmGetByThingID
  1135. }
  1136. // Expect sets up expected params for ThingImageRepository.GetByThingID
  1137. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGetByThingID {
  1138. if mmGetByThingID.mock.funcGetByThingID != nil {
  1139. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  1140. }
  1141. if mmGetByThingID.defaultExpectation == nil {
  1142. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
  1143. }
  1144. if mmGetByThingID.defaultExpectation.paramPtrs != nil {
  1145. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
  1146. }
  1147. mmGetByThingID.defaultExpectation.params = &ThingImageRepositoryMockGetByThingIDParams{ctx, id}
  1148. for _, e := range mmGetByThingID.expectations {
  1149. if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
  1150. mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
  1151. }
  1152. }
  1153. return mmGetByThingID
  1154. }
  1155. // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.GetByThingID
  1156. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockGetByThingID {
  1157. if mmGetByThingID.mock.funcGetByThingID != nil {
  1158. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  1159. }
  1160. if mmGetByThingID.defaultExpectation == nil {
  1161. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
  1162. }
  1163. if mmGetByThingID.defaultExpectation.params != nil {
  1164. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Expect")
  1165. }
  1166. if mmGetByThingID.defaultExpectation.paramPtrs == nil {
  1167. mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
  1168. }
  1169. mmGetByThingID.defaultExpectation.paramPtrs.ctx = &ctx
  1170. return mmGetByThingID
  1171. }
  1172. // ExpectIdParam2 sets up expected param id for ThingImageRepository.GetByThingID
  1173. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGetByThingID {
  1174. if mmGetByThingID.mock.funcGetByThingID != nil {
  1175. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  1176. }
  1177. if mmGetByThingID.defaultExpectation == nil {
  1178. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
  1179. }
  1180. if mmGetByThingID.defaultExpectation.params != nil {
  1181. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Expect")
  1182. }
  1183. if mmGetByThingID.defaultExpectation.paramPtrs == nil {
  1184. mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
  1185. }
  1186. mmGetByThingID.defaultExpectation.paramPtrs.id = &id
  1187. return mmGetByThingID
  1188. }
  1189. // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.GetByThingID
  1190. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGetByThingID {
  1191. if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
  1192. mmGetByThingID.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.GetByThingID")
  1193. }
  1194. mmGetByThingID.mock.inspectFuncGetByThingID = f
  1195. return mmGetByThingID
  1196. }
  1197. // Return sets up results that will be returned by ThingImageRepository.GetByThingID
  1198. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Return(ia1 []models.Image, err error) *ThingImageRepositoryMock {
  1199. if mmGetByThingID.mock.funcGetByThingID != nil {
  1200. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  1201. }
  1202. if mmGetByThingID.defaultExpectation == nil {
  1203. mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{mock: mmGetByThingID.mock}
  1204. }
  1205. mmGetByThingID.defaultExpectation.results = &ThingImageRepositoryMockGetByThingIDResults{ia1, err}
  1206. return mmGetByThingID.mock
  1207. }
  1208. // Set uses given function f to mock the ThingImageRepository.GetByThingID method
  1209. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
  1210. if mmGetByThingID.defaultExpectation != nil {
  1211. mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.GetByThingID method")
  1212. }
  1213. if len(mmGetByThingID.expectations) > 0 {
  1214. mmGetByThingID.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.GetByThingID method")
  1215. }
  1216. mmGetByThingID.mock.funcGetByThingID = f
  1217. return mmGetByThingID.mock
  1218. }
  1219. // When sets expectation for the ThingImageRepository.GetByThingID which will trigger the result defined by the following
  1220. // Then helper
  1221. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetByThingIDExpectation {
  1222. if mmGetByThingID.mock.funcGetByThingID != nil {
  1223. mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
  1224. }
  1225. expectation := &ThingImageRepositoryMockGetByThingIDExpectation{
  1226. mock: mmGetByThingID.mock,
  1227. params: &ThingImageRepositoryMockGetByThingIDParams{ctx, id},
  1228. }
  1229. mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
  1230. return expectation
  1231. }
  1232. // Then sets up ThingImageRepository.GetByThingID return parameters for the expectation previously defined by the When method
  1233. func (e *ThingImageRepositoryMockGetByThingIDExpectation) Then(ia1 []models.Image, err error) *ThingImageRepositoryMock {
  1234. e.results = &ThingImageRepositoryMockGetByThingIDResults{ia1, err}
  1235. return e.mock
  1236. }
  1237. // Times sets number of times ThingImageRepository.GetByThingID should be invoked
  1238. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Times(n uint64) *mThingImageRepositoryMockGetByThingID {
  1239. if n == 0 {
  1240. mmGetByThingID.mock.t.Fatalf("Times of ThingImageRepositoryMock.GetByThingID mock can not be zero")
  1241. }
  1242. mm_atomic.StoreUint64(&mmGetByThingID.expectedInvocations, n)
  1243. return mmGetByThingID
  1244. }
  1245. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) invocationsDone() bool {
  1246. if len(mmGetByThingID.expectations) == 0 && mmGetByThingID.defaultExpectation == nil && mmGetByThingID.mock.funcGetByThingID == nil {
  1247. return true
  1248. }
  1249. totalInvocations := mm_atomic.LoadUint64(&mmGetByThingID.mock.afterGetByThingIDCounter)
  1250. expectedInvocations := mm_atomic.LoadUint64(&mmGetByThingID.expectedInvocations)
  1251. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1252. }
  1253. // GetByThingID implements image.ThingImageRepository
  1254. func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
  1255. mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
  1256. defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)
  1257. if mmGetByThingID.inspectFuncGetByThingID != nil {
  1258. mmGetByThingID.inspectFuncGetByThingID(ctx, id)
  1259. }
  1260. mm_params := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
  1261. // Record call args
  1262. mmGetByThingID.GetByThingIDMock.mutex.Lock()
  1263. mmGetByThingID.GetByThingIDMock.callArgs = append(mmGetByThingID.GetByThingIDMock.callArgs, &mm_params)
  1264. mmGetByThingID.GetByThingIDMock.mutex.Unlock()
  1265. for _, e := range mmGetByThingID.GetByThingIDMock.expectations {
  1266. if minimock.Equal(*e.params, mm_params) {
  1267. mm_atomic.AddUint64(&e.Counter, 1)
  1268. return e.results.ia1, e.results.err
  1269. }
  1270. }
  1271. if mmGetByThingID.GetByThingIDMock.defaultExpectation != nil {
  1272. mm_atomic.AddUint64(&mmGetByThingID.GetByThingIDMock.defaultExpectation.Counter, 1)
  1273. mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
  1274. mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs
  1275. mm_got := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
  1276. if mm_want_ptrs != nil {
  1277. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1278. 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))
  1279. }
  1280. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  1281. 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))
  1282. }
  1283. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1284. mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1285. }
  1286. mm_results := mmGetByThingID.GetByThingIDMock.defaultExpectation.results
  1287. if mm_results == nil {
  1288. mmGetByThingID.t.Fatal("No results are set for the ThingImageRepositoryMock.GetByThingID")
  1289. }
  1290. return (*mm_results).ia1, (*mm_results).err
  1291. }
  1292. if mmGetByThingID.funcGetByThingID != nil {
  1293. return mmGetByThingID.funcGetByThingID(ctx, id)
  1294. }
  1295. mmGetByThingID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByThingID. %v %v", ctx, id)
  1296. return
  1297. }
  1298. // GetByThingIDAfterCounter returns a count of finished ThingImageRepositoryMock.GetByThingID invocations
  1299. func (mmGetByThingID *ThingImageRepositoryMock) GetByThingIDAfterCounter() uint64 {
  1300. return mm_atomic.LoadUint64(&mmGetByThingID.afterGetByThingIDCounter)
  1301. }
  1302. // GetByThingIDBeforeCounter returns a count of ThingImageRepositoryMock.GetByThingID invocations
  1303. func (mmGetByThingID *ThingImageRepositoryMock) GetByThingIDBeforeCounter() uint64 {
  1304. return mm_atomic.LoadUint64(&mmGetByThingID.beforeGetByThingIDCounter)
  1305. }
  1306. // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.GetByThingID.
  1307. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1308. func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Calls() []*ThingImageRepositoryMockGetByThingIDParams {
  1309. mmGetByThingID.mutex.RLock()
  1310. argCopy := make([]*ThingImageRepositoryMockGetByThingIDParams, len(mmGetByThingID.callArgs))
  1311. copy(argCopy, mmGetByThingID.callArgs)
  1312. mmGetByThingID.mutex.RUnlock()
  1313. return argCopy
  1314. }
  1315. // MinimockGetByThingIDDone returns true if the count of the GetByThingID invocations corresponds
  1316. // the number of defined expectations
  1317. func (m *ThingImageRepositoryMock) MinimockGetByThingIDDone() bool {
  1318. if m.GetByThingIDMock.optional {
  1319. // Optional methods provide '0 or more' call count restriction.
  1320. return true
  1321. }
  1322. for _, e := range m.GetByThingIDMock.expectations {
  1323. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1324. return false
  1325. }
  1326. }
  1327. return m.GetByThingIDMock.invocationsDone()
  1328. }
  1329. // MinimockGetByThingIDInspect logs each unmet expectation
  1330. func (m *ThingImageRepositoryMock) MinimockGetByThingIDInspect() {
  1331. for _, e := range m.GetByThingIDMock.expectations {
  1332. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1333. m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByThingID with params: %#v", *e.params)
  1334. }
  1335. }
  1336. afterGetByThingIDCounter := mm_atomic.LoadUint64(&m.afterGetByThingIDCounter)
  1337. // if default expectation was set then invocations count should be greater than zero
  1338. if m.GetByThingIDMock.defaultExpectation != nil && afterGetByThingIDCounter < 1 {
  1339. if m.GetByThingIDMock.defaultExpectation.params == nil {
  1340. m.t.Error("Expected call to ThingImageRepositoryMock.GetByThingID")
  1341. } else {
  1342. m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByThingID with params: %#v", *m.GetByThingIDMock.defaultExpectation.params)
  1343. }
  1344. }
  1345. // if func was set then invocations count should be greater than zero
  1346. if m.funcGetByThingID != nil && afterGetByThingIDCounter < 1 {
  1347. m.t.Error("Expected call to ThingImageRepositoryMock.GetByThingID")
  1348. }
  1349. if !m.GetByThingIDMock.invocationsDone() && afterGetByThingIDCounter > 0 {
  1350. m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.GetByThingID but found %d calls",
  1351. mm_atomic.LoadUint64(&m.GetByThingIDMock.expectedInvocations), afterGetByThingIDCounter)
  1352. }
  1353. }
  1354. // MinimockFinish checks that all mocked methods have been called the expected number of times
  1355. func (m *ThingImageRepositoryMock) MinimockFinish() {
  1356. m.finishOnce.Do(func() {
  1357. if !m.minimockDone() {
  1358. m.MinimockAddInspect()
  1359. m.MinimockDeleteInspect()
  1360. m.MinimockGetInspect()
  1361. m.MinimockGetByPlaceIDInspect()
  1362. m.MinimockGetByThingIDInspect()
  1363. }
  1364. })
  1365. }
  1366. // MinimockWait waits for all mocked methods to be called the expected number of times
  1367. func (m *ThingImageRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  1368. timeoutCh := mm_time.After(timeout)
  1369. for {
  1370. if m.minimockDone() {
  1371. return
  1372. }
  1373. select {
  1374. case <-timeoutCh:
  1375. m.MinimockFinish()
  1376. return
  1377. case <-mm_time.After(10 * mm_time.Millisecond):
  1378. }
  1379. }
  1380. }
  1381. func (m *ThingImageRepositoryMock) minimockDone() bool {
  1382. done := true
  1383. return done &&
  1384. m.MinimockAddDone() &&
  1385. m.MinimockDeleteDone() &&
  1386. m.MinimockGetDone() &&
  1387. m.MinimockGetByPlaceIDDone() &&
  1388. m.MinimockGetByThingIDDone()
  1389. }