place_thing_repository_minimock.go 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  1. // Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
  2. package mocks
  3. //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/thing.PlaceThingRepository -o place_thing_repository_minimock.go -n PlaceThingRepositoryMock -p mocks
  4. import (
  5. "context"
  6. "database/sql"
  7. "sync"
  8. mm_atomic "sync/atomic"
  9. mm_time "time"
  10. "git.dmitriygnatenko.ru/dima/homethings/internal/models"
  11. "github.com/gojuno/minimock/v3"
  12. )
  13. // PlaceThingRepositoryMock implements thing.PlaceThingRepository
  14. type PlaceThingRepositoryMock struct {
  15. t minimock.Tester
  16. finishOnce sync.Once
  17. funcAdd func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error)
  18. inspectFuncAdd func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx)
  19. afterAddCounter uint64
  20. beforeAddCounter uint64
  21. AddMock mPlaceThingRepositoryMockAdd
  22. funcDeleteThing func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
  23. inspectFuncDeleteThing func(ctx context.Context, thingID int, tx *sql.Tx)
  24. afterDeleteThingCounter uint64
  25. beforeDeleteThingCounter uint64
  26. DeleteThingMock mPlaceThingRepositoryMockDeleteThing
  27. funcGetByThingID func(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error)
  28. inspectFuncGetByThingID func(ctx context.Context, thingID int)
  29. afterGetByThingIDCounter uint64
  30. beforeGetByThingIDCounter uint64
  31. GetByThingIDMock mPlaceThingRepositoryMockGetByThingID
  32. funcUpdatePlace func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error)
  33. inspectFuncUpdatePlace func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx)
  34. afterUpdatePlaceCounter uint64
  35. beforeUpdatePlaceCounter uint64
  36. UpdatePlaceMock mPlaceThingRepositoryMockUpdatePlace
  37. }
  38. // NewPlaceThingRepositoryMock returns a mock for thing.PlaceThingRepository
  39. func NewPlaceThingRepositoryMock(t minimock.Tester) *PlaceThingRepositoryMock {
  40. m := &PlaceThingRepositoryMock{t: t}
  41. if controller, ok := t.(minimock.MockController); ok {
  42. controller.RegisterMocker(m)
  43. }
  44. m.AddMock = mPlaceThingRepositoryMockAdd{mock: m}
  45. m.AddMock.callArgs = []*PlaceThingRepositoryMockAddParams{}
  46. m.DeleteThingMock = mPlaceThingRepositoryMockDeleteThing{mock: m}
  47. m.DeleteThingMock.callArgs = []*PlaceThingRepositoryMockDeleteThingParams{}
  48. m.GetByThingIDMock = mPlaceThingRepositoryMockGetByThingID{mock: m}
  49. m.GetByThingIDMock.callArgs = []*PlaceThingRepositoryMockGetByThingIDParams{}
  50. m.UpdatePlaceMock = mPlaceThingRepositoryMockUpdatePlace{mock: m}
  51. m.UpdatePlaceMock.callArgs = []*PlaceThingRepositoryMockUpdatePlaceParams{}
  52. t.Cleanup(m.MinimockFinish)
  53. return m
  54. }
  55. type mPlaceThingRepositoryMockAdd struct {
  56. optional bool
  57. mock *PlaceThingRepositoryMock
  58. defaultExpectation *PlaceThingRepositoryMockAddExpectation
  59. expectations []*PlaceThingRepositoryMockAddExpectation
  60. callArgs []*PlaceThingRepositoryMockAddParams
  61. mutex sync.RWMutex
  62. expectedInvocations uint64
  63. }
  64. // PlaceThingRepositoryMockAddExpectation specifies expectation struct of the PlaceThingRepository.Add
  65. type PlaceThingRepositoryMockAddExpectation struct {
  66. mock *PlaceThingRepositoryMock
  67. params *PlaceThingRepositoryMockAddParams
  68. paramPtrs *PlaceThingRepositoryMockAddParamPtrs
  69. results *PlaceThingRepositoryMockAddResults
  70. Counter uint64
  71. }
  72. // PlaceThingRepositoryMockAddParams contains parameters of the PlaceThingRepository.Add
  73. type PlaceThingRepositoryMockAddParams struct {
  74. ctx context.Context
  75. req models.AddPlaceThingRequest
  76. tx *sql.Tx
  77. }
  78. // PlaceThingRepositoryMockAddParamPtrs contains pointers to parameters of the PlaceThingRepository.Add
  79. type PlaceThingRepositoryMockAddParamPtrs struct {
  80. ctx *context.Context
  81. req *models.AddPlaceThingRequest
  82. tx **sql.Tx
  83. }
  84. // PlaceThingRepositoryMockAddResults contains results of the PlaceThingRepository.Add
  85. type PlaceThingRepositoryMockAddResults struct {
  86. err error
  87. }
  88. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  89. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  90. // Optional() makes method check to work in '0 or more' mode.
  91. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  92. // catch the problems when the expected method call is totally skipped during test run.
  93. func (mmAdd *mPlaceThingRepositoryMockAdd) Optional() *mPlaceThingRepositoryMockAdd {
  94. mmAdd.optional = true
  95. return mmAdd
  96. }
  97. // Expect sets up expected params for PlaceThingRepository.Add
  98. func (mmAdd *mPlaceThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) *mPlaceThingRepositoryMockAdd {
  99. if mmAdd.mock.funcAdd != nil {
  100. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
  101. }
  102. if mmAdd.defaultExpectation == nil {
  103. mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
  104. }
  105. if mmAdd.defaultExpectation.paramPtrs != nil {
  106. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by ExpectParams functions")
  107. }
  108. mmAdd.defaultExpectation.params = &PlaceThingRepositoryMockAddParams{ctx, req, tx}
  109. for _, e := range mmAdd.expectations {
  110. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  111. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  112. }
  113. }
  114. return mmAdd
  115. }
  116. // ExpectCtxParam1 sets up expected param ctx for PlaceThingRepository.Add
  117. func (mmAdd *mPlaceThingRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockAdd {
  118. if mmAdd.mock.funcAdd != nil {
  119. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
  120. }
  121. if mmAdd.defaultExpectation == nil {
  122. mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
  123. }
  124. if mmAdd.defaultExpectation.params != nil {
  125. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Expect")
  126. }
  127. if mmAdd.defaultExpectation.paramPtrs == nil {
  128. mmAdd.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockAddParamPtrs{}
  129. }
  130. mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
  131. return mmAdd
  132. }
  133. // ExpectReqParam2 sets up expected param req for PlaceThingRepository.Add
  134. func (mmAdd *mPlaceThingRepositoryMockAdd) ExpectReqParam2(req models.AddPlaceThingRequest) *mPlaceThingRepositoryMockAdd {
  135. if mmAdd.mock.funcAdd != nil {
  136. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
  137. }
  138. if mmAdd.defaultExpectation == nil {
  139. mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
  140. }
  141. if mmAdd.defaultExpectation.params != nil {
  142. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Expect")
  143. }
  144. if mmAdd.defaultExpectation.paramPtrs == nil {
  145. mmAdd.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockAddParamPtrs{}
  146. }
  147. mmAdd.defaultExpectation.paramPtrs.req = &req
  148. return mmAdd
  149. }
  150. // ExpectTxParam3 sets up expected param tx for PlaceThingRepository.Add
  151. func (mmAdd *mPlaceThingRepositoryMockAdd) ExpectTxParam3(tx *sql.Tx) *mPlaceThingRepositoryMockAdd {
  152. if mmAdd.mock.funcAdd != nil {
  153. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
  154. }
  155. if mmAdd.defaultExpectation == nil {
  156. mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
  157. }
  158. if mmAdd.defaultExpectation.params != nil {
  159. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Expect")
  160. }
  161. if mmAdd.defaultExpectation.paramPtrs == nil {
  162. mmAdd.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockAddParamPtrs{}
  163. }
  164. mmAdd.defaultExpectation.paramPtrs.tx = &tx
  165. return mmAdd
  166. }
  167. // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.Add
  168. func (mmAdd *mPlaceThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx)) *mPlaceThingRepositoryMockAdd {
  169. if mmAdd.mock.inspectFuncAdd != nil {
  170. mmAdd.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.Add")
  171. }
  172. mmAdd.mock.inspectFuncAdd = f
  173. return mmAdd
  174. }
  175. // Return sets up results that will be returned by PlaceThingRepository.Add
  176. func (mmAdd *mPlaceThingRepositoryMockAdd) Return(err error) *PlaceThingRepositoryMock {
  177. if mmAdd.mock.funcAdd != nil {
  178. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
  179. }
  180. if mmAdd.defaultExpectation == nil {
  181. mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{mock: mmAdd.mock}
  182. }
  183. mmAdd.defaultExpectation.results = &PlaceThingRepositoryMockAddResults{err}
  184. return mmAdd.mock
  185. }
  186. // Set uses given function f to mock the PlaceThingRepository.Add method
  187. func (mmAdd *mPlaceThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
  188. if mmAdd.defaultExpectation != nil {
  189. mmAdd.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.Add method")
  190. }
  191. if len(mmAdd.expectations) > 0 {
  192. mmAdd.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.Add method")
  193. }
  194. mmAdd.mock.funcAdd = f
  195. return mmAdd.mock
  196. }
  197. // When sets expectation for the PlaceThingRepository.Add which will trigger the result defined by the following
  198. // Then helper
  199. func (mmAdd *mPlaceThingRepositoryMockAdd) When(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) *PlaceThingRepositoryMockAddExpectation {
  200. if mmAdd.mock.funcAdd != nil {
  201. mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
  202. }
  203. expectation := &PlaceThingRepositoryMockAddExpectation{
  204. mock: mmAdd.mock,
  205. params: &PlaceThingRepositoryMockAddParams{ctx, req, tx},
  206. }
  207. mmAdd.expectations = append(mmAdd.expectations, expectation)
  208. return expectation
  209. }
  210. // Then sets up PlaceThingRepository.Add return parameters for the expectation previously defined by the When method
  211. func (e *PlaceThingRepositoryMockAddExpectation) Then(err error) *PlaceThingRepositoryMock {
  212. e.results = &PlaceThingRepositoryMockAddResults{err}
  213. return e.mock
  214. }
  215. // Times sets number of times PlaceThingRepository.Add should be invoked
  216. func (mmAdd *mPlaceThingRepositoryMockAdd) Times(n uint64) *mPlaceThingRepositoryMockAdd {
  217. if n == 0 {
  218. mmAdd.mock.t.Fatalf("Times of PlaceThingRepositoryMock.Add mock can not be zero")
  219. }
  220. mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
  221. return mmAdd
  222. }
  223. func (mmAdd *mPlaceThingRepositoryMockAdd) invocationsDone() bool {
  224. if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
  225. return true
  226. }
  227. totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
  228. expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
  229. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  230. }
  231. // Add implements thing.PlaceThingRepository
  232. func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error) {
  233. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  234. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  235. if mmAdd.inspectFuncAdd != nil {
  236. mmAdd.inspectFuncAdd(ctx, req, tx)
  237. }
  238. mm_params := PlaceThingRepositoryMockAddParams{ctx, req, tx}
  239. // Record call args
  240. mmAdd.AddMock.mutex.Lock()
  241. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
  242. mmAdd.AddMock.mutex.Unlock()
  243. for _, e := range mmAdd.AddMock.expectations {
  244. if minimock.Equal(*e.params, mm_params) {
  245. mm_atomic.AddUint64(&e.Counter, 1)
  246. return e.results.err
  247. }
  248. }
  249. if mmAdd.AddMock.defaultExpectation != nil {
  250. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  251. mm_want := mmAdd.AddMock.defaultExpectation.params
  252. mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
  253. mm_got := PlaceThingRepositoryMockAddParams{ctx, req, tx}
  254. if mm_want_ptrs != nil {
  255. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  256. mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  257. }
  258. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  259. mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
  260. }
  261. if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
  262. mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
  263. }
  264. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  265. mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  266. }
  267. mm_results := mmAdd.AddMock.defaultExpectation.results
  268. if mm_results == nil {
  269. mmAdd.t.Fatal("No results are set for the PlaceThingRepositoryMock.Add")
  270. }
  271. return (*mm_results).err
  272. }
  273. if mmAdd.funcAdd != nil {
  274. return mmAdd.funcAdd(ctx, req, tx)
  275. }
  276. mmAdd.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.Add. %v %v %v", ctx, req, tx)
  277. return
  278. }
  279. // AddAfterCounter returns a count of finished PlaceThingRepositoryMock.Add invocations
  280. func (mmAdd *PlaceThingRepositoryMock) AddAfterCounter() uint64 {
  281. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  282. }
  283. // AddBeforeCounter returns a count of PlaceThingRepositoryMock.Add invocations
  284. func (mmAdd *PlaceThingRepositoryMock) AddBeforeCounter() uint64 {
  285. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  286. }
  287. // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.Add.
  288. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  289. func (mmAdd *mPlaceThingRepositoryMockAdd) Calls() []*PlaceThingRepositoryMockAddParams {
  290. mmAdd.mutex.RLock()
  291. argCopy := make([]*PlaceThingRepositoryMockAddParams, len(mmAdd.callArgs))
  292. copy(argCopy, mmAdd.callArgs)
  293. mmAdd.mutex.RUnlock()
  294. return argCopy
  295. }
  296. // MinimockAddDone returns true if the count of the Add invocations corresponds
  297. // the number of defined expectations
  298. func (m *PlaceThingRepositoryMock) MinimockAddDone() bool {
  299. if m.AddMock.optional {
  300. // Optional methods provide '0 or more' call count restriction.
  301. return true
  302. }
  303. for _, e := range m.AddMock.expectations {
  304. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  305. return false
  306. }
  307. }
  308. return m.AddMock.invocationsDone()
  309. }
  310. // MinimockAddInspect logs each unmet expectation
  311. func (m *PlaceThingRepositoryMock) MinimockAddInspect() {
  312. for _, e := range m.AddMock.expectations {
  313. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  314. m.t.Errorf("Expected call to PlaceThingRepositoryMock.Add with params: %#v", *e.params)
  315. }
  316. }
  317. afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
  318. // if default expectation was set then invocations count should be greater than zero
  319. if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
  320. if m.AddMock.defaultExpectation.params == nil {
  321. m.t.Error("Expected call to PlaceThingRepositoryMock.Add")
  322. } else {
  323. m.t.Errorf("Expected call to PlaceThingRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  324. }
  325. }
  326. // if func was set then invocations count should be greater than zero
  327. if m.funcAdd != nil && afterAddCounter < 1 {
  328. m.t.Error("Expected call to PlaceThingRepositoryMock.Add")
  329. }
  330. if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
  331. m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.Add but found %d calls",
  332. mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
  333. }
  334. }
  335. type mPlaceThingRepositoryMockDeleteThing struct {
  336. optional bool
  337. mock *PlaceThingRepositoryMock
  338. defaultExpectation *PlaceThingRepositoryMockDeleteThingExpectation
  339. expectations []*PlaceThingRepositoryMockDeleteThingExpectation
  340. callArgs []*PlaceThingRepositoryMockDeleteThingParams
  341. mutex sync.RWMutex
  342. expectedInvocations uint64
  343. }
  344. // PlaceThingRepositoryMockDeleteThingExpectation specifies expectation struct of the PlaceThingRepository.DeleteThing
  345. type PlaceThingRepositoryMockDeleteThingExpectation struct {
  346. mock *PlaceThingRepositoryMock
  347. params *PlaceThingRepositoryMockDeleteThingParams
  348. paramPtrs *PlaceThingRepositoryMockDeleteThingParamPtrs
  349. results *PlaceThingRepositoryMockDeleteThingResults
  350. Counter uint64
  351. }
  352. // PlaceThingRepositoryMockDeleteThingParams contains parameters of the PlaceThingRepository.DeleteThing
  353. type PlaceThingRepositoryMockDeleteThingParams struct {
  354. ctx context.Context
  355. thingID int
  356. tx *sql.Tx
  357. }
  358. // PlaceThingRepositoryMockDeleteThingParamPtrs contains pointers to parameters of the PlaceThingRepository.DeleteThing
  359. type PlaceThingRepositoryMockDeleteThingParamPtrs struct {
  360. ctx *context.Context
  361. thingID *int
  362. tx **sql.Tx
  363. }
  364. // PlaceThingRepositoryMockDeleteThingResults contains results of the PlaceThingRepository.DeleteThing
  365. type PlaceThingRepositoryMockDeleteThingResults struct {
  366. err error
  367. }
  368. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  369. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  370. // Optional() makes method check to work in '0 or more' mode.
  371. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  372. // catch the problems when the expected method call is totally skipped during test run.
  373. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Optional() *mPlaceThingRepositoryMockDeleteThing {
  374. mmDeleteThing.optional = true
  375. return mmDeleteThing
  376. }
  377. // Expect sets up expected params for PlaceThingRepository.DeleteThing
  378. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mPlaceThingRepositoryMockDeleteThing {
  379. if mmDeleteThing.mock.funcDeleteThing != nil {
  380. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
  381. }
  382. if mmDeleteThing.defaultExpectation == nil {
  383. mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
  384. }
  385. if mmDeleteThing.defaultExpectation.paramPtrs != nil {
  386. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by ExpectParams functions")
  387. }
  388. mmDeleteThing.defaultExpectation.params = &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
  389. for _, e := range mmDeleteThing.expectations {
  390. if minimock.Equal(e.params, mmDeleteThing.defaultExpectation.params) {
  391. mmDeleteThing.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteThing.defaultExpectation.params)
  392. }
  393. }
  394. return mmDeleteThing
  395. }
  396. // ExpectCtxParam1 sets up expected param ctx for PlaceThingRepository.DeleteThing
  397. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockDeleteThing {
  398. if mmDeleteThing.mock.funcDeleteThing != nil {
  399. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
  400. }
  401. if mmDeleteThing.defaultExpectation == nil {
  402. mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
  403. }
  404. if mmDeleteThing.defaultExpectation.params != nil {
  405. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Expect")
  406. }
  407. if mmDeleteThing.defaultExpectation.paramPtrs == nil {
  408. mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
  409. }
  410. mmDeleteThing.defaultExpectation.paramPtrs.ctx = &ctx
  411. return mmDeleteThing
  412. }
  413. // ExpectThingIDParam2 sets up expected param thingID for PlaceThingRepository.DeleteThing
  414. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectThingIDParam2(thingID int) *mPlaceThingRepositoryMockDeleteThing {
  415. if mmDeleteThing.mock.funcDeleteThing != nil {
  416. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
  417. }
  418. if mmDeleteThing.defaultExpectation == nil {
  419. mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
  420. }
  421. if mmDeleteThing.defaultExpectation.params != nil {
  422. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Expect")
  423. }
  424. if mmDeleteThing.defaultExpectation.paramPtrs == nil {
  425. mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
  426. }
  427. mmDeleteThing.defaultExpectation.paramPtrs.thingID = &thingID
  428. return mmDeleteThing
  429. }
  430. // ExpectTxParam3 sets up expected param tx for PlaceThingRepository.DeleteThing
  431. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectTxParam3(tx *sql.Tx) *mPlaceThingRepositoryMockDeleteThing {
  432. if mmDeleteThing.mock.funcDeleteThing != nil {
  433. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
  434. }
  435. if mmDeleteThing.defaultExpectation == nil {
  436. mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
  437. }
  438. if mmDeleteThing.defaultExpectation.params != nil {
  439. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Expect")
  440. }
  441. if mmDeleteThing.defaultExpectation.paramPtrs == nil {
  442. mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
  443. }
  444. mmDeleteThing.defaultExpectation.paramPtrs.tx = &tx
  445. return mmDeleteThing
  446. }
  447. // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.DeleteThing
  448. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mPlaceThingRepositoryMockDeleteThing {
  449. if mmDeleteThing.mock.inspectFuncDeleteThing != nil {
  450. mmDeleteThing.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.DeleteThing")
  451. }
  452. mmDeleteThing.mock.inspectFuncDeleteThing = f
  453. return mmDeleteThing
  454. }
  455. // Return sets up results that will be returned by PlaceThingRepository.DeleteThing
  456. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Return(err error) *PlaceThingRepositoryMock {
  457. if mmDeleteThing.mock.funcDeleteThing != nil {
  458. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
  459. }
  460. if mmDeleteThing.defaultExpectation == nil {
  461. mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{mock: mmDeleteThing.mock}
  462. }
  463. mmDeleteThing.defaultExpectation.results = &PlaceThingRepositoryMockDeleteThingResults{err}
  464. return mmDeleteThing.mock
  465. }
  466. // Set uses given function f to mock the PlaceThingRepository.DeleteThing method
  467. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
  468. if mmDeleteThing.defaultExpectation != nil {
  469. mmDeleteThing.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.DeleteThing method")
  470. }
  471. if len(mmDeleteThing.expectations) > 0 {
  472. mmDeleteThing.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.DeleteThing method")
  473. }
  474. mmDeleteThing.mock.funcDeleteThing = f
  475. return mmDeleteThing.mock
  476. }
  477. // When sets expectation for the PlaceThingRepository.DeleteThing which will trigger the result defined by the following
  478. // Then helper
  479. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) When(ctx context.Context, thingID int, tx *sql.Tx) *PlaceThingRepositoryMockDeleteThingExpectation {
  480. if mmDeleteThing.mock.funcDeleteThing != nil {
  481. mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
  482. }
  483. expectation := &PlaceThingRepositoryMockDeleteThingExpectation{
  484. mock: mmDeleteThing.mock,
  485. params: &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx},
  486. }
  487. mmDeleteThing.expectations = append(mmDeleteThing.expectations, expectation)
  488. return expectation
  489. }
  490. // Then sets up PlaceThingRepository.DeleteThing return parameters for the expectation previously defined by the When method
  491. func (e *PlaceThingRepositoryMockDeleteThingExpectation) Then(err error) *PlaceThingRepositoryMock {
  492. e.results = &PlaceThingRepositoryMockDeleteThingResults{err}
  493. return e.mock
  494. }
  495. // Times sets number of times PlaceThingRepository.DeleteThing should be invoked
  496. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Times(n uint64) *mPlaceThingRepositoryMockDeleteThing {
  497. if n == 0 {
  498. mmDeleteThing.mock.t.Fatalf("Times of PlaceThingRepositoryMock.DeleteThing mock can not be zero")
  499. }
  500. mm_atomic.StoreUint64(&mmDeleteThing.expectedInvocations, n)
  501. return mmDeleteThing
  502. }
  503. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) invocationsDone() bool {
  504. if len(mmDeleteThing.expectations) == 0 && mmDeleteThing.defaultExpectation == nil && mmDeleteThing.mock.funcDeleteThing == nil {
  505. return true
  506. }
  507. totalInvocations := mm_atomic.LoadUint64(&mmDeleteThing.mock.afterDeleteThingCounter)
  508. expectedInvocations := mm_atomic.LoadUint64(&mmDeleteThing.expectedInvocations)
  509. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  510. }
  511. // DeleteThing implements thing.PlaceThingRepository
  512. func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
  513. mm_atomic.AddUint64(&mmDeleteThing.beforeDeleteThingCounter, 1)
  514. defer mm_atomic.AddUint64(&mmDeleteThing.afterDeleteThingCounter, 1)
  515. if mmDeleteThing.inspectFuncDeleteThing != nil {
  516. mmDeleteThing.inspectFuncDeleteThing(ctx, thingID, tx)
  517. }
  518. mm_params := PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
  519. // Record call args
  520. mmDeleteThing.DeleteThingMock.mutex.Lock()
  521. mmDeleteThing.DeleteThingMock.callArgs = append(mmDeleteThing.DeleteThingMock.callArgs, &mm_params)
  522. mmDeleteThing.DeleteThingMock.mutex.Unlock()
  523. for _, e := range mmDeleteThing.DeleteThingMock.expectations {
  524. if minimock.Equal(*e.params, mm_params) {
  525. mm_atomic.AddUint64(&e.Counter, 1)
  526. return e.results.err
  527. }
  528. }
  529. if mmDeleteThing.DeleteThingMock.defaultExpectation != nil {
  530. mm_atomic.AddUint64(&mmDeleteThing.DeleteThingMock.defaultExpectation.Counter, 1)
  531. mm_want := mmDeleteThing.DeleteThingMock.defaultExpectation.params
  532. mm_want_ptrs := mmDeleteThing.DeleteThingMock.defaultExpectation.paramPtrs
  533. mm_got := PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
  534. if mm_want_ptrs != nil {
  535. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  536. mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  537. }
  538. if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
  539. mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
  540. }
  541. if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
  542. mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
  543. }
  544. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  545. mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  546. }
  547. mm_results := mmDeleteThing.DeleteThingMock.defaultExpectation.results
  548. if mm_results == nil {
  549. mmDeleteThing.t.Fatal("No results are set for the PlaceThingRepositoryMock.DeleteThing")
  550. }
  551. return (*mm_results).err
  552. }
  553. if mmDeleteThing.funcDeleteThing != nil {
  554. return mmDeleteThing.funcDeleteThing(ctx, thingID, tx)
  555. }
  556. mmDeleteThing.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.DeleteThing. %v %v %v", ctx, thingID, tx)
  557. return
  558. }
  559. // DeleteThingAfterCounter returns a count of finished PlaceThingRepositoryMock.DeleteThing invocations
  560. func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThingAfterCounter() uint64 {
  561. return mm_atomic.LoadUint64(&mmDeleteThing.afterDeleteThingCounter)
  562. }
  563. // DeleteThingBeforeCounter returns a count of PlaceThingRepositoryMock.DeleteThing invocations
  564. func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThingBeforeCounter() uint64 {
  565. return mm_atomic.LoadUint64(&mmDeleteThing.beforeDeleteThingCounter)
  566. }
  567. // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.DeleteThing.
  568. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  569. func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Calls() []*PlaceThingRepositoryMockDeleteThingParams {
  570. mmDeleteThing.mutex.RLock()
  571. argCopy := make([]*PlaceThingRepositoryMockDeleteThingParams, len(mmDeleteThing.callArgs))
  572. copy(argCopy, mmDeleteThing.callArgs)
  573. mmDeleteThing.mutex.RUnlock()
  574. return argCopy
  575. }
  576. // MinimockDeleteThingDone returns true if the count of the DeleteThing invocations corresponds
  577. // the number of defined expectations
  578. func (m *PlaceThingRepositoryMock) MinimockDeleteThingDone() bool {
  579. if m.DeleteThingMock.optional {
  580. // Optional methods provide '0 or more' call count restriction.
  581. return true
  582. }
  583. for _, e := range m.DeleteThingMock.expectations {
  584. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  585. return false
  586. }
  587. }
  588. return m.DeleteThingMock.invocationsDone()
  589. }
  590. // MinimockDeleteThingInspect logs each unmet expectation
  591. func (m *PlaceThingRepositoryMock) MinimockDeleteThingInspect() {
  592. for _, e := range m.DeleteThingMock.expectations {
  593. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  594. m.t.Errorf("Expected call to PlaceThingRepositoryMock.DeleteThing with params: %#v", *e.params)
  595. }
  596. }
  597. afterDeleteThingCounter := mm_atomic.LoadUint64(&m.afterDeleteThingCounter)
  598. // if default expectation was set then invocations count should be greater than zero
  599. if m.DeleteThingMock.defaultExpectation != nil && afterDeleteThingCounter < 1 {
  600. if m.DeleteThingMock.defaultExpectation.params == nil {
  601. m.t.Error("Expected call to PlaceThingRepositoryMock.DeleteThing")
  602. } else {
  603. m.t.Errorf("Expected call to PlaceThingRepositoryMock.DeleteThing with params: %#v", *m.DeleteThingMock.defaultExpectation.params)
  604. }
  605. }
  606. // if func was set then invocations count should be greater than zero
  607. if m.funcDeleteThing != nil && afterDeleteThingCounter < 1 {
  608. m.t.Error("Expected call to PlaceThingRepositoryMock.DeleteThing")
  609. }
  610. if !m.DeleteThingMock.invocationsDone() && afterDeleteThingCounter > 0 {
  611. m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.DeleteThing but found %d calls",
  612. mm_atomic.LoadUint64(&m.DeleteThingMock.expectedInvocations), afterDeleteThingCounter)
  613. }
  614. }
  615. type mPlaceThingRepositoryMockGetByThingID struct {
  616. optional bool
  617. mock *PlaceThingRepositoryMock
  618. defaultExpectation *PlaceThingRepositoryMockGetByThingIDExpectation
  619. expectations []*PlaceThingRepositoryMockGetByThingIDExpectation
  620. callArgs []*PlaceThingRepositoryMockGetByThingIDParams
  621. mutex sync.RWMutex
  622. expectedInvocations uint64
  623. }
  624. // PlaceThingRepositoryMockGetByThingIDExpectation specifies expectation struct of the PlaceThingRepository.GetByThingID
  625. type PlaceThingRepositoryMockGetByThingIDExpectation struct {
  626. mock *PlaceThingRepositoryMock
  627. params *PlaceThingRepositoryMockGetByThingIDParams
  628. paramPtrs *PlaceThingRepositoryMockGetByThingIDParamPtrs
  629. results *PlaceThingRepositoryMockGetByThingIDResults
  630. Counter uint64
  631. }
  632. // PlaceThingRepositoryMockGetByThingIDParams contains parameters of the PlaceThingRepository.GetByThingID
  633. type PlaceThingRepositoryMockGetByThingIDParams struct {
  634. ctx context.Context
  635. thingID int
  636. }
  637. // PlaceThingRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the PlaceThingRepository.GetByThingID
  638. type PlaceThingRepositoryMockGetByThingIDParamPtrs struct {
  639. ctx *context.Context
  640. thingID *int
  641. }
  642. // PlaceThingRepositoryMockGetByThingIDResults contains results of the PlaceThingRepository.GetByThingID
  643. type PlaceThingRepositoryMockGetByThingIDResults struct {
  644. pp1 *models.PlaceThing
  645. err error
  646. }
  647. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  648. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  649. // Optional() makes method check to work in '0 or more' mode.
  650. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  651. // catch the problems when the expected method call is totally skipped during test run.
  652. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Optional() *mPlaceThingRepositoryMockGetByThingID {
  653. mmGetByThingID.optional = true
  654. return mmGetByThingID
  655. }
  656. // Expect sets up expected params for PlaceThingRepository.GetByThingID
  657. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Expect(ctx context.Context, thingID int) *mPlaceThingRepositoryMockGetByThingID {
  658. if mmGetByThingID.mock.funcGetByThingID != nil {
  659. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
  660. }
  661. if mmGetByThingID.defaultExpectation == nil {
  662. mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{}
  663. }
  664. if mmGetByThingID.defaultExpectation.paramPtrs != nil {
  665. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
  666. }
  667. mmGetByThingID.defaultExpectation.params = &PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
  668. for _, e := range mmGetByThingID.expectations {
  669. if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
  670. mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
  671. }
  672. }
  673. return mmGetByThingID
  674. }
  675. // ExpectCtxParam1 sets up expected param ctx for PlaceThingRepository.GetByThingID
  676. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockGetByThingID {
  677. if mmGetByThingID.mock.funcGetByThingID != nil {
  678. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
  679. }
  680. if mmGetByThingID.defaultExpectation == nil {
  681. mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{}
  682. }
  683. if mmGetByThingID.defaultExpectation.params != nil {
  684. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Expect")
  685. }
  686. if mmGetByThingID.defaultExpectation.paramPtrs == nil {
  687. mmGetByThingID.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockGetByThingIDParamPtrs{}
  688. }
  689. mmGetByThingID.defaultExpectation.paramPtrs.ctx = &ctx
  690. return mmGetByThingID
  691. }
  692. // ExpectThingIDParam2 sets up expected param thingID for PlaceThingRepository.GetByThingID
  693. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectThingIDParam2(thingID int) *mPlaceThingRepositoryMockGetByThingID {
  694. if mmGetByThingID.mock.funcGetByThingID != nil {
  695. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
  696. }
  697. if mmGetByThingID.defaultExpectation == nil {
  698. mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{}
  699. }
  700. if mmGetByThingID.defaultExpectation.params != nil {
  701. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Expect")
  702. }
  703. if mmGetByThingID.defaultExpectation.paramPtrs == nil {
  704. mmGetByThingID.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockGetByThingIDParamPtrs{}
  705. }
  706. mmGetByThingID.defaultExpectation.paramPtrs.thingID = &thingID
  707. return mmGetByThingID
  708. }
  709. // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.GetByThingID
  710. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, thingID int)) *mPlaceThingRepositoryMockGetByThingID {
  711. if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
  712. mmGetByThingID.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.GetByThingID")
  713. }
  714. mmGetByThingID.mock.inspectFuncGetByThingID = f
  715. return mmGetByThingID
  716. }
  717. // Return sets up results that will be returned by PlaceThingRepository.GetByThingID
  718. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Return(pp1 *models.PlaceThing, err error) *PlaceThingRepositoryMock {
  719. if mmGetByThingID.mock.funcGetByThingID != nil {
  720. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
  721. }
  722. if mmGetByThingID.defaultExpectation == nil {
  723. mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{mock: mmGetByThingID.mock}
  724. }
  725. mmGetByThingID.defaultExpectation.results = &PlaceThingRepositoryMockGetByThingIDResults{pp1, err}
  726. return mmGetByThingID.mock
  727. }
  728. // Set uses given function f to mock the PlaceThingRepository.GetByThingID method
  729. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Set(f func(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error)) *PlaceThingRepositoryMock {
  730. if mmGetByThingID.defaultExpectation != nil {
  731. mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.GetByThingID method")
  732. }
  733. if len(mmGetByThingID.expectations) > 0 {
  734. mmGetByThingID.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.GetByThingID method")
  735. }
  736. mmGetByThingID.mock.funcGetByThingID = f
  737. return mmGetByThingID.mock
  738. }
  739. // When sets expectation for the PlaceThingRepository.GetByThingID which will trigger the result defined by the following
  740. // Then helper
  741. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) When(ctx context.Context, thingID int) *PlaceThingRepositoryMockGetByThingIDExpectation {
  742. if mmGetByThingID.mock.funcGetByThingID != nil {
  743. mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
  744. }
  745. expectation := &PlaceThingRepositoryMockGetByThingIDExpectation{
  746. mock: mmGetByThingID.mock,
  747. params: &PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID},
  748. }
  749. mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
  750. return expectation
  751. }
  752. // Then sets up PlaceThingRepository.GetByThingID return parameters for the expectation previously defined by the When method
  753. func (e *PlaceThingRepositoryMockGetByThingIDExpectation) Then(pp1 *models.PlaceThing, err error) *PlaceThingRepositoryMock {
  754. e.results = &PlaceThingRepositoryMockGetByThingIDResults{pp1, err}
  755. return e.mock
  756. }
  757. // Times sets number of times PlaceThingRepository.GetByThingID should be invoked
  758. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Times(n uint64) *mPlaceThingRepositoryMockGetByThingID {
  759. if n == 0 {
  760. mmGetByThingID.mock.t.Fatalf("Times of PlaceThingRepositoryMock.GetByThingID mock can not be zero")
  761. }
  762. mm_atomic.StoreUint64(&mmGetByThingID.expectedInvocations, n)
  763. return mmGetByThingID
  764. }
  765. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) invocationsDone() bool {
  766. if len(mmGetByThingID.expectations) == 0 && mmGetByThingID.defaultExpectation == nil && mmGetByThingID.mock.funcGetByThingID == nil {
  767. return true
  768. }
  769. totalInvocations := mm_atomic.LoadUint64(&mmGetByThingID.mock.afterGetByThingIDCounter)
  770. expectedInvocations := mm_atomic.LoadUint64(&mmGetByThingID.expectedInvocations)
  771. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  772. }
  773. // GetByThingID implements thing.PlaceThingRepository
  774. func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error) {
  775. mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
  776. defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)
  777. if mmGetByThingID.inspectFuncGetByThingID != nil {
  778. mmGetByThingID.inspectFuncGetByThingID(ctx, thingID)
  779. }
  780. mm_params := PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
  781. // Record call args
  782. mmGetByThingID.GetByThingIDMock.mutex.Lock()
  783. mmGetByThingID.GetByThingIDMock.callArgs = append(mmGetByThingID.GetByThingIDMock.callArgs, &mm_params)
  784. mmGetByThingID.GetByThingIDMock.mutex.Unlock()
  785. for _, e := range mmGetByThingID.GetByThingIDMock.expectations {
  786. if minimock.Equal(*e.params, mm_params) {
  787. mm_atomic.AddUint64(&e.Counter, 1)
  788. return e.results.pp1, e.results.err
  789. }
  790. }
  791. if mmGetByThingID.GetByThingIDMock.defaultExpectation != nil {
  792. mm_atomic.AddUint64(&mmGetByThingID.GetByThingIDMock.defaultExpectation.Counter, 1)
  793. mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
  794. mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs
  795. mm_got := PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
  796. if mm_want_ptrs != nil {
  797. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  798. mmGetByThingID.t.Errorf("PlaceThingRepositoryMock.GetByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  799. }
  800. if mm_want_ptrs.thingID != nil && !minimock.Equal(*mm_want_ptrs.thingID, mm_got.thingID) {
  801. mmGetByThingID.t.Errorf("PlaceThingRepositoryMock.GetByThingID got unexpected parameter thingID, want: %#v, got: %#v%s\n", *mm_want_ptrs.thingID, mm_got.thingID, minimock.Diff(*mm_want_ptrs.thingID, mm_got.thingID))
  802. }
  803. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  804. mmGetByThingID.t.Errorf("PlaceThingRepositoryMock.GetByThingID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  805. }
  806. mm_results := mmGetByThingID.GetByThingIDMock.defaultExpectation.results
  807. if mm_results == nil {
  808. mmGetByThingID.t.Fatal("No results are set for the PlaceThingRepositoryMock.GetByThingID")
  809. }
  810. return (*mm_results).pp1, (*mm_results).err
  811. }
  812. if mmGetByThingID.funcGetByThingID != nil {
  813. return mmGetByThingID.funcGetByThingID(ctx, thingID)
  814. }
  815. mmGetByThingID.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.GetByThingID. %v %v", ctx, thingID)
  816. return
  817. }
  818. // GetByThingIDAfterCounter returns a count of finished PlaceThingRepositoryMock.GetByThingID invocations
  819. func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingIDAfterCounter() uint64 {
  820. return mm_atomic.LoadUint64(&mmGetByThingID.afterGetByThingIDCounter)
  821. }
  822. // GetByThingIDBeforeCounter returns a count of PlaceThingRepositoryMock.GetByThingID invocations
  823. func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingIDBeforeCounter() uint64 {
  824. return mm_atomic.LoadUint64(&mmGetByThingID.beforeGetByThingIDCounter)
  825. }
  826. // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.GetByThingID.
  827. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  828. func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Calls() []*PlaceThingRepositoryMockGetByThingIDParams {
  829. mmGetByThingID.mutex.RLock()
  830. argCopy := make([]*PlaceThingRepositoryMockGetByThingIDParams, len(mmGetByThingID.callArgs))
  831. copy(argCopy, mmGetByThingID.callArgs)
  832. mmGetByThingID.mutex.RUnlock()
  833. return argCopy
  834. }
  835. // MinimockGetByThingIDDone returns true if the count of the GetByThingID invocations corresponds
  836. // the number of defined expectations
  837. func (m *PlaceThingRepositoryMock) MinimockGetByThingIDDone() bool {
  838. if m.GetByThingIDMock.optional {
  839. // Optional methods provide '0 or more' call count restriction.
  840. return true
  841. }
  842. for _, e := range m.GetByThingIDMock.expectations {
  843. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  844. return false
  845. }
  846. }
  847. return m.GetByThingIDMock.invocationsDone()
  848. }
  849. // MinimockGetByThingIDInspect logs each unmet expectation
  850. func (m *PlaceThingRepositoryMock) MinimockGetByThingIDInspect() {
  851. for _, e := range m.GetByThingIDMock.expectations {
  852. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  853. m.t.Errorf("Expected call to PlaceThingRepositoryMock.GetByThingID with params: %#v", *e.params)
  854. }
  855. }
  856. afterGetByThingIDCounter := mm_atomic.LoadUint64(&m.afterGetByThingIDCounter)
  857. // if default expectation was set then invocations count should be greater than zero
  858. if m.GetByThingIDMock.defaultExpectation != nil && afterGetByThingIDCounter < 1 {
  859. if m.GetByThingIDMock.defaultExpectation.params == nil {
  860. m.t.Error("Expected call to PlaceThingRepositoryMock.GetByThingID")
  861. } else {
  862. m.t.Errorf("Expected call to PlaceThingRepositoryMock.GetByThingID with params: %#v", *m.GetByThingIDMock.defaultExpectation.params)
  863. }
  864. }
  865. // if func was set then invocations count should be greater than zero
  866. if m.funcGetByThingID != nil && afterGetByThingIDCounter < 1 {
  867. m.t.Error("Expected call to PlaceThingRepositoryMock.GetByThingID")
  868. }
  869. if !m.GetByThingIDMock.invocationsDone() && afterGetByThingIDCounter > 0 {
  870. m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.GetByThingID but found %d calls",
  871. mm_atomic.LoadUint64(&m.GetByThingIDMock.expectedInvocations), afterGetByThingIDCounter)
  872. }
  873. }
  874. type mPlaceThingRepositoryMockUpdatePlace struct {
  875. optional bool
  876. mock *PlaceThingRepositoryMock
  877. defaultExpectation *PlaceThingRepositoryMockUpdatePlaceExpectation
  878. expectations []*PlaceThingRepositoryMockUpdatePlaceExpectation
  879. callArgs []*PlaceThingRepositoryMockUpdatePlaceParams
  880. mutex sync.RWMutex
  881. expectedInvocations uint64
  882. }
  883. // PlaceThingRepositoryMockUpdatePlaceExpectation specifies expectation struct of the PlaceThingRepository.UpdatePlace
  884. type PlaceThingRepositoryMockUpdatePlaceExpectation struct {
  885. mock *PlaceThingRepositoryMock
  886. params *PlaceThingRepositoryMockUpdatePlaceParams
  887. paramPtrs *PlaceThingRepositoryMockUpdatePlaceParamPtrs
  888. results *PlaceThingRepositoryMockUpdatePlaceResults
  889. Counter uint64
  890. }
  891. // PlaceThingRepositoryMockUpdatePlaceParams contains parameters of the PlaceThingRepository.UpdatePlace
  892. type PlaceThingRepositoryMockUpdatePlaceParams struct {
  893. ctx context.Context
  894. req models.UpdatePlaceThingRequest
  895. tx *sql.Tx
  896. }
  897. // PlaceThingRepositoryMockUpdatePlaceParamPtrs contains pointers to parameters of the PlaceThingRepository.UpdatePlace
  898. type PlaceThingRepositoryMockUpdatePlaceParamPtrs struct {
  899. ctx *context.Context
  900. req *models.UpdatePlaceThingRequest
  901. tx **sql.Tx
  902. }
  903. // PlaceThingRepositoryMockUpdatePlaceResults contains results of the PlaceThingRepository.UpdatePlace
  904. type PlaceThingRepositoryMockUpdatePlaceResults struct {
  905. err error
  906. }
  907. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  908. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  909. // Optional() makes method check to work in '0 or more' mode.
  910. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  911. // catch the problems when the expected method call is totally skipped during test run.
  912. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Optional() *mPlaceThingRepositoryMockUpdatePlace {
  913. mmUpdatePlace.optional = true
  914. return mmUpdatePlace
  915. }
  916. // Expect sets up expected params for PlaceThingRepository.UpdatePlace
  917. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Expect(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) *mPlaceThingRepositoryMockUpdatePlace {
  918. if mmUpdatePlace.mock.funcUpdatePlace != nil {
  919. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
  920. }
  921. if mmUpdatePlace.defaultExpectation == nil {
  922. mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
  923. }
  924. if mmUpdatePlace.defaultExpectation.paramPtrs != nil {
  925. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by ExpectParams functions")
  926. }
  927. mmUpdatePlace.defaultExpectation.params = &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
  928. for _, e := range mmUpdatePlace.expectations {
  929. if minimock.Equal(e.params, mmUpdatePlace.defaultExpectation.params) {
  930. mmUpdatePlace.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdatePlace.defaultExpectation.params)
  931. }
  932. }
  933. return mmUpdatePlace
  934. }
  935. // ExpectCtxParam1 sets up expected param ctx for PlaceThingRepository.UpdatePlace
  936. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockUpdatePlace {
  937. if mmUpdatePlace.mock.funcUpdatePlace != nil {
  938. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
  939. }
  940. if mmUpdatePlace.defaultExpectation == nil {
  941. mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
  942. }
  943. if mmUpdatePlace.defaultExpectation.params != nil {
  944. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Expect")
  945. }
  946. if mmUpdatePlace.defaultExpectation.paramPtrs == nil {
  947. mmUpdatePlace.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockUpdatePlaceParamPtrs{}
  948. }
  949. mmUpdatePlace.defaultExpectation.paramPtrs.ctx = &ctx
  950. return mmUpdatePlace
  951. }
  952. // ExpectReqParam2 sets up expected param req for PlaceThingRepository.UpdatePlace
  953. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) ExpectReqParam2(req models.UpdatePlaceThingRequest) *mPlaceThingRepositoryMockUpdatePlace {
  954. if mmUpdatePlace.mock.funcUpdatePlace != nil {
  955. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
  956. }
  957. if mmUpdatePlace.defaultExpectation == nil {
  958. mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
  959. }
  960. if mmUpdatePlace.defaultExpectation.params != nil {
  961. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Expect")
  962. }
  963. if mmUpdatePlace.defaultExpectation.paramPtrs == nil {
  964. mmUpdatePlace.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockUpdatePlaceParamPtrs{}
  965. }
  966. mmUpdatePlace.defaultExpectation.paramPtrs.req = &req
  967. return mmUpdatePlace
  968. }
  969. // ExpectTxParam3 sets up expected param tx for PlaceThingRepository.UpdatePlace
  970. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) ExpectTxParam3(tx *sql.Tx) *mPlaceThingRepositoryMockUpdatePlace {
  971. if mmUpdatePlace.mock.funcUpdatePlace != nil {
  972. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
  973. }
  974. if mmUpdatePlace.defaultExpectation == nil {
  975. mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
  976. }
  977. if mmUpdatePlace.defaultExpectation.params != nil {
  978. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Expect")
  979. }
  980. if mmUpdatePlace.defaultExpectation.paramPtrs == nil {
  981. mmUpdatePlace.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockUpdatePlaceParamPtrs{}
  982. }
  983. mmUpdatePlace.defaultExpectation.paramPtrs.tx = &tx
  984. return mmUpdatePlace
  985. }
  986. // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.UpdatePlace
  987. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Inspect(f func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx)) *mPlaceThingRepositoryMockUpdatePlace {
  988. if mmUpdatePlace.mock.inspectFuncUpdatePlace != nil {
  989. mmUpdatePlace.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.UpdatePlace")
  990. }
  991. mmUpdatePlace.mock.inspectFuncUpdatePlace = f
  992. return mmUpdatePlace
  993. }
  994. // Return sets up results that will be returned by PlaceThingRepository.UpdatePlace
  995. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Return(err error) *PlaceThingRepositoryMock {
  996. if mmUpdatePlace.mock.funcUpdatePlace != nil {
  997. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
  998. }
  999. if mmUpdatePlace.defaultExpectation == nil {
  1000. mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{mock: mmUpdatePlace.mock}
  1001. }
  1002. mmUpdatePlace.defaultExpectation.results = &PlaceThingRepositoryMockUpdatePlaceResults{err}
  1003. return mmUpdatePlace.mock
  1004. }
  1005. // Set uses given function f to mock the PlaceThingRepository.UpdatePlace method
  1006. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Set(f func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
  1007. if mmUpdatePlace.defaultExpectation != nil {
  1008. mmUpdatePlace.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.UpdatePlace method")
  1009. }
  1010. if len(mmUpdatePlace.expectations) > 0 {
  1011. mmUpdatePlace.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.UpdatePlace method")
  1012. }
  1013. mmUpdatePlace.mock.funcUpdatePlace = f
  1014. return mmUpdatePlace.mock
  1015. }
  1016. // When sets expectation for the PlaceThingRepository.UpdatePlace which will trigger the result defined by the following
  1017. // Then helper
  1018. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) When(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) *PlaceThingRepositoryMockUpdatePlaceExpectation {
  1019. if mmUpdatePlace.mock.funcUpdatePlace != nil {
  1020. mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
  1021. }
  1022. expectation := &PlaceThingRepositoryMockUpdatePlaceExpectation{
  1023. mock: mmUpdatePlace.mock,
  1024. params: &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx},
  1025. }
  1026. mmUpdatePlace.expectations = append(mmUpdatePlace.expectations, expectation)
  1027. return expectation
  1028. }
  1029. // Then sets up PlaceThingRepository.UpdatePlace return parameters for the expectation previously defined by the When method
  1030. func (e *PlaceThingRepositoryMockUpdatePlaceExpectation) Then(err error) *PlaceThingRepositoryMock {
  1031. e.results = &PlaceThingRepositoryMockUpdatePlaceResults{err}
  1032. return e.mock
  1033. }
  1034. // Times sets number of times PlaceThingRepository.UpdatePlace should be invoked
  1035. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Times(n uint64) *mPlaceThingRepositoryMockUpdatePlace {
  1036. if n == 0 {
  1037. mmUpdatePlace.mock.t.Fatalf("Times of PlaceThingRepositoryMock.UpdatePlace mock can not be zero")
  1038. }
  1039. mm_atomic.StoreUint64(&mmUpdatePlace.expectedInvocations, n)
  1040. return mmUpdatePlace
  1041. }
  1042. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) invocationsDone() bool {
  1043. if len(mmUpdatePlace.expectations) == 0 && mmUpdatePlace.defaultExpectation == nil && mmUpdatePlace.mock.funcUpdatePlace == nil {
  1044. return true
  1045. }
  1046. totalInvocations := mm_atomic.LoadUint64(&mmUpdatePlace.mock.afterUpdatePlaceCounter)
  1047. expectedInvocations := mm_atomic.LoadUint64(&mmUpdatePlace.expectedInvocations)
  1048. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  1049. }
  1050. // UpdatePlace implements thing.PlaceThingRepository
  1051. func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error) {
  1052. mm_atomic.AddUint64(&mmUpdatePlace.beforeUpdatePlaceCounter, 1)
  1053. defer mm_atomic.AddUint64(&mmUpdatePlace.afterUpdatePlaceCounter, 1)
  1054. if mmUpdatePlace.inspectFuncUpdatePlace != nil {
  1055. mmUpdatePlace.inspectFuncUpdatePlace(ctx, req, tx)
  1056. }
  1057. mm_params := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
  1058. // Record call args
  1059. mmUpdatePlace.UpdatePlaceMock.mutex.Lock()
  1060. mmUpdatePlace.UpdatePlaceMock.callArgs = append(mmUpdatePlace.UpdatePlaceMock.callArgs, &mm_params)
  1061. mmUpdatePlace.UpdatePlaceMock.mutex.Unlock()
  1062. for _, e := range mmUpdatePlace.UpdatePlaceMock.expectations {
  1063. if minimock.Equal(*e.params, mm_params) {
  1064. mm_atomic.AddUint64(&e.Counter, 1)
  1065. return e.results.err
  1066. }
  1067. }
  1068. if mmUpdatePlace.UpdatePlaceMock.defaultExpectation != nil {
  1069. mm_atomic.AddUint64(&mmUpdatePlace.UpdatePlaceMock.defaultExpectation.Counter, 1)
  1070. mm_want := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.params
  1071. mm_want_ptrs := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.paramPtrs
  1072. mm_got := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
  1073. if mm_want_ptrs != nil {
  1074. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  1075. mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  1076. }
  1077. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  1078. mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
  1079. }
  1080. if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
  1081. mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameter tx, want: %#v, got: %#v%s\n", *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
  1082. }
  1083. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  1084. mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  1085. }
  1086. mm_results := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.results
  1087. if mm_results == nil {
  1088. mmUpdatePlace.t.Fatal("No results are set for the PlaceThingRepositoryMock.UpdatePlace")
  1089. }
  1090. return (*mm_results).err
  1091. }
  1092. if mmUpdatePlace.funcUpdatePlace != nil {
  1093. return mmUpdatePlace.funcUpdatePlace(ctx, req, tx)
  1094. }
  1095. mmUpdatePlace.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.UpdatePlace. %v %v %v", ctx, req, tx)
  1096. return
  1097. }
  1098. // UpdatePlaceAfterCounter returns a count of finished PlaceThingRepositoryMock.UpdatePlace invocations
  1099. func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlaceAfterCounter() uint64 {
  1100. return mm_atomic.LoadUint64(&mmUpdatePlace.afterUpdatePlaceCounter)
  1101. }
  1102. // UpdatePlaceBeforeCounter returns a count of PlaceThingRepositoryMock.UpdatePlace invocations
  1103. func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlaceBeforeCounter() uint64 {
  1104. return mm_atomic.LoadUint64(&mmUpdatePlace.beforeUpdatePlaceCounter)
  1105. }
  1106. // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.UpdatePlace.
  1107. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  1108. func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Calls() []*PlaceThingRepositoryMockUpdatePlaceParams {
  1109. mmUpdatePlace.mutex.RLock()
  1110. argCopy := make([]*PlaceThingRepositoryMockUpdatePlaceParams, len(mmUpdatePlace.callArgs))
  1111. copy(argCopy, mmUpdatePlace.callArgs)
  1112. mmUpdatePlace.mutex.RUnlock()
  1113. return argCopy
  1114. }
  1115. // MinimockUpdatePlaceDone returns true if the count of the UpdatePlace invocations corresponds
  1116. // the number of defined expectations
  1117. func (m *PlaceThingRepositoryMock) MinimockUpdatePlaceDone() bool {
  1118. if m.UpdatePlaceMock.optional {
  1119. // Optional methods provide '0 or more' call count restriction.
  1120. return true
  1121. }
  1122. for _, e := range m.UpdatePlaceMock.expectations {
  1123. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1124. return false
  1125. }
  1126. }
  1127. return m.UpdatePlaceMock.invocationsDone()
  1128. }
  1129. // MinimockUpdatePlaceInspect logs each unmet expectation
  1130. func (m *PlaceThingRepositoryMock) MinimockUpdatePlaceInspect() {
  1131. for _, e := range m.UpdatePlaceMock.expectations {
  1132. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  1133. m.t.Errorf("Expected call to PlaceThingRepositoryMock.UpdatePlace with params: %#v", *e.params)
  1134. }
  1135. }
  1136. afterUpdatePlaceCounter := mm_atomic.LoadUint64(&m.afterUpdatePlaceCounter)
  1137. // if default expectation was set then invocations count should be greater than zero
  1138. if m.UpdatePlaceMock.defaultExpectation != nil && afterUpdatePlaceCounter < 1 {
  1139. if m.UpdatePlaceMock.defaultExpectation.params == nil {
  1140. m.t.Error("Expected call to PlaceThingRepositoryMock.UpdatePlace")
  1141. } else {
  1142. m.t.Errorf("Expected call to PlaceThingRepositoryMock.UpdatePlace with params: %#v", *m.UpdatePlaceMock.defaultExpectation.params)
  1143. }
  1144. }
  1145. // if func was set then invocations count should be greater than zero
  1146. if m.funcUpdatePlace != nil && afterUpdatePlaceCounter < 1 {
  1147. m.t.Error("Expected call to PlaceThingRepositoryMock.UpdatePlace")
  1148. }
  1149. if !m.UpdatePlaceMock.invocationsDone() && afterUpdatePlaceCounter > 0 {
  1150. m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.UpdatePlace but found %d calls",
  1151. mm_atomic.LoadUint64(&m.UpdatePlaceMock.expectedInvocations), afterUpdatePlaceCounter)
  1152. }
  1153. }
  1154. // MinimockFinish checks that all mocked methods have been called the expected number of times
  1155. func (m *PlaceThingRepositoryMock) MinimockFinish() {
  1156. m.finishOnce.Do(func() {
  1157. if !m.minimockDone() {
  1158. m.MinimockAddInspect()
  1159. m.MinimockDeleteThingInspect()
  1160. m.MinimockGetByThingIDInspect()
  1161. m.MinimockUpdatePlaceInspect()
  1162. }
  1163. })
  1164. }
  1165. // MinimockWait waits for all mocked methods to be called the expected number of times
  1166. func (m *PlaceThingRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  1167. timeoutCh := mm_time.After(timeout)
  1168. for {
  1169. if m.minimockDone() {
  1170. return
  1171. }
  1172. select {
  1173. case <-timeoutCh:
  1174. m.MinimockFinish()
  1175. return
  1176. case <-mm_time.After(10 * mm_time.Millisecond):
  1177. }
  1178. }
  1179. }
  1180. func (m *PlaceThingRepositoryMock) minimockDone() bool {
  1181. done := true
  1182. return done &&
  1183. m.MinimockAddDone() &&
  1184. m.MinimockDeleteThingDone() &&
  1185. m.MinimockGetByThingIDDone() &&
  1186. m.MinimockUpdatePlaceDone()
  1187. }