thing_repository_minimock.go 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118
  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.ThingRepository -o ./mocks/thing_repository_minimock.go -n ThingRepositoryMock
  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. // ThingRepositoryMock implements interfaces.ThingRepository
  14. type ThingRepositoryMock struct {
  15. t minimock.Tester
  16. funcAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)
  17. inspectFuncAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)
  18. afterAddCounter uint64
  19. beforeAddCounter uint64
  20. AddMock mThingRepositoryMockAdd
  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 mThingRepositoryMockBeginTx
  26. funcCommitTx func(tx *sql.Tx) (err error)
  27. inspectFuncCommitTx func(tx *sql.Tx)
  28. afterCommitTxCounter uint64
  29. beforeCommitTxCounter uint64
  30. CommitTxMock mThingRepositoryMockCommitTx
  31. funcDelete func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
  32. inspectFuncDelete func(ctx context.Context, thingID int, tx *sql.Tx)
  33. afterDeleteCounter uint64
  34. beforeDeleteCounter uint64
  35. DeleteMock mThingRepositoryMockDelete
  36. funcGet func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)
  37. inspectFuncGet func(ctx context.Context, thingID int)
  38. afterGetCounter uint64
  39. beforeGetCounter uint64
  40. GetMock mThingRepositoryMockGet
  41. funcGetAllByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
  42. inspectFuncGetAllByPlaceID func(ctx context.Context, placeID int)
  43. afterGetAllByPlaceIDCounter uint64
  44. beforeGetAllByPlaceIDCounter uint64
  45. GetAllByPlaceIDMock mThingRepositoryMockGetAllByPlaceID
  46. funcGetByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
  47. inspectFuncGetByPlaceID func(ctx context.Context, placeID int)
  48. afterGetByPlaceIDCounter uint64
  49. beforeGetByPlaceIDCounter uint64
  50. GetByPlaceIDMock mThingRepositoryMockGetByPlaceID
  51. funcSearch func(ctx context.Context, search string) (ta1 []models.Thing, err error)
  52. inspectFuncSearch func(ctx context.Context, search string)
  53. afterSearchCounter uint64
  54. beforeSearchCounter uint64
  55. SearchMock mThingRepositoryMockSearch
  56. funcUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)
  57. inspectFuncUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)
  58. afterUpdateCounter uint64
  59. beforeUpdateCounter uint64
  60. UpdateMock mThingRepositoryMockUpdate
  61. }
  62. // NewThingRepositoryMock returns a mock for interfaces.ThingRepository
  63. func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock {
  64. m := &ThingRepositoryMock{t: t}
  65. if controller, ok := t.(minimock.MockController); ok {
  66. controller.RegisterMocker(m)
  67. }
  68. m.AddMock = mThingRepositoryMockAdd{mock: m}
  69. m.AddMock.callArgs = []*ThingRepositoryMockAddParams{}
  70. m.BeginTxMock = mThingRepositoryMockBeginTx{mock: m}
  71. m.BeginTxMock.callArgs = []*ThingRepositoryMockBeginTxParams{}
  72. m.CommitTxMock = mThingRepositoryMockCommitTx{mock: m}
  73. m.CommitTxMock.callArgs = []*ThingRepositoryMockCommitTxParams{}
  74. m.DeleteMock = mThingRepositoryMockDelete{mock: m}
  75. m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{}
  76. m.GetMock = mThingRepositoryMockGet{mock: m}
  77. m.GetMock.callArgs = []*ThingRepositoryMockGetParams{}
  78. m.GetAllByPlaceIDMock = mThingRepositoryMockGetAllByPlaceID{mock: m}
  79. m.GetAllByPlaceIDMock.callArgs = []*ThingRepositoryMockGetAllByPlaceIDParams{}
  80. m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m}
  81. m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{}
  82. m.SearchMock = mThingRepositoryMockSearch{mock: m}
  83. m.SearchMock.callArgs = []*ThingRepositoryMockSearchParams{}
  84. m.UpdateMock = mThingRepositoryMockUpdate{mock: m}
  85. m.UpdateMock.callArgs = []*ThingRepositoryMockUpdateParams{}
  86. return m
  87. }
  88. type mThingRepositoryMockAdd struct {
  89. mock *ThingRepositoryMock
  90. defaultExpectation *ThingRepositoryMockAddExpectation
  91. expectations []*ThingRepositoryMockAddExpectation
  92. callArgs []*ThingRepositoryMockAddParams
  93. mutex sync.RWMutex
  94. }
  95. // ThingRepositoryMockAddExpectation specifies expectation struct of the ThingRepository.Add
  96. type ThingRepositoryMockAddExpectation struct {
  97. mock *ThingRepositoryMock
  98. params *ThingRepositoryMockAddParams
  99. results *ThingRepositoryMockAddResults
  100. Counter uint64
  101. }
  102. // ThingRepositoryMockAddParams contains parameters of the ThingRepository.Add
  103. type ThingRepositoryMockAddParams struct {
  104. ctx context.Context
  105. req models.AddThingRequest
  106. tx *sql.Tx
  107. }
  108. // ThingRepositoryMockAddResults contains results of the ThingRepository.Add
  109. type ThingRepositoryMockAddResults struct {
  110. i1 int
  111. err error
  112. }
  113. // Expect sets up expected params for ThingRepository.Add
  114. func (mmAdd *mThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *mThingRepositoryMockAdd {
  115. if mmAdd.mock.funcAdd != nil {
  116. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  117. }
  118. if mmAdd.defaultExpectation == nil {
  119. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
  120. }
  121. mmAdd.defaultExpectation.params = &ThingRepositoryMockAddParams{ctx, req, tx}
  122. for _, e := range mmAdd.expectations {
  123. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  124. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  125. }
  126. }
  127. return mmAdd
  128. }
  129. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Add
  130. func (mmAdd *mThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)) *mThingRepositoryMockAdd {
  131. if mmAdd.mock.inspectFuncAdd != nil {
  132. mmAdd.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Add")
  133. }
  134. mmAdd.mock.inspectFuncAdd = f
  135. return mmAdd
  136. }
  137. // Return sets up results that will be returned by ThingRepository.Add
  138. func (mmAdd *mThingRepositoryMockAdd) Return(i1 int, err error) *ThingRepositoryMock {
  139. if mmAdd.mock.funcAdd != nil {
  140. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  141. }
  142. if mmAdd.defaultExpectation == nil {
  143. mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{mock: mmAdd.mock}
  144. }
  145. mmAdd.defaultExpectation.results = &ThingRepositoryMockAddResults{i1, err}
  146. return mmAdd.mock
  147. }
  148. // Set uses given function f to mock the ThingRepository.Add method
  149. func (mmAdd *mThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)) *ThingRepositoryMock {
  150. if mmAdd.defaultExpectation != nil {
  151. mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Add method")
  152. }
  153. if len(mmAdd.expectations) > 0 {
  154. mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Add method")
  155. }
  156. mmAdd.mock.funcAdd = f
  157. return mmAdd.mock
  158. }
  159. // When sets expectation for the ThingRepository.Add which will trigger the result defined by the following
  160. // Then helper
  161. func (mmAdd *mThingRepositoryMockAdd) When(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *ThingRepositoryMockAddExpectation {
  162. if mmAdd.mock.funcAdd != nil {
  163. mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
  164. }
  165. expectation := &ThingRepositoryMockAddExpectation{
  166. mock: mmAdd.mock,
  167. params: &ThingRepositoryMockAddParams{ctx, req, tx},
  168. }
  169. mmAdd.expectations = append(mmAdd.expectations, expectation)
  170. return expectation
  171. }
  172. // Then sets up ThingRepository.Add return parameters for the expectation previously defined by the When method
  173. func (e *ThingRepositoryMockAddExpectation) Then(i1 int, err error) *ThingRepositoryMock {
  174. e.results = &ThingRepositoryMockAddResults{i1, err}
  175. return e.mock
  176. }
  177. // Add implements interfaces.ThingRepository
  178. func (mmAdd *ThingRepositoryMock) Add(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error) {
  179. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  180. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  181. if mmAdd.inspectFuncAdd != nil {
  182. mmAdd.inspectFuncAdd(ctx, req, tx)
  183. }
  184. mm_params := &ThingRepositoryMockAddParams{ctx, req, tx}
  185. // Record call args
  186. mmAdd.AddMock.mutex.Lock()
  187. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
  188. mmAdd.AddMock.mutex.Unlock()
  189. for _, e := range mmAdd.AddMock.expectations {
  190. if minimock.Equal(e.params, mm_params) {
  191. mm_atomic.AddUint64(&e.Counter, 1)
  192. return e.results.i1, e.results.err
  193. }
  194. }
  195. if mmAdd.AddMock.defaultExpectation != nil {
  196. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  197. mm_want := mmAdd.AddMock.defaultExpectation.params
  198. mm_got := ThingRepositoryMockAddParams{ctx, req, tx}
  199. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  200. mmAdd.t.Errorf("ThingRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  201. }
  202. mm_results := mmAdd.AddMock.defaultExpectation.results
  203. if mm_results == nil {
  204. mmAdd.t.Fatal("No results are set for the ThingRepositoryMock.Add")
  205. }
  206. return (*mm_results).i1, (*mm_results).err
  207. }
  208. if mmAdd.funcAdd != nil {
  209. return mmAdd.funcAdd(ctx, req, tx)
  210. }
  211. mmAdd.t.Fatalf("Unexpected call to ThingRepositoryMock.Add. %v %v %v", ctx, req, tx)
  212. return
  213. }
  214. // AddAfterCounter returns a count of finished ThingRepositoryMock.Add invocations
  215. func (mmAdd *ThingRepositoryMock) AddAfterCounter() uint64 {
  216. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  217. }
  218. // AddBeforeCounter returns a count of ThingRepositoryMock.Add invocations
  219. func (mmAdd *ThingRepositoryMock) AddBeforeCounter() uint64 {
  220. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  221. }
  222. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Add.
  223. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  224. func (mmAdd *mThingRepositoryMockAdd) Calls() []*ThingRepositoryMockAddParams {
  225. mmAdd.mutex.RLock()
  226. argCopy := make([]*ThingRepositoryMockAddParams, len(mmAdd.callArgs))
  227. copy(argCopy, mmAdd.callArgs)
  228. mmAdd.mutex.RUnlock()
  229. return argCopy
  230. }
  231. // MinimockAddDone returns true if the count of the Add invocations corresponds
  232. // the number of defined expectations
  233. func (m *ThingRepositoryMock) MinimockAddDone() bool {
  234. for _, e := range m.AddMock.expectations {
  235. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  236. return false
  237. }
  238. }
  239. // if default expectation was set then invocations count should be greater than zero
  240. if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  241. return false
  242. }
  243. // if func was set then invocations count should be greater than zero
  244. if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  245. return false
  246. }
  247. return true
  248. }
  249. // MinimockAddInspect logs each unmet expectation
  250. func (m *ThingRepositoryMock) MinimockAddInspect() {
  251. for _, e := range m.AddMock.expectations {
  252. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  253. m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *e.params)
  254. }
  255. }
  256. // if default expectation was set then invocations count should be greater than zero
  257. if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  258. if m.AddMock.defaultExpectation.params == nil {
  259. m.t.Error("Expected call to ThingRepositoryMock.Add")
  260. } else {
  261. m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  262. }
  263. }
  264. // if func was set then invocations count should be greater than zero
  265. if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
  266. m.t.Error("Expected call to ThingRepositoryMock.Add")
  267. }
  268. }
  269. type mThingRepositoryMockBeginTx struct {
  270. mock *ThingRepositoryMock
  271. defaultExpectation *ThingRepositoryMockBeginTxExpectation
  272. expectations []*ThingRepositoryMockBeginTxExpectation
  273. callArgs []*ThingRepositoryMockBeginTxParams
  274. mutex sync.RWMutex
  275. }
  276. // ThingRepositoryMockBeginTxExpectation specifies expectation struct of the ThingRepository.BeginTx
  277. type ThingRepositoryMockBeginTxExpectation struct {
  278. mock *ThingRepositoryMock
  279. params *ThingRepositoryMockBeginTxParams
  280. results *ThingRepositoryMockBeginTxResults
  281. Counter uint64
  282. }
  283. // ThingRepositoryMockBeginTxParams contains parameters of the ThingRepository.BeginTx
  284. type ThingRepositoryMockBeginTxParams struct {
  285. ctx context.Context
  286. level sql.IsolationLevel
  287. }
  288. // ThingRepositoryMockBeginTxResults contains results of the ThingRepository.BeginTx
  289. type ThingRepositoryMockBeginTxResults struct {
  290. tp1 *sql.Tx
  291. err error
  292. }
  293. // Expect sets up expected params for ThingRepository.BeginTx
  294. func (mmBeginTx *mThingRepositoryMockBeginTx) Expect(ctx context.Context, level sql.IsolationLevel) *mThingRepositoryMockBeginTx {
  295. if mmBeginTx.mock.funcBeginTx != nil {
  296. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  297. }
  298. if mmBeginTx.defaultExpectation == nil {
  299. mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
  300. }
  301. mmBeginTx.defaultExpectation.params = &ThingRepositoryMockBeginTxParams{ctx, level}
  302. for _, e := range mmBeginTx.expectations {
  303. if minimock.Equal(e.params, mmBeginTx.defaultExpectation.params) {
  304. mmBeginTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmBeginTx.defaultExpectation.params)
  305. }
  306. }
  307. return mmBeginTx
  308. }
  309. // Inspect accepts an inspector function that has same arguments as the ThingRepository.BeginTx
  310. func (mmBeginTx *mThingRepositoryMockBeginTx) Inspect(f func(ctx context.Context, level sql.IsolationLevel)) *mThingRepositoryMockBeginTx {
  311. if mmBeginTx.mock.inspectFuncBeginTx != nil {
  312. mmBeginTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.BeginTx")
  313. }
  314. mmBeginTx.mock.inspectFuncBeginTx = f
  315. return mmBeginTx
  316. }
  317. // Return sets up results that will be returned by ThingRepository.BeginTx
  318. func (mmBeginTx *mThingRepositoryMockBeginTx) Return(tp1 *sql.Tx, err error) *ThingRepositoryMock {
  319. if mmBeginTx.mock.funcBeginTx != nil {
  320. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  321. }
  322. if mmBeginTx.defaultExpectation == nil {
  323. mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{mock: mmBeginTx.mock}
  324. }
  325. mmBeginTx.defaultExpectation.results = &ThingRepositoryMockBeginTxResults{tp1, err}
  326. return mmBeginTx.mock
  327. }
  328. // Set uses given function f to mock the ThingRepository.BeginTx method
  329. func (mmBeginTx *mThingRepositoryMockBeginTx) Set(f func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)) *ThingRepositoryMock {
  330. if mmBeginTx.defaultExpectation != nil {
  331. mmBeginTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.BeginTx method")
  332. }
  333. if len(mmBeginTx.expectations) > 0 {
  334. mmBeginTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.BeginTx method")
  335. }
  336. mmBeginTx.mock.funcBeginTx = f
  337. return mmBeginTx.mock
  338. }
  339. // When sets expectation for the ThingRepository.BeginTx which will trigger the result defined by the following
  340. // Then helper
  341. func (mmBeginTx *mThingRepositoryMockBeginTx) When(ctx context.Context, level sql.IsolationLevel) *ThingRepositoryMockBeginTxExpectation {
  342. if mmBeginTx.mock.funcBeginTx != nil {
  343. mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
  344. }
  345. expectation := &ThingRepositoryMockBeginTxExpectation{
  346. mock: mmBeginTx.mock,
  347. params: &ThingRepositoryMockBeginTxParams{ctx, level},
  348. }
  349. mmBeginTx.expectations = append(mmBeginTx.expectations, expectation)
  350. return expectation
  351. }
  352. // Then sets up ThingRepository.BeginTx return parameters for the expectation previously defined by the When method
  353. func (e *ThingRepositoryMockBeginTxExpectation) Then(tp1 *sql.Tx, err error) *ThingRepositoryMock {
  354. e.results = &ThingRepositoryMockBeginTxResults{tp1, err}
  355. return e.mock
  356. }
  357. // BeginTx implements interfaces.ThingRepository
  358. func (mmBeginTx *ThingRepositoryMock) BeginTx(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error) {
  359. mm_atomic.AddUint64(&mmBeginTx.beforeBeginTxCounter, 1)
  360. defer mm_atomic.AddUint64(&mmBeginTx.afterBeginTxCounter, 1)
  361. if mmBeginTx.inspectFuncBeginTx != nil {
  362. mmBeginTx.inspectFuncBeginTx(ctx, level)
  363. }
  364. mm_params := &ThingRepositoryMockBeginTxParams{ctx, level}
  365. // Record call args
  366. mmBeginTx.BeginTxMock.mutex.Lock()
  367. mmBeginTx.BeginTxMock.callArgs = append(mmBeginTx.BeginTxMock.callArgs, mm_params)
  368. mmBeginTx.BeginTxMock.mutex.Unlock()
  369. for _, e := range mmBeginTx.BeginTxMock.expectations {
  370. if minimock.Equal(e.params, mm_params) {
  371. mm_atomic.AddUint64(&e.Counter, 1)
  372. return e.results.tp1, e.results.err
  373. }
  374. }
  375. if mmBeginTx.BeginTxMock.defaultExpectation != nil {
  376. mm_atomic.AddUint64(&mmBeginTx.BeginTxMock.defaultExpectation.Counter, 1)
  377. mm_want := mmBeginTx.BeginTxMock.defaultExpectation.params
  378. mm_got := ThingRepositoryMockBeginTxParams{ctx, level}
  379. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  380. mmBeginTx.t.Errorf("ThingRepositoryMock.BeginTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  381. }
  382. mm_results := mmBeginTx.BeginTxMock.defaultExpectation.results
  383. if mm_results == nil {
  384. mmBeginTx.t.Fatal("No results are set for the ThingRepositoryMock.BeginTx")
  385. }
  386. return (*mm_results).tp1, (*mm_results).err
  387. }
  388. if mmBeginTx.funcBeginTx != nil {
  389. return mmBeginTx.funcBeginTx(ctx, level)
  390. }
  391. mmBeginTx.t.Fatalf("Unexpected call to ThingRepositoryMock.BeginTx. %v %v", ctx, level)
  392. return
  393. }
  394. // BeginTxAfterCounter returns a count of finished ThingRepositoryMock.BeginTx invocations
  395. func (mmBeginTx *ThingRepositoryMock) BeginTxAfterCounter() uint64 {
  396. return mm_atomic.LoadUint64(&mmBeginTx.afterBeginTxCounter)
  397. }
  398. // BeginTxBeforeCounter returns a count of ThingRepositoryMock.BeginTx invocations
  399. func (mmBeginTx *ThingRepositoryMock) BeginTxBeforeCounter() uint64 {
  400. return mm_atomic.LoadUint64(&mmBeginTx.beforeBeginTxCounter)
  401. }
  402. // Calls returns a list of arguments used in each call to ThingRepositoryMock.BeginTx.
  403. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  404. func (mmBeginTx *mThingRepositoryMockBeginTx) Calls() []*ThingRepositoryMockBeginTxParams {
  405. mmBeginTx.mutex.RLock()
  406. argCopy := make([]*ThingRepositoryMockBeginTxParams, len(mmBeginTx.callArgs))
  407. copy(argCopy, mmBeginTx.callArgs)
  408. mmBeginTx.mutex.RUnlock()
  409. return argCopy
  410. }
  411. // MinimockBeginTxDone returns true if the count of the BeginTx invocations corresponds
  412. // the number of defined expectations
  413. func (m *ThingRepositoryMock) MinimockBeginTxDone() bool {
  414. for _, e := range m.BeginTxMock.expectations {
  415. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  416. return false
  417. }
  418. }
  419. // if default expectation was set then invocations count should be greater than zero
  420. if m.BeginTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
  421. return false
  422. }
  423. // if func was set then invocations count should be greater than zero
  424. if m.funcBeginTx != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
  425. return false
  426. }
  427. return true
  428. }
  429. // MinimockBeginTxInspect logs each unmet expectation
  430. func (m *ThingRepositoryMock) MinimockBeginTxInspect() {
  431. for _, e := range m.BeginTxMock.expectations {
  432. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  433. m.t.Errorf("Expected call to ThingRepositoryMock.BeginTx with params: %#v", *e.params)
  434. }
  435. }
  436. // if default expectation was set then invocations count should be greater than zero
  437. if m.BeginTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
  438. if m.BeginTxMock.defaultExpectation.params == nil {
  439. m.t.Error("Expected call to ThingRepositoryMock.BeginTx")
  440. } else {
  441. m.t.Errorf("Expected call to ThingRepositoryMock.BeginTx with params: %#v", *m.BeginTxMock.defaultExpectation.params)
  442. }
  443. }
  444. // if func was set then invocations count should be greater than zero
  445. if m.funcBeginTx != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
  446. m.t.Error("Expected call to ThingRepositoryMock.BeginTx")
  447. }
  448. }
  449. type mThingRepositoryMockCommitTx struct {
  450. mock *ThingRepositoryMock
  451. defaultExpectation *ThingRepositoryMockCommitTxExpectation
  452. expectations []*ThingRepositoryMockCommitTxExpectation
  453. callArgs []*ThingRepositoryMockCommitTxParams
  454. mutex sync.RWMutex
  455. }
  456. // ThingRepositoryMockCommitTxExpectation specifies expectation struct of the ThingRepository.CommitTx
  457. type ThingRepositoryMockCommitTxExpectation struct {
  458. mock *ThingRepositoryMock
  459. params *ThingRepositoryMockCommitTxParams
  460. results *ThingRepositoryMockCommitTxResults
  461. Counter uint64
  462. }
  463. // ThingRepositoryMockCommitTxParams contains parameters of the ThingRepository.CommitTx
  464. type ThingRepositoryMockCommitTxParams struct {
  465. tx *sql.Tx
  466. }
  467. // ThingRepositoryMockCommitTxResults contains results of the ThingRepository.CommitTx
  468. type ThingRepositoryMockCommitTxResults struct {
  469. err error
  470. }
  471. // Expect sets up expected params for ThingRepository.CommitTx
  472. func (mmCommitTx *mThingRepositoryMockCommitTx) Expect(tx *sql.Tx) *mThingRepositoryMockCommitTx {
  473. if mmCommitTx.mock.funcCommitTx != nil {
  474. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
  475. }
  476. if mmCommitTx.defaultExpectation == nil {
  477. mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{}
  478. }
  479. mmCommitTx.defaultExpectation.params = &ThingRepositoryMockCommitTxParams{tx}
  480. for _, e := range mmCommitTx.expectations {
  481. if minimock.Equal(e.params, mmCommitTx.defaultExpectation.params) {
  482. mmCommitTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCommitTx.defaultExpectation.params)
  483. }
  484. }
  485. return mmCommitTx
  486. }
  487. // Inspect accepts an inspector function that has same arguments as the ThingRepository.CommitTx
  488. func (mmCommitTx *mThingRepositoryMockCommitTx) Inspect(f func(tx *sql.Tx)) *mThingRepositoryMockCommitTx {
  489. if mmCommitTx.mock.inspectFuncCommitTx != nil {
  490. mmCommitTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.CommitTx")
  491. }
  492. mmCommitTx.mock.inspectFuncCommitTx = f
  493. return mmCommitTx
  494. }
  495. // Return sets up results that will be returned by ThingRepository.CommitTx
  496. func (mmCommitTx *mThingRepositoryMockCommitTx) Return(err error) *ThingRepositoryMock {
  497. if mmCommitTx.mock.funcCommitTx != nil {
  498. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
  499. }
  500. if mmCommitTx.defaultExpectation == nil {
  501. mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{mock: mmCommitTx.mock}
  502. }
  503. mmCommitTx.defaultExpectation.results = &ThingRepositoryMockCommitTxResults{err}
  504. return mmCommitTx.mock
  505. }
  506. // Set uses given function f to mock the ThingRepository.CommitTx method
  507. func (mmCommitTx *mThingRepositoryMockCommitTx) Set(f func(tx *sql.Tx) (err error)) *ThingRepositoryMock {
  508. if mmCommitTx.defaultExpectation != nil {
  509. mmCommitTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.CommitTx method")
  510. }
  511. if len(mmCommitTx.expectations) > 0 {
  512. mmCommitTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.CommitTx method")
  513. }
  514. mmCommitTx.mock.funcCommitTx = f
  515. return mmCommitTx.mock
  516. }
  517. // When sets expectation for the ThingRepository.CommitTx which will trigger the result defined by the following
  518. // Then helper
  519. func (mmCommitTx *mThingRepositoryMockCommitTx) When(tx *sql.Tx) *ThingRepositoryMockCommitTxExpectation {
  520. if mmCommitTx.mock.funcCommitTx != nil {
  521. mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
  522. }
  523. expectation := &ThingRepositoryMockCommitTxExpectation{
  524. mock: mmCommitTx.mock,
  525. params: &ThingRepositoryMockCommitTxParams{tx},
  526. }
  527. mmCommitTx.expectations = append(mmCommitTx.expectations, expectation)
  528. return expectation
  529. }
  530. // Then sets up ThingRepository.CommitTx return parameters for the expectation previously defined by the When method
  531. func (e *ThingRepositoryMockCommitTxExpectation) Then(err error) *ThingRepositoryMock {
  532. e.results = &ThingRepositoryMockCommitTxResults{err}
  533. return e.mock
  534. }
  535. // CommitTx implements interfaces.ThingRepository
  536. func (mmCommitTx *ThingRepositoryMock) CommitTx(tx *sql.Tx) (err error) {
  537. mm_atomic.AddUint64(&mmCommitTx.beforeCommitTxCounter, 1)
  538. defer mm_atomic.AddUint64(&mmCommitTx.afterCommitTxCounter, 1)
  539. if mmCommitTx.inspectFuncCommitTx != nil {
  540. mmCommitTx.inspectFuncCommitTx(tx)
  541. }
  542. mm_params := &ThingRepositoryMockCommitTxParams{tx}
  543. // Record call args
  544. mmCommitTx.CommitTxMock.mutex.Lock()
  545. mmCommitTx.CommitTxMock.callArgs = append(mmCommitTx.CommitTxMock.callArgs, mm_params)
  546. mmCommitTx.CommitTxMock.mutex.Unlock()
  547. for _, e := range mmCommitTx.CommitTxMock.expectations {
  548. if minimock.Equal(e.params, mm_params) {
  549. mm_atomic.AddUint64(&e.Counter, 1)
  550. return e.results.err
  551. }
  552. }
  553. if mmCommitTx.CommitTxMock.defaultExpectation != nil {
  554. mm_atomic.AddUint64(&mmCommitTx.CommitTxMock.defaultExpectation.Counter, 1)
  555. mm_want := mmCommitTx.CommitTxMock.defaultExpectation.params
  556. mm_got := ThingRepositoryMockCommitTxParams{tx}
  557. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  558. mmCommitTx.t.Errorf("ThingRepositoryMock.CommitTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  559. }
  560. mm_results := mmCommitTx.CommitTxMock.defaultExpectation.results
  561. if mm_results == nil {
  562. mmCommitTx.t.Fatal("No results are set for the ThingRepositoryMock.CommitTx")
  563. }
  564. return (*mm_results).err
  565. }
  566. if mmCommitTx.funcCommitTx != nil {
  567. return mmCommitTx.funcCommitTx(tx)
  568. }
  569. mmCommitTx.t.Fatalf("Unexpected call to ThingRepositoryMock.CommitTx. %v", tx)
  570. return
  571. }
  572. // CommitTxAfterCounter returns a count of finished ThingRepositoryMock.CommitTx invocations
  573. func (mmCommitTx *ThingRepositoryMock) CommitTxAfterCounter() uint64 {
  574. return mm_atomic.LoadUint64(&mmCommitTx.afterCommitTxCounter)
  575. }
  576. // CommitTxBeforeCounter returns a count of ThingRepositoryMock.CommitTx invocations
  577. func (mmCommitTx *ThingRepositoryMock) CommitTxBeforeCounter() uint64 {
  578. return mm_atomic.LoadUint64(&mmCommitTx.beforeCommitTxCounter)
  579. }
  580. // Calls returns a list of arguments used in each call to ThingRepositoryMock.CommitTx.
  581. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  582. func (mmCommitTx *mThingRepositoryMockCommitTx) Calls() []*ThingRepositoryMockCommitTxParams {
  583. mmCommitTx.mutex.RLock()
  584. argCopy := make([]*ThingRepositoryMockCommitTxParams, len(mmCommitTx.callArgs))
  585. copy(argCopy, mmCommitTx.callArgs)
  586. mmCommitTx.mutex.RUnlock()
  587. return argCopy
  588. }
  589. // MinimockCommitTxDone returns true if the count of the CommitTx invocations corresponds
  590. // the number of defined expectations
  591. func (m *ThingRepositoryMock) MinimockCommitTxDone() bool {
  592. for _, e := range m.CommitTxMock.expectations {
  593. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  594. return false
  595. }
  596. }
  597. // if default expectation was set then invocations count should be greater than zero
  598. if m.CommitTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
  599. return false
  600. }
  601. // if func was set then invocations count should be greater than zero
  602. if m.funcCommitTx != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
  603. return false
  604. }
  605. return true
  606. }
  607. // MinimockCommitTxInspect logs each unmet expectation
  608. func (m *ThingRepositoryMock) MinimockCommitTxInspect() {
  609. for _, e := range m.CommitTxMock.expectations {
  610. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  611. m.t.Errorf("Expected call to ThingRepositoryMock.CommitTx with params: %#v", *e.params)
  612. }
  613. }
  614. // if default expectation was set then invocations count should be greater than zero
  615. if m.CommitTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
  616. if m.CommitTxMock.defaultExpectation.params == nil {
  617. m.t.Error("Expected call to ThingRepositoryMock.CommitTx")
  618. } else {
  619. m.t.Errorf("Expected call to ThingRepositoryMock.CommitTx with params: %#v", *m.CommitTxMock.defaultExpectation.params)
  620. }
  621. }
  622. // if func was set then invocations count should be greater than zero
  623. if m.funcCommitTx != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
  624. m.t.Error("Expected call to ThingRepositoryMock.CommitTx")
  625. }
  626. }
  627. type mThingRepositoryMockDelete struct {
  628. mock *ThingRepositoryMock
  629. defaultExpectation *ThingRepositoryMockDeleteExpectation
  630. expectations []*ThingRepositoryMockDeleteExpectation
  631. callArgs []*ThingRepositoryMockDeleteParams
  632. mutex sync.RWMutex
  633. }
  634. // ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete
  635. type ThingRepositoryMockDeleteExpectation struct {
  636. mock *ThingRepositoryMock
  637. params *ThingRepositoryMockDeleteParams
  638. results *ThingRepositoryMockDeleteResults
  639. Counter uint64
  640. }
  641. // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
  642. type ThingRepositoryMockDeleteParams struct {
  643. ctx context.Context
  644. thingID int
  645. tx *sql.Tx
  646. }
  647. // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
  648. type ThingRepositoryMockDeleteResults struct {
  649. err error
  650. }
  651. // Expect sets up expected params for ThingRepository.Delete
  652. func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingRepositoryMockDelete {
  653. if mmDelete.mock.funcDelete != nil {
  654. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  655. }
  656. if mmDelete.defaultExpectation == nil {
  657. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  658. }
  659. mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, thingID, tx}
  660. for _, e := range mmDelete.expectations {
  661. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  662. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  663. }
  664. }
  665. return mmDelete
  666. }
  667. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
  668. func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingRepositoryMockDelete {
  669. if mmDelete.mock.inspectFuncDelete != nil {
  670. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
  671. }
  672. mmDelete.mock.inspectFuncDelete = f
  673. return mmDelete
  674. }
  675. // Return sets up results that will be returned by ThingRepository.Delete
  676. func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock {
  677. if mmDelete.mock.funcDelete != nil {
  678. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  679. }
  680. if mmDelete.defaultExpectation == nil {
  681. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  682. }
  683. mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err}
  684. return mmDelete.mock
  685. }
  686. // Set uses given function f to mock the ThingRepository.Delete method
  687. func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingRepositoryMock {
  688. if mmDelete.defaultExpectation != nil {
  689. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
  690. }
  691. if len(mmDelete.expectations) > 0 {
  692. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method")
  693. }
  694. mmDelete.mock.funcDelete = f
  695. return mmDelete.mock
  696. }
  697. // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
  698. // Then helper
  699. func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingRepositoryMockDeleteExpectation {
  700. if mmDelete.mock.funcDelete != nil {
  701. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  702. }
  703. expectation := &ThingRepositoryMockDeleteExpectation{
  704. mock: mmDelete.mock,
  705. params: &ThingRepositoryMockDeleteParams{ctx, thingID, tx},
  706. }
  707. mmDelete.expectations = append(mmDelete.expectations, expectation)
  708. return expectation
  709. }
  710. // Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method
  711. func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock {
  712. e.results = &ThingRepositoryMockDeleteResults{err}
  713. return e.mock
  714. }
  715. // Delete implements interfaces.ThingRepository
  716. func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
  717. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  718. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  719. if mmDelete.inspectFuncDelete != nil {
  720. mmDelete.inspectFuncDelete(ctx, thingID, tx)
  721. }
  722. mm_params := &ThingRepositoryMockDeleteParams{ctx, thingID, tx}
  723. // Record call args
  724. mmDelete.DeleteMock.mutex.Lock()
  725. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, mm_params)
  726. mmDelete.DeleteMock.mutex.Unlock()
  727. for _, e := range mmDelete.DeleteMock.expectations {
  728. if minimock.Equal(e.params, mm_params) {
  729. mm_atomic.AddUint64(&e.Counter, 1)
  730. return e.results.err
  731. }
  732. }
  733. if mmDelete.DeleteMock.defaultExpectation != nil {
  734. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  735. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  736. mm_got := ThingRepositoryMockDeleteParams{ctx, thingID, tx}
  737. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  738. mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  739. }
  740. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  741. if mm_results == nil {
  742. mmDelete.t.Fatal("No results are set for the ThingRepositoryMock.Delete")
  743. }
  744. return (*mm_results).err
  745. }
  746. if mmDelete.funcDelete != nil {
  747. return mmDelete.funcDelete(ctx, thingID, tx)
  748. }
  749. mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
  750. return
  751. }
  752. // DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations
  753. func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 {
  754. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  755. }
  756. // DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations
  757. func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 {
  758. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  759. }
  760. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete.
  761. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  762. func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams {
  763. mmDelete.mutex.RLock()
  764. argCopy := make([]*ThingRepositoryMockDeleteParams, len(mmDelete.callArgs))
  765. copy(argCopy, mmDelete.callArgs)
  766. mmDelete.mutex.RUnlock()
  767. return argCopy
  768. }
  769. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  770. // the number of defined expectations
  771. func (m *ThingRepositoryMock) MinimockDeleteDone() bool {
  772. for _, e := range m.DeleteMock.expectations {
  773. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  774. return false
  775. }
  776. }
  777. // if default expectation was set then invocations count should be greater than zero
  778. if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  779. return false
  780. }
  781. // if func was set then invocations count should be greater than zero
  782. if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  783. return false
  784. }
  785. return true
  786. }
  787. // MinimockDeleteInspect logs each unmet expectation
  788. func (m *ThingRepositoryMock) MinimockDeleteInspect() {
  789. for _, e := range m.DeleteMock.expectations {
  790. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  791. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *e.params)
  792. }
  793. }
  794. // if default expectation was set then invocations count should be greater than zero
  795. if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  796. if m.DeleteMock.defaultExpectation.params == nil {
  797. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  798. } else {
  799. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  800. }
  801. }
  802. // if func was set then invocations count should be greater than zero
  803. if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
  804. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  805. }
  806. }
  807. type mThingRepositoryMockGet struct {
  808. mock *ThingRepositoryMock
  809. defaultExpectation *ThingRepositoryMockGetExpectation
  810. expectations []*ThingRepositoryMockGetExpectation
  811. callArgs []*ThingRepositoryMockGetParams
  812. mutex sync.RWMutex
  813. }
  814. // ThingRepositoryMockGetExpectation specifies expectation struct of the ThingRepository.Get
  815. type ThingRepositoryMockGetExpectation struct {
  816. mock *ThingRepositoryMock
  817. params *ThingRepositoryMockGetParams
  818. results *ThingRepositoryMockGetResults
  819. Counter uint64
  820. }
  821. // ThingRepositoryMockGetParams contains parameters of the ThingRepository.Get
  822. type ThingRepositoryMockGetParams struct {
  823. ctx context.Context
  824. thingID int
  825. }
  826. // ThingRepositoryMockGetResults contains results of the ThingRepository.Get
  827. type ThingRepositoryMockGetResults struct {
  828. tp1 *models.Thing
  829. err error
  830. }
  831. // Expect sets up expected params for ThingRepository.Get
  832. func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, thingID int) *mThingRepositoryMockGet {
  833. if mmGet.mock.funcGet != nil {
  834. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  835. }
  836. if mmGet.defaultExpectation == nil {
  837. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
  838. }
  839. mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, thingID}
  840. for _, e := range mmGet.expectations {
  841. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  842. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  843. }
  844. }
  845. return mmGet
  846. }
  847. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Get
  848. func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, thingID int)) *mThingRepositoryMockGet {
  849. if mmGet.mock.inspectFuncGet != nil {
  850. mmGet.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Get")
  851. }
  852. mmGet.mock.inspectFuncGet = f
  853. return mmGet
  854. }
  855. // Return sets up results that will be returned by ThingRepository.Get
  856. func (mmGet *mThingRepositoryMockGet) Return(tp1 *models.Thing, err error) *ThingRepositoryMock {
  857. if mmGet.mock.funcGet != nil {
  858. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  859. }
  860. if mmGet.defaultExpectation == nil {
  861. mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{mock: mmGet.mock}
  862. }
  863. mmGet.defaultExpectation.results = &ThingRepositoryMockGetResults{tp1, err}
  864. return mmGet.mock
  865. }
  866. // Set uses given function f to mock the ThingRepository.Get method
  867. func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
  868. if mmGet.defaultExpectation != nil {
  869. mmGet.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Get method")
  870. }
  871. if len(mmGet.expectations) > 0 {
  872. mmGet.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Get method")
  873. }
  874. mmGet.mock.funcGet = f
  875. return mmGet.mock
  876. }
  877. // When sets expectation for the ThingRepository.Get which will trigger the result defined by the following
  878. // Then helper
  879. func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, thingID int) *ThingRepositoryMockGetExpectation {
  880. if mmGet.mock.funcGet != nil {
  881. mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
  882. }
  883. expectation := &ThingRepositoryMockGetExpectation{
  884. mock: mmGet.mock,
  885. params: &ThingRepositoryMockGetParams{ctx, thingID},
  886. }
  887. mmGet.expectations = append(mmGet.expectations, expectation)
  888. return expectation
  889. }
  890. // Then sets up ThingRepository.Get return parameters for the expectation previously defined by the When method
  891. func (e *ThingRepositoryMockGetExpectation) Then(tp1 *models.Thing, err error) *ThingRepositoryMock {
  892. e.results = &ThingRepositoryMockGetResults{tp1, err}
  893. return e.mock
  894. }
  895. // Get implements interfaces.ThingRepository
  896. func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *models.Thing, err error) {
  897. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  898. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  899. if mmGet.inspectFuncGet != nil {
  900. mmGet.inspectFuncGet(ctx, thingID)
  901. }
  902. mm_params := &ThingRepositoryMockGetParams{ctx, thingID}
  903. // Record call args
  904. mmGet.GetMock.mutex.Lock()
  905. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, mm_params)
  906. mmGet.GetMock.mutex.Unlock()
  907. for _, e := range mmGet.GetMock.expectations {
  908. if minimock.Equal(e.params, mm_params) {
  909. mm_atomic.AddUint64(&e.Counter, 1)
  910. return e.results.tp1, e.results.err
  911. }
  912. }
  913. if mmGet.GetMock.defaultExpectation != nil {
  914. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  915. mm_want := mmGet.GetMock.defaultExpectation.params
  916. mm_got := ThingRepositoryMockGetParams{ctx, thingID}
  917. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  918. mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  919. }
  920. mm_results := mmGet.GetMock.defaultExpectation.results
  921. if mm_results == nil {
  922. mmGet.t.Fatal("No results are set for the ThingRepositoryMock.Get")
  923. }
  924. return (*mm_results).tp1, (*mm_results).err
  925. }
  926. if mmGet.funcGet != nil {
  927. return mmGet.funcGet(ctx, thingID)
  928. }
  929. mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, thingID)
  930. return
  931. }
  932. // GetAfterCounter returns a count of finished ThingRepositoryMock.Get invocations
  933. func (mmGet *ThingRepositoryMock) GetAfterCounter() uint64 {
  934. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  935. }
  936. // GetBeforeCounter returns a count of ThingRepositoryMock.Get invocations
  937. func (mmGet *ThingRepositoryMock) GetBeforeCounter() uint64 {
  938. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  939. }
  940. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Get.
  941. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  942. func (mmGet *mThingRepositoryMockGet) Calls() []*ThingRepositoryMockGetParams {
  943. mmGet.mutex.RLock()
  944. argCopy := make([]*ThingRepositoryMockGetParams, len(mmGet.callArgs))
  945. copy(argCopy, mmGet.callArgs)
  946. mmGet.mutex.RUnlock()
  947. return argCopy
  948. }
  949. // MinimockGetDone returns true if the count of the Get invocations corresponds
  950. // the number of defined expectations
  951. func (m *ThingRepositoryMock) MinimockGetDone() bool {
  952. for _, e := range m.GetMock.expectations {
  953. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  954. return false
  955. }
  956. }
  957. // if default expectation was set then invocations count should be greater than zero
  958. if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  959. return false
  960. }
  961. // if func was set then invocations count should be greater than zero
  962. if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  963. return false
  964. }
  965. return true
  966. }
  967. // MinimockGetInspect logs each unmet expectation
  968. func (m *ThingRepositoryMock) MinimockGetInspect() {
  969. for _, e := range m.GetMock.expectations {
  970. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  971. m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *e.params)
  972. }
  973. }
  974. // if default expectation was set then invocations count should be greater than zero
  975. if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  976. if m.GetMock.defaultExpectation.params == nil {
  977. m.t.Error("Expected call to ThingRepositoryMock.Get")
  978. } else {
  979. m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  980. }
  981. }
  982. // if func was set then invocations count should be greater than zero
  983. if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
  984. m.t.Error("Expected call to ThingRepositoryMock.Get")
  985. }
  986. }
  987. type mThingRepositoryMockGetAllByPlaceID struct {
  988. mock *ThingRepositoryMock
  989. defaultExpectation *ThingRepositoryMockGetAllByPlaceIDExpectation
  990. expectations []*ThingRepositoryMockGetAllByPlaceIDExpectation
  991. callArgs []*ThingRepositoryMockGetAllByPlaceIDParams
  992. mutex sync.RWMutex
  993. }
  994. // ThingRepositoryMockGetAllByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetAllByPlaceID
  995. type ThingRepositoryMockGetAllByPlaceIDExpectation struct {
  996. mock *ThingRepositoryMock
  997. params *ThingRepositoryMockGetAllByPlaceIDParams
  998. results *ThingRepositoryMockGetAllByPlaceIDResults
  999. Counter uint64
  1000. }
  1001. // ThingRepositoryMockGetAllByPlaceIDParams contains parameters of the ThingRepository.GetAllByPlaceID
  1002. type ThingRepositoryMockGetAllByPlaceIDParams struct {
  1003. ctx context.Context
  1004. placeID int
  1005. }
  1006. // ThingRepositoryMockGetAllByPlaceIDResults contains results of the ThingRepository.GetAllByPlaceID
  1007. type ThingRepositoryMockGetAllByPlaceIDResults struct {
  1008. ta1 []models.Thing
  1009. err error
  1010. }
  1011. // Expect sets up expected params for ThingRepository.GetAllByPlaceID
  1012. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetAllByPlaceID {
  1013. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1014. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1015. }
  1016. if mmGetAllByPlaceID.defaultExpectation == nil {
  1017. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
  1018. }
  1019. mmGetAllByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
  1020. for _, e := range mmGetAllByPlaceID.expectations {
  1021. if minimock.Equal(e.params, mmGetAllByPlaceID.defaultExpectation.params) {
  1022. mmGetAllByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllByPlaceID.defaultExpectation.params)
  1023. }
  1024. }
  1025. return mmGetAllByPlaceID
  1026. }
  1027. // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetAllByPlaceID
  1028. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetAllByPlaceID {
  1029. if mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID != nil {
  1030. mmGetAllByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetAllByPlaceID")
  1031. }
  1032. mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID = f
  1033. return mmGetAllByPlaceID
  1034. }
  1035. // Return sets up results that will be returned by ThingRepository.GetAllByPlaceID
  1036. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1037. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1038. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1039. }
  1040. if mmGetAllByPlaceID.defaultExpectation == nil {
  1041. mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{mock: mmGetAllByPlaceID.mock}
  1042. }
  1043. mmGetAllByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
  1044. return mmGetAllByPlaceID.mock
  1045. }
  1046. // Set uses given function f to mock the ThingRepository.GetAllByPlaceID method
  1047. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  1048. if mmGetAllByPlaceID.defaultExpectation != nil {
  1049. mmGetAllByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetAllByPlaceID method")
  1050. }
  1051. if len(mmGetAllByPlaceID.expectations) > 0 {
  1052. mmGetAllByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetAllByPlaceID method")
  1053. }
  1054. mmGetAllByPlaceID.mock.funcGetAllByPlaceID = f
  1055. return mmGetAllByPlaceID.mock
  1056. }
  1057. // When sets expectation for the ThingRepository.GetAllByPlaceID which will trigger the result defined by the following
  1058. // Then helper
  1059. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetAllByPlaceIDExpectation {
  1060. if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
  1061. mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
  1062. }
  1063. expectation := &ThingRepositoryMockGetAllByPlaceIDExpectation{
  1064. mock: mmGetAllByPlaceID.mock,
  1065. params: &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID},
  1066. }
  1067. mmGetAllByPlaceID.expectations = append(mmGetAllByPlaceID.expectations, expectation)
  1068. return expectation
  1069. }
  1070. // Then sets up ThingRepository.GetAllByPlaceID return parameters for the expectation previously defined by the When method
  1071. func (e *ThingRepositoryMockGetAllByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1072. e.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
  1073. return e.mock
  1074. }
  1075. // GetAllByPlaceID implements interfaces.ThingRepository
  1076. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
  1077. mm_atomic.AddUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter, 1)
  1078. defer mm_atomic.AddUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter, 1)
  1079. if mmGetAllByPlaceID.inspectFuncGetAllByPlaceID != nil {
  1080. mmGetAllByPlaceID.inspectFuncGetAllByPlaceID(ctx, placeID)
  1081. }
  1082. mm_params := &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
  1083. // Record call args
  1084. mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Lock()
  1085. mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs = append(mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs, mm_params)
  1086. mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Unlock()
  1087. for _, e := range mmGetAllByPlaceID.GetAllByPlaceIDMock.expectations {
  1088. if minimock.Equal(e.params, mm_params) {
  1089. mm_atomic.AddUint64(&e.Counter, 1)
  1090. return e.results.ta1, e.results.err
  1091. }
  1092. }
  1093. if mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation != nil {
  1094. mm_atomic.AddUint64(&mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.Counter, 1)
  1095. mm_want := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.params
  1096. mm_got := ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
  1097. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1098. mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1099. }
  1100. mm_results := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.results
  1101. if mm_results == nil {
  1102. mmGetAllByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetAllByPlaceID")
  1103. }
  1104. return (*mm_results).ta1, (*mm_results).err
  1105. }
  1106. if mmGetAllByPlaceID.funcGetAllByPlaceID != nil {
  1107. return mmGetAllByPlaceID.funcGetAllByPlaceID(ctx, placeID)
  1108. }
  1109. mmGetAllByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetAllByPlaceID. %v %v", ctx, placeID)
  1110. return
  1111. }
  1112. // GetAllByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetAllByPlaceID invocations
  1113. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDAfterCounter() uint64 {
  1114. return mm_atomic.LoadUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter)
  1115. }
  1116. // GetAllByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetAllByPlaceID invocations
  1117. func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDBeforeCounter() uint64 {
  1118. return mm_atomic.LoadUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter)
  1119. }
  1120. // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetAllByPlaceID.
  1121. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1122. func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Calls() []*ThingRepositoryMockGetAllByPlaceIDParams {
  1123. mmGetAllByPlaceID.mutex.RLock()
  1124. argCopy := make([]*ThingRepositoryMockGetAllByPlaceIDParams, len(mmGetAllByPlaceID.callArgs))
  1125. copy(argCopy, mmGetAllByPlaceID.callArgs)
  1126. mmGetAllByPlaceID.mutex.RUnlock()
  1127. return argCopy
  1128. }
  1129. // MinimockGetAllByPlaceIDDone returns true if the count of the GetAllByPlaceID invocations corresponds
  1130. // the number of defined expectations
  1131. func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDDone() bool {
  1132. for _, e := range m.GetAllByPlaceIDMock.expectations {
  1133. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1134. return false
  1135. }
  1136. }
  1137. // if default expectation was set then invocations count should be greater than zero
  1138. if m.GetAllByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
  1139. return false
  1140. }
  1141. // if func was set then invocations count should be greater than zero
  1142. if m.funcGetAllByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
  1143. return false
  1144. }
  1145. return true
  1146. }
  1147. // MinimockGetAllByPlaceIDInspect logs each unmet expectation
  1148. func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDInspect() {
  1149. for _, e := range m.GetAllByPlaceIDMock.expectations {
  1150. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1151. m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *e.params)
  1152. }
  1153. }
  1154. // if default expectation was set then invocations count should be greater than zero
  1155. if m.GetAllByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
  1156. if m.GetAllByPlaceIDMock.defaultExpectation.params == nil {
  1157. m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
  1158. } else {
  1159. m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *m.GetAllByPlaceIDMock.defaultExpectation.params)
  1160. }
  1161. }
  1162. // if func was set then invocations count should be greater than zero
  1163. if m.funcGetAllByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
  1164. m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
  1165. }
  1166. }
  1167. type mThingRepositoryMockGetByPlaceID struct {
  1168. mock *ThingRepositoryMock
  1169. defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation
  1170. expectations []*ThingRepositoryMockGetByPlaceIDExpectation
  1171. callArgs []*ThingRepositoryMockGetByPlaceIDParams
  1172. mutex sync.RWMutex
  1173. }
  1174. // ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID
  1175. type ThingRepositoryMockGetByPlaceIDExpectation struct {
  1176. mock *ThingRepositoryMock
  1177. params *ThingRepositoryMockGetByPlaceIDParams
  1178. results *ThingRepositoryMockGetByPlaceIDResults
  1179. Counter uint64
  1180. }
  1181. // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
  1182. type ThingRepositoryMockGetByPlaceIDParams struct {
  1183. ctx context.Context
  1184. placeID int
  1185. }
  1186. // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
  1187. type ThingRepositoryMockGetByPlaceIDResults struct {
  1188. ta1 []models.Thing
  1189. err error
  1190. }
  1191. // Expect sets up expected params for ThingRepository.GetByPlaceID
  1192. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetByPlaceID {
  1193. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1194. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1195. }
  1196. if mmGetByPlaceID.defaultExpectation == nil {
  1197. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  1198. }
  1199. mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
  1200. for _, e := range mmGetByPlaceID.expectations {
  1201. if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
  1202. mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
  1203. }
  1204. }
  1205. return mmGetByPlaceID
  1206. }
  1207. // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
  1208. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetByPlaceID {
  1209. if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
  1210. mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
  1211. }
  1212. mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
  1213. return mmGetByPlaceID
  1214. }
  1215. // Return sets up results that will be returned by ThingRepository.GetByPlaceID
  1216. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1217. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1218. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1219. }
  1220. if mmGetByPlaceID.defaultExpectation == nil {
  1221. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
  1222. }
  1223. mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  1224. return mmGetByPlaceID.mock
  1225. }
  1226. // Set uses given function f to mock the ThingRepository.GetByPlaceID method
  1227. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  1228. if mmGetByPlaceID.defaultExpectation != nil {
  1229. mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
  1230. }
  1231. if len(mmGetByPlaceID.expectations) > 0 {
  1232. mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method")
  1233. }
  1234. mmGetByPlaceID.mock.funcGetByPlaceID = f
  1235. return mmGetByPlaceID.mock
  1236. }
  1237. // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
  1238. // Then helper
  1239. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetByPlaceIDExpectation {
  1240. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  1241. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  1242. }
  1243. expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
  1244. mock: mmGetByPlaceID.mock,
  1245. params: &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID},
  1246. }
  1247. mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
  1248. return expectation
  1249. }
  1250. // Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
  1251. func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1252. e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  1253. return e.mock
  1254. }
  1255. // GetByPlaceID implements interfaces.ThingRepository
  1256. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
  1257. mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
  1258. defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
  1259. if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
  1260. mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID)
  1261. }
  1262. mm_params := &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
  1263. // Record call args
  1264. mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
  1265. mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, mm_params)
  1266. mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
  1267. for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
  1268. if minimock.Equal(e.params, mm_params) {
  1269. mm_atomic.AddUint64(&e.Counter, 1)
  1270. return e.results.ta1, e.results.err
  1271. }
  1272. }
  1273. if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
  1274. mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
  1275. mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
  1276. mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
  1277. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1278. mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1279. }
  1280. mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
  1281. if mm_results == nil {
  1282. mmGetByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetByPlaceID")
  1283. }
  1284. return (*mm_results).ta1, (*mm_results).err
  1285. }
  1286. if mmGetByPlaceID.funcGetByPlaceID != nil {
  1287. return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID)
  1288. }
  1289. mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, placeID)
  1290. return
  1291. }
  1292. // GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations
  1293. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
  1294. return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
  1295. }
  1296. // GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations
  1297. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
  1298. return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
  1299. }
  1300. // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID.
  1301. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1302. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams {
  1303. mmGetByPlaceID.mutex.RLock()
  1304. argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
  1305. copy(argCopy, mmGetByPlaceID.callArgs)
  1306. mmGetByPlaceID.mutex.RUnlock()
  1307. return argCopy
  1308. }
  1309. // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
  1310. // the number of defined expectations
  1311. func (m *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool {
  1312. for _, e := range m.GetByPlaceIDMock.expectations {
  1313. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1314. return false
  1315. }
  1316. }
  1317. // if default expectation was set then invocations count should be greater than zero
  1318. if m.GetByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
  1319. return false
  1320. }
  1321. // if func was set then invocations count should be greater than zero
  1322. if m.funcGetByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
  1323. return false
  1324. }
  1325. return true
  1326. }
  1327. // MinimockGetByPlaceIDInspect logs each unmet expectation
  1328. func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() {
  1329. for _, e := range m.GetByPlaceIDMock.expectations {
  1330. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1331. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params)
  1332. }
  1333. }
  1334. // if default expectation was set then invocations count should be greater than zero
  1335. if m.GetByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
  1336. if m.GetByPlaceIDMock.defaultExpectation.params == nil {
  1337. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  1338. } else {
  1339. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
  1340. }
  1341. }
  1342. // if func was set then invocations count should be greater than zero
  1343. if m.funcGetByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
  1344. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  1345. }
  1346. }
  1347. type mThingRepositoryMockSearch struct {
  1348. mock *ThingRepositoryMock
  1349. defaultExpectation *ThingRepositoryMockSearchExpectation
  1350. expectations []*ThingRepositoryMockSearchExpectation
  1351. callArgs []*ThingRepositoryMockSearchParams
  1352. mutex sync.RWMutex
  1353. }
  1354. // ThingRepositoryMockSearchExpectation specifies expectation struct of the ThingRepository.Search
  1355. type ThingRepositoryMockSearchExpectation struct {
  1356. mock *ThingRepositoryMock
  1357. params *ThingRepositoryMockSearchParams
  1358. results *ThingRepositoryMockSearchResults
  1359. Counter uint64
  1360. }
  1361. // ThingRepositoryMockSearchParams contains parameters of the ThingRepository.Search
  1362. type ThingRepositoryMockSearchParams struct {
  1363. ctx context.Context
  1364. search string
  1365. }
  1366. // ThingRepositoryMockSearchResults contains results of the ThingRepository.Search
  1367. type ThingRepositoryMockSearchResults struct {
  1368. ta1 []models.Thing
  1369. err error
  1370. }
  1371. // Expect sets up expected params for ThingRepository.Search
  1372. func (mmSearch *mThingRepositoryMockSearch) Expect(ctx context.Context, search string) *mThingRepositoryMockSearch {
  1373. if mmSearch.mock.funcSearch != nil {
  1374. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1375. }
  1376. if mmSearch.defaultExpectation == nil {
  1377. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
  1378. }
  1379. mmSearch.defaultExpectation.params = &ThingRepositoryMockSearchParams{ctx, search}
  1380. for _, e := range mmSearch.expectations {
  1381. if minimock.Equal(e.params, mmSearch.defaultExpectation.params) {
  1382. mmSearch.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSearch.defaultExpectation.params)
  1383. }
  1384. }
  1385. return mmSearch
  1386. }
  1387. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Search
  1388. func (mmSearch *mThingRepositoryMockSearch) Inspect(f func(ctx context.Context, search string)) *mThingRepositoryMockSearch {
  1389. if mmSearch.mock.inspectFuncSearch != nil {
  1390. mmSearch.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Search")
  1391. }
  1392. mmSearch.mock.inspectFuncSearch = f
  1393. return mmSearch
  1394. }
  1395. // Return sets up results that will be returned by ThingRepository.Search
  1396. func (mmSearch *mThingRepositoryMockSearch) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1397. if mmSearch.mock.funcSearch != nil {
  1398. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1399. }
  1400. if mmSearch.defaultExpectation == nil {
  1401. mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{mock: mmSearch.mock}
  1402. }
  1403. mmSearch.defaultExpectation.results = &ThingRepositoryMockSearchResults{ta1, err}
  1404. return mmSearch.mock
  1405. }
  1406. // Set uses given function f to mock the ThingRepository.Search method
  1407. func (mmSearch *mThingRepositoryMockSearch) Set(f func(ctx context.Context, search string) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  1408. if mmSearch.defaultExpectation != nil {
  1409. mmSearch.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Search method")
  1410. }
  1411. if len(mmSearch.expectations) > 0 {
  1412. mmSearch.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Search method")
  1413. }
  1414. mmSearch.mock.funcSearch = f
  1415. return mmSearch.mock
  1416. }
  1417. // When sets expectation for the ThingRepository.Search which will trigger the result defined by the following
  1418. // Then helper
  1419. func (mmSearch *mThingRepositoryMockSearch) When(ctx context.Context, search string) *ThingRepositoryMockSearchExpectation {
  1420. if mmSearch.mock.funcSearch != nil {
  1421. mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
  1422. }
  1423. expectation := &ThingRepositoryMockSearchExpectation{
  1424. mock: mmSearch.mock,
  1425. params: &ThingRepositoryMockSearchParams{ctx, search},
  1426. }
  1427. mmSearch.expectations = append(mmSearch.expectations, expectation)
  1428. return expectation
  1429. }
  1430. // Then sets up ThingRepository.Search return parameters for the expectation previously defined by the When method
  1431. func (e *ThingRepositoryMockSearchExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  1432. e.results = &ThingRepositoryMockSearchResults{ta1, err}
  1433. return e.mock
  1434. }
  1435. // Search implements interfaces.ThingRepository
  1436. func (mmSearch *ThingRepositoryMock) Search(ctx context.Context, search string) (ta1 []models.Thing, err error) {
  1437. mm_atomic.AddUint64(&mmSearch.beforeSearchCounter, 1)
  1438. defer mm_atomic.AddUint64(&mmSearch.afterSearchCounter, 1)
  1439. if mmSearch.inspectFuncSearch != nil {
  1440. mmSearch.inspectFuncSearch(ctx, search)
  1441. }
  1442. mm_params := &ThingRepositoryMockSearchParams{ctx, search}
  1443. // Record call args
  1444. mmSearch.SearchMock.mutex.Lock()
  1445. mmSearch.SearchMock.callArgs = append(mmSearch.SearchMock.callArgs, mm_params)
  1446. mmSearch.SearchMock.mutex.Unlock()
  1447. for _, e := range mmSearch.SearchMock.expectations {
  1448. if minimock.Equal(e.params, mm_params) {
  1449. mm_atomic.AddUint64(&e.Counter, 1)
  1450. return e.results.ta1, e.results.err
  1451. }
  1452. }
  1453. if mmSearch.SearchMock.defaultExpectation != nil {
  1454. mm_atomic.AddUint64(&mmSearch.SearchMock.defaultExpectation.Counter, 1)
  1455. mm_want := mmSearch.SearchMock.defaultExpectation.params
  1456. mm_got := ThingRepositoryMockSearchParams{ctx, search}
  1457. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1458. mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1459. }
  1460. mm_results := mmSearch.SearchMock.defaultExpectation.results
  1461. if mm_results == nil {
  1462. mmSearch.t.Fatal("No results are set for the ThingRepositoryMock.Search")
  1463. }
  1464. return (*mm_results).ta1, (*mm_results).err
  1465. }
  1466. if mmSearch.funcSearch != nil {
  1467. return mmSearch.funcSearch(ctx, search)
  1468. }
  1469. mmSearch.t.Fatalf("Unexpected call to ThingRepositoryMock.Search. %v %v", ctx, search)
  1470. return
  1471. }
  1472. // SearchAfterCounter returns a count of finished ThingRepositoryMock.Search invocations
  1473. func (mmSearch *ThingRepositoryMock) SearchAfterCounter() uint64 {
  1474. return mm_atomic.LoadUint64(&mmSearch.afterSearchCounter)
  1475. }
  1476. // SearchBeforeCounter returns a count of ThingRepositoryMock.Search invocations
  1477. func (mmSearch *ThingRepositoryMock) SearchBeforeCounter() uint64 {
  1478. return mm_atomic.LoadUint64(&mmSearch.beforeSearchCounter)
  1479. }
  1480. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Search.
  1481. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1482. func (mmSearch *mThingRepositoryMockSearch) Calls() []*ThingRepositoryMockSearchParams {
  1483. mmSearch.mutex.RLock()
  1484. argCopy := make([]*ThingRepositoryMockSearchParams, len(mmSearch.callArgs))
  1485. copy(argCopy, mmSearch.callArgs)
  1486. mmSearch.mutex.RUnlock()
  1487. return argCopy
  1488. }
  1489. // MinimockSearchDone returns true if the count of the Search invocations corresponds
  1490. // the number of defined expectations
  1491. func (m *ThingRepositoryMock) MinimockSearchDone() bool {
  1492. for _, e := range m.SearchMock.expectations {
  1493. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1494. return false
  1495. }
  1496. }
  1497. // if default expectation was set then invocations count should be greater than zero
  1498. if m.SearchMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
  1499. return false
  1500. }
  1501. // if func was set then invocations count should be greater than zero
  1502. if m.funcSearch != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
  1503. return false
  1504. }
  1505. return true
  1506. }
  1507. // MinimockSearchInspect logs each unmet expectation
  1508. func (m *ThingRepositoryMock) MinimockSearchInspect() {
  1509. for _, e := range m.SearchMock.expectations {
  1510. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1511. m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *e.params)
  1512. }
  1513. }
  1514. // if default expectation was set then invocations count should be greater than zero
  1515. if m.SearchMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
  1516. if m.SearchMock.defaultExpectation.params == nil {
  1517. m.t.Error("Expected call to ThingRepositoryMock.Search")
  1518. } else {
  1519. m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *m.SearchMock.defaultExpectation.params)
  1520. }
  1521. }
  1522. // if func was set then invocations count should be greater than zero
  1523. if m.funcSearch != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
  1524. m.t.Error("Expected call to ThingRepositoryMock.Search")
  1525. }
  1526. }
  1527. type mThingRepositoryMockUpdate struct {
  1528. mock *ThingRepositoryMock
  1529. defaultExpectation *ThingRepositoryMockUpdateExpectation
  1530. expectations []*ThingRepositoryMockUpdateExpectation
  1531. callArgs []*ThingRepositoryMockUpdateParams
  1532. mutex sync.RWMutex
  1533. }
  1534. // ThingRepositoryMockUpdateExpectation specifies expectation struct of the ThingRepository.Update
  1535. type ThingRepositoryMockUpdateExpectation struct {
  1536. mock *ThingRepositoryMock
  1537. params *ThingRepositoryMockUpdateParams
  1538. results *ThingRepositoryMockUpdateResults
  1539. Counter uint64
  1540. }
  1541. // ThingRepositoryMockUpdateParams contains parameters of the ThingRepository.Update
  1542. type ThingRepositoryMockUpdateParams struct {
  1543. ctx context.Context
  1544. req models.UpdateThingRequest
  1545. tx *sql.Tx
  1546. }
  1547. // ThingRepositoryMockUpdateResults contains results of the ThingRepository.Update
  1548. type ThingRepositoryMockUpdateResults struct {
  1549. err error
  1550. }
  1551. // Expect sets up expected params for ThingRepository.Update
  1552. func (mmUpdate *mThingRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *mThingRepositoryMockUpdate {
  1553. if mmUpdate.mock.funcUpdate != nil {
  1554. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1555. }
  1556. if mmUpdate.defaultExpectation == nil {
  1557. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
  1558. }
  1559. mmUpdate.defaultExpectation.params = &ThingRepositoryMockUpdateParams{ctx, req, tx}
  1560. for _, e := range mmUpdate.expectations {
  1561. if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
  1562. mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
  1563. }
  1564. }
  1565. return mmUpdate
  1566. }
  1567. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Update
  1568. func (mmUpdate *mThingRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)) *mThingRepositoryMockUpdate {
  1569. if mmUpdate.mock.inspectFuncUpdate != nil {
  1570. mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Update")
  1571. }
  1572. mmUpdate.mock.inspectFuncUpdate = f
  1573. return mmUpdate
  1574. }
  1575. // Return sets up results that will be returned by ThingRepository.Update
  1576. func (mmUpdate *mThingRepositoryMockUpdate) Return(err error) *ThingRepositoryMock {
  1577. if mmUpdate.mock.funcUpdate != nil {
  1578. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1579. }
  1580. if mmUpdate.defaultExpectation == nil {
  1581. mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
  1582. }
  1583. mmUpdate.defaultExpectation.results = &ThingRepositoryMockUpdateResults{err}
  1584. return mmUpdate.mock
  1585. }
  1586. // Set uses given function f to mock the ThingRepository.Update method
  1587. func (mmUpdate *mThingRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)) *ThingRepositoryMock {
  1588. if mmUpdate.defaultExpectation != nil {
  1589. mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Update method")
  1590. }
  1591. if len(mmUpdate.expectations) > 0 {
  1592. mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Update method")
  1593. }
  1594. mmUpdate.mock.funcUpdate = f
  1595. return mmUpdate.mock
  1596. }
  1597. // When sets expectation for the ThingRepository.Update which will trigger the result defined by the following
  1598. // Then helper
  1599. func (mmUpdate *mThingRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *ThingRepositoryMockUpdateExpectation {
  1600. if mmUpdate.mock.funcUpdate != nil {
  1601. mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
  1602. }
  1603. expectation := &ThingRepositoryMockUpdateExpectation{
  1604. mock: mmUpdate.mock,
  1605. params: &ThingRepositoryMockUpdateParams{ctx, req, tx},
  1606. }
  1607. mmUpdate.expectations = append(mmUpdate.expectations, expectation)
  1608. return expectation
  1609. }
  1610. // Then sets up ThingRepository.Update return parameters for the expectation previously defined by the When method
  1611. func (e *ThingRepositoryMockUpdateExpectation) Then(err error) *ThingRepositoryMock {
  1612. e.results = &ThingRepositoryMockUpdateResults{err}
  1613. return e.mock
  1614. }
  1615. // Update implements interfaces.ThingRepository
  1616. func (mmUpdate *ThingRepositoryMock) Update(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error) {
  1617. mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
  1618. defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
  1619. if mmUpdate.inspectFuncUpdate != nil {
  1620. mmUpdate.inspectFuncUpdate(ctx, req, tx)
  1621. }
  1622. mm_params := &ThingRepositoryMockUpdateParams{ctx, req, tx}
  1623. // Record call args
  1624. mmUpdate.UpdateMock.mutex.Lock()
  1625. mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, mm_params)
  1626. mmUpdate.UpdateMock.mutex.Unlock()
  1627. for _, e := range mmUpdate.UpdateMock.expectations {
  1628. if minimock.Equal(e.params, mm_params) {
  1629. mm_atomic.AddUint64(&e.Counter, 1)
  1630. return e.results.err
  1631. }
  1632. }
  1633. if mmUpdate.UpdateMock.defaultExpectation != nil {
  1634. mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
  1635. mm_want := mmUpdate.UpdateMock.defaultExpectation.params
  1636. mm_got := ThingRepositoryMockUpdateParams{ctx, req, tx}
  1637. if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1638. mmUpdate.t.Errorf("ThingRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1639. }
  1640. mm_results := mmUpdate.UpdateMock.defaultExpectation.results
  1641. if mm_results == nil {
  1642. mmUpdate.t.Fatal("No results are set for the ThingRepositoryMock.Update")
  1643. }
  1644. return (*mm_results).err
  1645. }
  1646. if mmUpdate.funcUpdate != nil {
  1647. return mmUpdate.funcUpdate(ctx, req, tx)
  1648. }
  1649. mmUpdate.t.Fatalf("Unexpected call to ThingRepositoryMock.Update. %v %v %v", ctx, req, tx)
  1650. return
  1651. }
  1652. // UpdateAfterCounter returns a count of finished ThingRepositoryMock.Update invocations
  1653. func (mmUpdate *ThingRepositoryMock) UpdateAfterCounter() uint64 {
  1654. return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
  1655. }
  1656. // UpdateBeforeCounter returns a count of ThingRepositoryMock.Update invocations
  1657. func (mmUpdate *ThingRepositoryMock) UpdateBeforeCounter() uint64 {
  1658. return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
  1659. }
  1660. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Update.
  1661. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1662. func (mmUpdate *mThingRepositoryMockUpdate) Calls() []*ThingRepositoryMockUpdateParams {
  1663. mmUpdate.mutex.RLock()
  1664. argCopy := make([]*ThingRepositoryMockUpdateParams, len(mmUpdate.callArgs))
  1665. copy(argCopy, mmUpdate.callArgs)
  1666. mmUpdate.mutex.RUnlock()
  1667. return argCopy
  1668. }
  1669. // MinimockUpdateDone returns true if the count of the Update invocations corresponds
  1670. // the number of defined expectations
  1671. func (m *ThingRepositoryMock) MinimockUpdateDone() bool {
  1672. for _, e := range m.UpdateMock.expectations {
  1673. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1674. return false
  1675. }
  1676. }
  1677. // if default expectation was set then invocations count should be greater than zero
  1678. if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  1679. return false
  1680. }
  1681. // if func was set then invocations count should be greater than zero
  1682. if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  1683. return false
  1684. }
  1685. return true
  1686. }
  1687. // MinimockUpdateInspect logs each unmet expectation
  1688. func (m *ThingRepositoryMock) MinimockUpdateInspect() {
  1689. for _, e := range m.UpdateMock.expectations {
  1690. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1691. m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *e.params)
  1692. }
  1693. }
  1694. // if default expectation was set then invocations count should be greater than zero
  1695. if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  1696. if m.UpdateMock.defaultExpectation.params == nil {
  1697. m.t.Error("Expected call to ThingRepositoryMock.Update")
  1698. } else {
  1699. m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
  1700. }
  1701. }
  1702. // if func was set then invocations count should be greater than zero
  1703. if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
  1704. m.t.Error("Expected call to ThingRepositoryMock.Update")
  1705. }
  1706. }
  1707. // MinimockFinish checks that all mocked methods have been called the expected number of times
  1708. func (m *ThingRepositoryMock) MinimockFinish() {
  1709. if !m.minimockDone() {
  1710. m.MinimockAddInspect()
  1711. m.MinimockBeginTxInspect()
  1712. m.MinimockCommitTxInspect()
  1713. m.MinimockDeleteInspect()
  1714. m.MinimockGetInspect()
  1715. m.MinimockGetAllByPlaceIDInspect()
  1716. m.MinimockGetByPlaceIDInspect()
  1717. m.MinimockSearchInspect()
  1718. m.MinimockUpdateInspect()
  1719. m.t.FailNow()
  1720. }
  1721. }
  1722. // MinimockWait waits for all mocked methods to be called the expected number of times
  1723. func (m *ThingRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  1724. timeoutCh := mm_time.After(timeout)
  1725. for {
  1726. if m.minimockDone() {
  1727. return
  1728. }
  1729. select {
  1730. case <-timeoutCh:
  1731. m.MinimockFinish()
  1732. return
  1733. case <-mm_time.After(10 * mm_time.Millisecond):
  1734. }
  1735. }
  1736. }
  1737. func (m *ThingRepositoryMock) minimockDone() bool {
  1738. done := true
  1739. return done &&
  1740. m.MinimockAddDone() &&
  1741. m.MinimockBeginTxDone() &&
  1742. m.MinimockCommitTxDone() &&
  1743. m.MinimockDeleteDone() &&
  1744. m.MinimockGetDone() &&
  1745. m.MinimockGetAllByPlaceIDDone() &&
  1746. m.MinimockGetByPlaceIDDone() &&
  1747. m.MinimockSearchDone() &&
  1748. m.MinimockUpdateDone()
  1749. }