thing_image_repository_minimock.go 64 KB

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