thing_repository_minimock.go 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. // Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
  2. package mocks
  3. //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place.ThingRepository -o thing_repository_minimock.go -n ThingRepositoryMock -p mocks
  4. import (
  5. "context"
  6. "sync"
  7. mm_atomic "sync/atomic"
  8. mm_time "time"
  9. "git.dmitriygnatenko.ru/dima/homethings/internal/models"
  10. "github.com/gojuno/minimock/v3"
  11. )
  12. // ThingRepositoryMock implements place.ThingRepository
  13. type ThingRepositoryMock struct {
  14. t minimock.Tester
  15. finishOnce sync.Once
  16. funcDelete func(ctx context.Context, id uint64) (err error)
  17. inspectFuncDelete func(ctx context.Context, id uint64)
  18. afterDeleteCounter uint64
  19. beforeDeleteCounter uint64
  20. DeleteMock mThingRepositoryMockDelete
  21. funcGetByPlaceID func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)
  22. inspectFuncGetByPlaceID func(ctx context.Context, id uint64)
  23. afterGetByPlaceIDCounter uint64
  24. beforeGetByPlaceIDCounter uint64
  25. GetByPlaceIDMock mThingRepositoryMockGetByPlaceID
  26. }
  27. // NewThingRepositoryMock returns a mock for place.ThingRepository
  28. func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock {
  29. m := &ThingRepositoryMock{t: t}
  30. if controller, ok := t.(minimock.MockController); ok {
  31. controller.RegisterMocker(m)
  32. }
  33. m.DeleteMock = mThingRepositoryMockDelete{mock: m}
  34. m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{}
  35. m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m}
  36. m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{}
  37. t.Cleanup(m.MinimockFinish)
  38. return m
  39. }
  40. type mThingRepositoryMockDelete struct {
  41. optional bool
  42. mock *ThingRepositoryMock
  43. defaultExpectation *ThingRepositoryMockDeleteExpectation
  44. expectations []*ThingRepositoryMockDeleteExpectation
  45. callArgs []*ThingRepositoryMockDeleteParams
  46. mutex sync.RWMutex
  47. expectedInvocations uint64
  48. }
  49. // ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete
  50. type ThingRepositoryMockDeleteExpectation struct {
  51. mock *ThingRepositoryMock
  52. params *ThingRepositoryMockDeleteParams
  53. paramPtrs *ThingRepositoryMockDeleteParamPtrs
  54. results *ThingRepositoryMockDeleteResults
  55. Counter uint64
  56. }
  57. // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
  58. type ThingRepositoryMockDeleteParams struct {
  59. ctx context.Context
  60. id uint64
  61. }
  62. // ThingRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingRepository.Delete
  63. type ThingRepositoryMockDeleteParamPtrs struct {
  64. ctx *context.Context
  65. id *uint64
  66. }
  67. // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
  68. type ThingRepositoryMockDeleteResults struct {
  69. err error
  70. }
  71. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  72. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  73. // Optional() makes method check to work in '0 or more' mode.
  74. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  75. // catch the problems when the expected method call is totally skipped during test run.
  76. func (mmDelete *mThingRepositoryMockDelete) Optional() *mThingRepositoryMockDelete {
  77. mmDelete.optional = true
  78. return mmDelete
  79. }
  80. // Expect sets up expected params for ThingRepository.Delete
  81. func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingRepositoryMockDelete {
  82. if mmDelete.mock.funcDelete != nil {
  83. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  84. }
  85. if mmDelete.defaultExpectation == nil {
  86. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  87. }
  88. if mmDelete.defaultExpectation.paramPtrs != nil {
  89. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by ExpectParams functions")
  90. }
  91. mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, id}
  92. for _, e := range mmDelete.expectations {
  93. if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
  94. mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
  95. }
  96. }
  97. return mmDelete
  98. }
  99. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.Delete
  100. func (mmDelete *mThingRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockDelete {
  101. if mmDelete.mock.funcDelete != nil {
  102. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  103. }
  104. if mmDelete.defaultExpectation == nil {
  105. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  106. }
  107. if mmDelete.defaultExpectation.params != nil {
  108. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
  109. }
  110. if mmDelete.defaultExpectation.paramPtrs == nil {
  111. mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
  112. }
  113. mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
  114. return mmDelete
  115. }
  116. // ExpectIdParam2 sets up expected param id for ThingRepository.Delete
  117. func (mmDelete *mThingRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingRepositoryMockDelete {
  118. if mmDelete.mock.funcDelete != nil {
  119. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  120. }
  121. if mmDelete.defaultExpectation == nil {
  122. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
  123. }
  124. if mmDelete.defaultExpectation.params != nil {
  125. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
  126. }
  127. if mmDelete.defaultExpectation.paramPtrs == nil {
  128. mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
  129. }
  130. mmDelete.defaultExpectation.paramPtrs.id = &id
  131. return mmDelete
  132. }
  133. // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
  134. func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockDelete {
  135. if mmDelete.mock.inspectFuncDelete != nil {
  136. mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
  137. }
  138. mmDelete.mock.inspectFuncDelete = f
  139. return mmDelete
  140. }
  141. // Return sets up results that will be returned by ThingRepository.Delete
  142. func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock {
  143. if mmDelete.mock.funcDelete != nil {
  144. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  145. }
  146. if mmDelete.defaultExpectation == nil {
  147. mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock}
  148. }
  149. mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err}
  150. return mmDelete.mock
  151. }
  152. // Set uses given function f to mock the ThingRepository.Delete method
  153. func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingRepositoryMock {
  154. if mmDelete.defaultExpectation != nil {
  155. mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
  156. }
  157. if len(mmDelete.expectations) > 0 {
  158. mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method")
  159. }
  160. mmDelete.mock.funcDelete = f
  161. return mmDelete.mock
  162. }
  163. // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
  164. // Then helper
  165. func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingRepositoryMockDeleteExpectation {
  166. if mmDelete.mock.funcDelete != nil {
  167. mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
  168. }
  169. expectation := &ThingRepositoryMockDeleteExpectation{
  170. mock: mmDelete.mock,
  171. params: &ThingRepositoryMockDeleteParams{ctx, id},
  172. }
  173. mmDelete.expectations = append(mmDelete.expectations, expectation)
  174. return expectation
  175. }
  176. // Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method
  177. func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock {
  178. e.results = &ThingRepositoryMockDeleteResults{err}
  179. return e.mock
  180. }
  181. // Times sets number of times ThingRepository.Delete should be invoked
  182. func (mmDelete *mThingRepositoryMockDelete) Times(n uint64) *mThingRepositoryMockDelete {
  183. if n == 0 {
  184. mmDelete.mock.t.Fatalf("Times of ThingRepositoryMock.Delete mock can not be zero")
  185. }
  186. mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
  187. return mmDelete
  188. }
  189. func (mmDelete *mThingRepositoryMockDelete) invocationsDone() bool {
  190. if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
  191. return true
  192. }
  193. totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
  194. expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
  195. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  196. }
  197. // Delete implements place.ThingRepository
  198. func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
  199. mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
  200. defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
  201. if mmDelete.inspectFuncDelete != nil {
  202. mmDelete.inspectFuncDelete(ctx, id)
  203. }
  204. mm_params := ThingRepositoryMockDeleteParams{ctx, id}
  205. // Record call args
  206. mmDelete.DeleteMock.mutex.Lock()
  207. mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
  208. mmDelete.DeleteMock.mutex.Unlock()
  209. for _, e := range mmDelete.DeleteMock.expectations {
  210. if minimock.Equal(*e.params, mm_params) {
  211. mm_atomic.AddUint64(&e.Counter, 1)
  212. return e.results.err
  213. }
  214. }
  215. if mmDelete.DeleteMock.defaultExpectation != nil {
  216. mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
  217. mm_want := mmDelete.DeleteMock.defaultExpectation.params
  218. mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
  219. mm_got := ThingRepositoryMockDeleteParams{ctx, id}
  220. if mm_want_ptrs != nil {
  221. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  222. mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  223. }
  224. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  225. mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  226. }
  227. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  228. mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  229. }
  230. mm_results := mmDelete.DeleteMock.defaultExpectation.results
  231. if mm_results == nil {
  232. mmDelete.t.Fatal("No results are set for the ThingRepositoryMock.Delete")
  233. }
  234. return (*mm_results).err
  235. }
  236. if mmDelete.funcDelete != nil {
  237. return mmDelete.funcDelete(ctx, id)
  238. }
  239. mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v", ctx, id)
  240. return
  241. }
  242. // DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations
  243. func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 {
  244. return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
  245. }
  246. // DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations
  247. func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 {
  248. return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
  249. }
  250. // Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete.
  251. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  252. func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams {
  253. mmDelete.mutex.RLock()
  254. argCopy := make([]*ThingRepositoryMockDeleteParams, len(mmDelete.callArgs))
  255. copy(argCopy, mmDelete.callArgs)
  256. mmDelete.mutex.RUnlock()
  257. return argCopy
  258. }
  259. // MinimockDeleteDone returns true if the count of the Delete invocations corresponds
  260. // the number of defined expectations
  261. func (m *ThingRepositoryMock) MinimockDeleteDone() bool {
  262. if m.DeleteMock.optional {
  263. // Optional methods provide '0 or more' call count restriction.
  264. return true
  265. }
  266. for _, e := range m.DeleteMock.expectations {
  267. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  268. return false
  269. }
  270. }
  271. return m.DeleteMock.invocationsDone()
  272. }
  273. // MinimockDeleteInspect logs each unmet expectation
  274. func (m *ThingRepositoryMock) MinimockDeleteInspect() {
  275. for _, e := range m.DeleteMock.expectations {
  276. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  277. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *e.params)
  278. }
  279. }
  280. afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
  281. // if default expectation was set then invocations count should be greater than zero
  282. if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
  283. if m.DeleteMock.defaultExpectation.params == nil {
  284. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  285. } else {
  286. m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
  287. }
  288. }
  289. // if func was set then invocations count should be greater than zero
  290. if m.funcDelete != nil && afterDeleteCounter < 1 {
  291. m.t.Error("Expected call to ThingRepositoryMock.Delete")
  292. }
  293. if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
  294. m.t.Errorf("Expected %d calls to ThingRepositoryMock.Delete but found %d calls",
  295. mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
  296. }
  297. }
  298. type mThingRepositoryMockGetByPlaceID struct {
  299. optional bool
  300. mock *ThingRepositoryMock
  301. defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation
  302. expectations []*ThingRepositoryMockGetByPlaceIDExpectation
  303. callArgs []*ThingRepositoryMockGetByPlaceIDParams
  304. mutex sync.RWMutex
  305. expectedInvocations uint64
  306. }
  307. // ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID
  308. type ThingRepositoryMockGetByPlaceIDExpectation struct {
  309. mock *ThingRepositoryMock
  310. params *ThingRepositoryMockGetByPlaceIDParams
  311. paramPtrs *ThingRepositoryMockGetByPlaceIDParamPtrs
  312. results *ThingRepositoryMockGetByPlaceIDResults
  313. Counter uint64
  314. }
  315. // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
  316. type ThingRepositoryMockGetByPlaceIDParams struct {
  317. ctx context.Context
  318. id uint64
  319. }
  320. // ThingRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetByPlaceID
  321. type ThingRepositoryMockGetByPlaceIDParamPtrs struct {
  322. ctx *context.Context
  323. id *uint64
  324. }
  325. // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
  326. type ThingRepositoryMockGetByPlaceIDResults struct {
  327. ta1 []models.Thing
  328. err error
  329. }
  330. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  331. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  332. // Optional() makes method check to work in '0 or more' mode.
  333. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  334. // catch the problems when the expected method call is totally skipped during test run.
  335. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Optional() *mThingRepositoryMockGetByPlaceID {
  336. mmGetByPlaceID.optional = true
  337. return mmGetByPlaceID
  338. }
  339. // Expect sets up expected params for ThingRepository.GetByPlaceID
  340. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGetByPlaceID {
  341. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  342. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  343. }
  344. if mmGetByPlaceID.defaultExpectation == nil {
  345. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  346. }
  347. if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
  348. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
  349. }
  350. mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, id}
  351. for _, e := range mmGetByPlaceID.expectations {
  352. if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
  353. mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
  354. }
  355. }
  356. return mmGetByPlaceID
  357. }
  358. // ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetByPlaceID
  359. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetByPlaceID {
  360. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  361. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  362. }
  363. if mmGetByPlaceID.defaultExpectation == nil {
  364. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  365. }
  366. if mmGetByPlaceID.defaultExpectation.params != nil {
  367. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
  368. }
  369. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  370. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
  371. }
  372. mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
  373. return mmGetByPlaceID
  374. }
  375. // ExpectIdParam2 sets up expected param id for ThingRepository.GetByPlaceID
  376. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingRepositoryMockGetByPlaceID {
  377. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  378. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  379. }
  380. if mmGetByPlaceID.defaultExpectation == nil {
  381. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
  382. }
  383. if mmGetByPlaceID.defaultExpectation.params != nil {
  384. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
  385. }
  386. if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
  387. mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
  388. }
  389. mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
  390. return mmGetByPlaceID
  391. }
  392. // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
  393. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGetByPlaceID {
  394. if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
  395. mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
  396. }
  397. mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
  398. return mmGetByPlaceID
  399. }
  400. // Return sets up results that will be returned by ThingRepository.GetByPlaceID
  401. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
  402. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  403. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  404. }
  405. if mmGetByPlaceID.defaultExpectation == nil {
  406. mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
  407. }
  408. mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  409. return mmGetByPlaceID.mock
  410. }
  411. // Set uses given function f to mock the ThingRepository.GetByPlaceID method
  412. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
  413. if mmGetByPlaceID.defaultExpectation != nil {
  414. mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
  415. }
  416. if len(mmGetByPlaceID.expectations) > 0 {
  417. mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method")
  418. }
  419. mmGetByPlaceID.mock.funcGetByPlaceID = f
  420. return mmGetByPlaceID.mock
  421. }
  422. // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
  423. // Then helper
  424. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingRepositoryMockGetByPlaceIDExpectation {
  425. if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
  426. mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
  427. }
  428. expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
  429. mock: mmGetByPlaceID.mock,
  430. params: &ThingRepositoryMockGetByPlaceIDParams{ctx, id},
  431. }
  432. mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
  433. return expectation
  434. }
  435. // Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
  436. func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
  437. e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
  438. return e.mock
  439. }
  440. // Times sets number of times ThingRepository.GetByPlaceID should be invoked
  441. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Times(n uint64) *mThingRepositoryMockGetByPlaceID {
  442. if n == 0 {
  443. mmGetByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetByPlaceID mock can not be zero")
  444. }
  445. mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
  446. return mmGetByPlaceID
  447. }
  448. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) invocationsDone() bool {
  449. if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
  450. return true
  451. }
  452. totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
  453. expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)
  454. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  455. }
  456. // GetByPlaceID implements place.ThingRepository
  457. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ta1 []models.Thing, err error) {
  458. mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
  459. defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
  460. if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
  461. mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
  462. }
  463. mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, id}
  464. // Record call args
  465. mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
  466. mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
  467. mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
  468. for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
  469. if minimock.Equal(*e.params, mm_params) {
  470. mm_atomic.AddUint64(&e.Counter, 1)
  471. return e.results.ta1, e.results.err
  472. }
  473. }
  474. if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
  475. mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
  476. mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
  477. mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
  478. mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, id}
  479. if mm_want_ptrs != nil {
  480. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  481. mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  482. }
  483. if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
  484. mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
  485. }
  486. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  487. mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  488. }
  489. mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
  490. if mm_results == nil {
  491. mmGetByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetByPlaceID")
  492. }
  493. return (*mm_results).ta1, (*mm_results).err
  494. }
  495. if mmGetByPlaceID.funcGetByPlaceID != nil {
  496. return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
  497. }
  498. mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, id)
  499. return
  500. }
  501. // GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations
  502. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
  503. return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
  504. }
  505. // GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations
  506. func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
  507. return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
  508. }
  509. // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID.
  510. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  511. func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams {
  512. mmGetByPlaceID.mutex.RLock()
  513. argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
  514. copy(argCopy, mmGetByPlaceID.callArgs)
  515. mmGetByPlaceID.mutex.RUnlock()
  516. return argCopy
  517. }
  518. // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
  519. // the number of defined expectations
  520. func (m *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool {
  521. if m.GetByPlaceIDMock.optional {
  522. // Optional methods provide '0 or more' call count restriction.
  523. return true
  524. }
  525. for _, e := range m.GetByPlaceIDMock.expectations {
  526. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  527. return false
  528. }
  529. }
  530. return m.GetByPlaceIDMock.invocationsDone()
  531. }
  532. // MinimockGetByPlaceIDInspect logs each unmet expectation
  533. func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() {
  534. for _, e := range m.GetByPlaceIDMock.expectations {
  535. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  536. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params)
  537. }
  538. }
  539. afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
  540. // if default expectation was set then invocations count should be greater than zero
  541. if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
  542. if m.GetByPlaceIDMock.defaultExpectation.params == nil {
  543. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  544. } else {
  545. m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
  546. }
  547. }
  548. // if func was set then invocations count should be greater than zero
  549. if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
  550. m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
  551. }
  552. if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
  553. m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetByPlaceID but found %d calls",
  554. mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
  555. }
  556. }
  557. // MinimockFinish checks that all mocked methods have been called the expected number of times
  558. func (m *ThingRepositoryMock) MinimockFinish() {
  559. m.finishOnce.Do(func() {
  560. if !m.minimockDone() {
  561. m.MinimockDeleteInspect()
  562. m.MinimockGetByPlaceIDInspect()
  563. }
  564. })
  565. }
  566. // MinimockWait waits for all mocked methods to be called the expected number of times
  567. func (m *ThingRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  568. timeoutCh := mm_time.After(timeout)
  569. for {
  570. if m.minimockDone() {
  571. return
  572. }
  573. select {
  574. case <-timeoutCh:
  575. m.MinimockFinish()
  576. return
  577. case <-mm_time.After(10 * mm_time.Millisecond):
  578. }
  579. }
  580. }
  581. func (m *ThingRepositoryMock) minimockDone() bool {
  582. done := true
  583. return done &&
  584. m.MinimockDeleteDone() &&
  585. m.MinimockGetByPlaceIDDone()
  586. }