user_repository_minimock.go 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  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/user.UserRepository -o user_repository_minimock.go -n UserRepositoryMock -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. // UserRepositoryMock implements user.UserRepository
  13. type UserRepositoryMock struct {
  14. t minimock.Tester
  15. finishOnce sync.Once
  16. funcAdd func(ctx context.Context, username string, password string) (u1 uint64, err error)
  17. inspectFuncAdd func(ctx context.Context, username string, password string)
  18. afterAddCounter uint64
  19. beforeAddCounter uint64
  20. AddMock mUserRepositoryMockAdd
  21. funcGet func(ctx context.Context, username string) (up1 *models.User, err error)
  22. inspectFuncGet func(ctx context.Context, username string)
  23. afterGetCounter uint64
  24. beforeGetCounter uint64
  25. GetMock mUserRepositoryMockGet
  26. funcUpdate func(ctx context.Context, req models.UpdateUserRequest) (err error)
  27. inspectFuncUpdate func(ctx context.Context, req models.UpdateUserRequest)
  28. afterUpdateCounter uint64
  29. beforeUpdateCounter uint64
  30. UpdateMock mUserRepositoryMockUpdate
  31. }
  32. // NewUserRepositoryMock returns a mock for user.UserRepository
  33. func NewUserRepositoryMock(t minimock.Tester) *UserRepositoryMock {
  34. m := &UserRepositoryMock{t: t}
  35. if controller, ok := t.(minimock.MockController); ok {
  36. controller.RegisterMocker(m)
  37. }
  38. m.AddMock = mUserRepositoryMockAdd{mock: m}
  39. m.AddMock.callArgs = []*UserRepositoryMockAddParams{}
  40. m.GetMock = mUserRepositoryMockGet{mock: m}
  41. m.GetMock.callArgs = []*UserRepositoryMockGetParams{}
  42. m.UpdateMock = mUserRepositoryMockUpdate{mock: m}
  43. m.UpdateMock.callArgs = []*UserRepositoryMockUpdateParams{}
  44. t.Cleanup(m.MinimockFinish)
  45. return m
  46. }
  47. type mUserRepositoryMockAdd struct {
  48. optional bool
  49. mock *UserRepositoryMock
  50. defaultExpectation *UserRepositoryMockAddExpectation
  51. expectations []*UserRepositoryMockAddExpectation
  52. callArgs []*UserRepositoryMockAddParams
  53. mutex sync.RWMutex
  54. expectedInvocations uint64
  55. }
  56. // UserRepositoryMockAddExpectation specifies expectation struct of the UserRepository.Add
  57. type UserRepositoryMockAddExpectation struct {
  58. mock *UserRepositoryMock
  59. params *UserRepositoryMockAddParams
  60. paramPtrs *UserRepositoryMockAddParamPtrs
  61. results *UserRepositoryMockAddResults
  62. Counter uint64
  63. }
  64. // UserRepositoryMockAddParams contains parameters of the UserRepository.Add
  65. type UserRepositoryMockAddParams struct {
  66. ctx context.Context
  67. username string
  68. password string
  69. }
  70. // UserRepositoryMockAddParamPtrs contains pointers to parameters of the UserRepository.Add
  71. type UserRepositoryMockAddParamPtrs struct {
  72. ctx *context.Context
  73. username *string
  74. password *string
  75. }
  76. // UserRepositoryMockAddResults contains results of the UserRepository.Add
  77. type UserRepositoryMockAddResults struct {
  78. u1 uint64
  79. err error
  80. }
  81. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  82. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  83. // Optional() makes method check to work in '0 or more' mode.
  84. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  85. // catch the problems when the expected method call is totally skipped during test run.
  86. func (mmAdd *mUserRepositoryMockAdd) Optional() *mUserRepositoryMockAdd {
  87. mmAdd.optional = true
  88. return mmAdd
  89. }
  90. // Expect sets up expected params for UserRepository.Add
  91. func (mmAdd *mUserRepositoryMockAdd) Expect(ctx context.Context, username string, password string) *mUserRepositoryMockAdd {
  92. if mmAdd.mock.funcAdd != nil {
  93. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
  94. }
  95. if mmAdd.defaultExpectation == nil {
  96. mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{}
  97. }
  98. if mmAdd.defaultExpectation.paramPtrs != nil {
  99. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by ExpectParams functions")
  100. }
  101. mmAdd.defaultExpectation.params = &UserRepositoryMockAddParams{ctx, username, password}
  102. for _, e := range mmAdd.expectations {
  103. if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
  104. mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
  105. }
  106. }
  107. return mmAdd
  108. }
  109. // ExpectCtxParam1 sets up expected param ctx for UserRepository.Add
  110. func (mmAdd *mUserRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockAdd {
  111. if mmAdd.mock.funcAdd != nil {
  112. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
  113. }
  114. if mmAdd.defaultExpectation == nil {
  115. mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{}
  116. }
  117. if mmAdd.defaultExpectation.params != nil {
  118. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Expect")
  119. }
  120. if mmAdd.defaultExpectation.paramPtrs == nil {
  121. mmAdd.defaultExpectation.paramPtrs = &UserRepositoryMockAddParamPtrs{}
  122. }
  123. mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
  124. return mmAdd
  125. }
  126. // ExpectUsernameParam2 sets up expected param username for UserRepository.Add
  127. func (mmAdd *mUserRepositoryMockAdd) ExpectUsernameParam2(username string) *mUserRepositoryMockAdd {
  128. if mmAdd.mock.funcAdd != nil {
  129. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
  130. }
  131. if mmAdd.defaultExpectation == nil {
  132. mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{}
  133. }
  134. if mmAdd.defaultExpectation.params != nil {
  135. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Expect")
  136. }
  137. if mmAdd.defaultExpectation.paramPtrs == nil {
  138. mmAdd.defaultExpectation.paramPtrs = &UserRepositoryMockAddParamPtrs{}
  139. }
  140. mmAdd.defaultExpectation.paramPtrs.username = &username
  141. return mmAdd
  142. }
  143. // ExpectPasswordParam3 sets up expected param password for UserRepository.Add
  144. func (mmAdd *mUserRepositoryMockAdd) ExpectPasswordParam3(password string) *mUserRepositoryMockAdd {
  145. if mmAdd.mock.funcAdd != nil {
  146. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
  147. }
  148. if mmAdd.defaultExpectation == nil {
  149. mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{}
  150. }
  151. if mmAdd.defaultExpectation.params != nil {
  152. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Expect")
  153. }
  154. if mmAdd.defaultExpectation.paramPtrs == nil {
  155. mmAdd.defaultExpectation.paramPtrs = &UserRepositoryMockAddParamPtrs{}
  156. }
  157. mmAdd.defaultExpectation.paramPtrs.password = &password
  158. return mmAdd
  159. }
  160. // Inspect accepts an inspector function that has same arguments as the UserRepository.Add
  161. func (mmAdd *mUserRepositoryMockAdd) Inspect(f func(ctx context.Context, username string, password string)) *mUserRepositoryMockAdd {
  162. if mmAdd.mock.inspectFuncAdd != nil {
  163. mmAdd.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Add")
  164. }
  165. mmAdd.mock.inspectFuncAdd = f
  166. return mmAdd
  167. }
  168. // Return sets up results that will be returned by UserRepository.Add
  169. func (mmAdd *mUserRepositoryMockAdd) Return(u1 uint64, err error) *UserRepositoryMock {
  170. if mmAdd.mock.funcAdd != nil {
  171. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
  172. }
  173. if mmAdd.defaultExpectation == nil {
  174. mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{mock: mmAdd.mock}
  175. }
  176. mmAdd.defaultExpectation.results = &UserRepositoryMockAddResults{u1, err}
  177. return mmAdd.mock
  178. }
  179. // Set uses given function f to mock the UserRepository.Add method
  180. func (mmAdd *mUserRepositoryMockAdd) Set(f func(ctx context.Context, username string, password string) (u1 uint64, err error)) *UserRepositoryMock {
  181. if mmAdd.defaultExpectation != nil {
  182. mmAdd.mock.t.Fatalf("Default expectation is already set for the UserRepository.Add method")
  183. }
  184. if len(mmAdd.expectations) > 0 {
  185. mmAdd.mock.t.Fatalf("Some expectations are already set for the UserRepository.Add method")
  186. }
  187. mmAdd.mock.funcAdd = f
  188. return mmAdd.mock
  189. }
  190. // When sets expectation for the UserRepository.Add which will trigger the result defined by the following
  191. // Then helper
  192. func (mmAdd *mUserRepositoryMockAdd) When(ctx context.Context, username string, password string) *UserRepositoryMockAddExpectation {
  193. if mmAdd.mock.funcAdd != nil {
  194. mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
  195. }
  196. expectation := &UserRepositoryMockAddExpectation{
  197. mock: mmAdd.mock,
  198. params: &UserRepositoryMockAddParams{ctx, username, password},
  199. }
  200. mmAdd.expectations = append(mmAdd.expectations, expectation)
  201. return expectation
  202. }
  203. // Then sets up UserRepository.Add return parameters for the expectation previously defined by the When method
  204. func (e *UserRepositoryMockAddExpectation) Then(u1 uint64, err error) *UserRepositoryMock {
  205. e.results = &UserRepositoryMockAddResults{u1, err}
  206. return e.mock
  207. }
  208. // Times sets number of times UserRepository.Add should be invoked
  209. func (mmAdd *mUserRepositoryMockAdd) Times(n uint64) *mUserRepositoryMockAdd {
  210. if n == 0 {
  211. mmAdd.mock.t.Fatalf("Times of UserRepositoryMock.Add mock can not be zero")
  212. }
  213. mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
  214. return mmAdd
  215. }
  216. func (mmAdd *mUserRepositoryMockAdd) invocationsDone() bool {
  217. if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
  218. return true
  219. }
  220. totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
  221. expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
  222. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  223. }
  224. // Add implements user.UserRepository
  225. func (mmAdd *UserRepositoryMock) Add(ctx context.Context, username string, password string) (u1 uint64, err error) {
  226. mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
  227. defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
  228. if mmAdd.inspectFuncAdd != nil {
  229. mmAdd.inspectFuncAdd(ctx, username, password)
  230. }
  231. mm_params := UserRepositoryMockAddParams{ctx, username, password}
  232. // Record call args
  233. mmAdd.AddMock.mutex.Lock()
  234. mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
  235. mmAdd.AddMock.mutex.Unlock()
  236. for _, e := range mmAdd.AddMock.expectations {
  237. if minimock.Equal(*e.params, mm_params) {
  238. mm_atomic.AddUint64(&e.Counter, 1)
  239. return e.results.u1, e.results.err
  240. }
  241. }
  242. if mmAdd.AddMock.defaultExpectation != nil {
  243. mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
  244. mm_want := mmAdd.AddMock.defaultExpectation.params
  245. mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
  246. mm_got := UserRepositoryMockAddParams{ctx, username, password}
  247. if mm_want_ptrs != nil {
  248. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  249. mmAdd.t.Errorf("UserRepositoryMock.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))
  250. }
  251. if mm_want_ptrs.username != nil && !minimock.Equal(*mm_want_ptrs.username, mm_got.username) {
  252. mmAdd.t.Errorf("UserRepositoryMock.Add got unexpected parameter username, want: %#v, got: %#v%s\n", *mm_want_ptrs.username, mm_got.username, minimock.Diff(*mm_want_ptrs.username, mm_got.username))
  253. }
  254. if mm_want_ptrs.password != nil && !minimock.Equal(*mm_want_ptrs.password, mm_got.password) {
  255. mmAdd.t.Errorf("UserRepositoryMock.Add got unexpected parameter password, want: %#v, got: %#v%s\n", *mm_want_ptrs.password, mm_got.password, minimock.Diff(*mm_want_ptrs.password, mm_got.password))
  256. }
  257. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  258. mmAdd.t.Errorf("UserRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  259. }
  260. mm_results := mmAdd.AddMock.defaultExpectation.results
  261. if mm_results == nil {
  262. mmAdd.t.Fatal("No results are set for the UserRepositoryMock.Add")
  263. }
  264. return (*mm_results).u1, (*mm_results).err
  265. }
  266. if mmAdd.funcAdd != nil {
  267. return mmAdd.funcAdd(ctx, username, password)
  268. }
  269. mmAdd.t.Fatalf("Unexpected call to UserRepositoryMock.Add. %v %v %v", ctx, username, password)
  270. return
  271. }
  272. // AddAfterCounter returns a count of finished UserRepositoryMock.Add invocations
  273. func (mmAdd *UserRepositoryMock) AddAfterCounter() uint64 {
  274. return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
  275. }
  276. // AddBeforeCounter returns a count of UserRepositoryMock.Add invocations
  277. func (mmAdd *UserRepositoryMock) AddBeforeCounter() uint64 {
  278. return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
  279. }
  280. // Calls returns a list of arguments used in each call to UserRepositoryMock.Add.
  281. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  282. func (mmAdd *mUserRepositoryMockAdd) Calls() []*UserRepositoryMockAddParams {
  283. mmAdd.mutex.RLock()
  284. argCopy := make([]*UserRepositoryMockAddParams, len(mmAdd.callArgs))
  285. copy(argCopy, mmAdd.callArgs)
  286. mmAdd.mutex.RUnlock()
  287. return argCopy
  288. }
  289. // MinimockAddDone returns true if the count of the Add invocations corresponds
  290. // the number of defined expectations
  291. func (m *UserRepositoryMock) MinimockAddDone() bool {
  292. if m.AddMock.optional {
  293. // Optional methods provide '0 or more' call count restriction.
  294. return true
  295. }
  296. for _, e := range m.AddMock.expectations {
  297. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  298. return false
  299. }
  300. }
  301. return m.AddMock.invocationsDone()
  302. }
  303. // MinimockAddInspect logs each unmet expectation
  304. func (m *UserRepositoryMock) MinimockAddInspect() {
  305. for _, e := range m.AddMock.expectations {
  306. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  307. m.t.Errorf("Expected call to UserRepositoryMock.Add with params: %#v", *e.params)
  308. }
  309. }
  310. afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
  311. // if default expectation was set then invocations count should be greater than zero
  312. if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
  313. if m.AddMock.defaultExpectation.params == nil {
  314. m.t.Error("Expected call to UserRepositoryMock.Add")
  315. } else {
  316. m.t.Errorf("Expected call to UserRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
  317. }
  318. }
  319. // if func was set then invocations count should be greater than zero
  320. if m.funcAdd != nil && afterAddCounter < 1 {
  321. m.t.Error("Expected call to UserRepositoryMock.Add")
  322. }
  323. if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
  324. m.t.Errorf("Expected %d calls to UserRepositoryMock.Add but found %d calls",
  325. mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
  326. }
  327. }
  328. type mUserRepositoryMockGet struct {
  329. optional bool
  330. mock *UserRepositoryMock
  331. defaultExpectation *UserRepositoryMockGetExpectation
  332. expectations []*UserRepositoryMockGetExpectation
  333. callArgs []*UserRepositoryMockGetParams
  334. mutex sync.RWMutex
  335. expectedInvocations uint64
  336. }
  337. // UserRepositoryMockGetExpectation specifies expectation struct of the UserRepository.Get
  338. type UserRepositoryMockGetExpectation struct {
  339. mock *UserRepositoryMock
  340. params *UserRepositoryMockGetParams
  341. paramPtrs *UserRepositoryMockGetParamPtrs
  342. results *UserRepositoryMockGetResults
  343. Counter uint64
  344. }
  345. // UserRepositoryMockGetParams contains parameters of the UserRepository.Get
  346. type UserRepositoryMockGetParams struct {
  347. ctx context.Context
  348. username string
  349. }
  350. // UserRepositoryMockGetParamPtrs contains pointers to parameters of the UserRepository.Get
  351. type UserRepositoryMockGetParamPtrs struct {
  352. ctx *context.Context
  353. username *string
  354. }
  355. // UserRepositoryMockGetResults contains results of the UserRepository.Get
  356. type UserRepositoryMockGetResults struct {
  357. up1 *models.User
  358. err error
  359. }
  360. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  361. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  362. // Optional() makes method check to work in '0 or more' mode.
  363. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  364. // catch the problems when the expected method call is totally skipped during test run.
  365. func (mmGet *mUserRepositoryMockGet) Optional() *mUserRepositoryMockGet {
  366. mmGet.optional = true
  367. return mmGet
  368. }
  369. // Expect sets up expected params for UserRepository.Get
  370. func (mmGet *mUserRepositoryMockGet) Expect(ctx context.Context, username string) *mUserRepositoryMockGet {
  371. if mmGet.mock.funcGet != nil {
  372. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
  373. }
  374. if mmGet.defaultExpectation == nil {
  375. mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{}
  376. }
  377. if mmGet.defaultExpectation.paramPtrs != nil {
  378. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by ExpectParams functions")
  379. }
  380. mmGet.defaultExpectation.params = &UserRepositoryMockGetParams{ctx, username}
  381. for _, e := range mmGet.expectations {
  382. if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
  383. mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
  384. }
  385. }
  386. return mmGet
  387. }
  388. // ExpectCtxParam1 sets up expected param ctx for UserRepository.Get
  389. func (mmGet *mUserRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockGet {
  390. if mmGet.mock.funcGet != nil {
  391. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
  392. }
  393. if mmGet.defaultExpectation == nil {
  394. mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{}
  395. }
  396. if mmGet.defaultExpectation.params != nil {
  397. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Expect")
  398. }
  399. if mmGet.defaultExpectation.paramPtrs == nil {
  400. mmGet.defaultExpectation.paramPtrs = &UserRepositoryMockGetParamPtrs{}
  401. }
  402. mmGet.defaultExpectation.paramPtrs.ctx = &ctx
  403. return mmGet
  404. }
  405. // ExpectUsernameParam2 sets up expected param username for UserRepository.Get
  406. func (mmGet *mUserRepositoryMockGet) ExpectUsernameParam2(username string) *mUserRepositoryMockGet {
  407. if mmGet.mock.funcGet != nil {
  408. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
  409. }
  410. if mmGet.defaultExpectation == nil {
  411. mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{}
  412. }
  413. if mmGet.defaultExpectation.params != nil {
  414. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Expect")
  415. }
  416. if mmGet.defaultExpectation.paramPtrs == nil {
  417. mmGet.defaultExpectation.paramPtrs = &UserRepositoryMockGetParamPtrs{}
  418. }
  419. mmGet.defaultExpectation.paramPtrs.username = &username
  420. return mmGet
  421. }
  422. // Inspect accepts an inspector function that has same arguments as the UserRepository.Get
  423. func (mmGet *mUserRepositoryMockGet) Inspect(f func(ctx context.Context, username string)) *mUserRepositoryMockGet {
  424. if mmGet.mock.inspectFuncGet != nil {
  425. mmGet.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Get")
  426. }
  427. mmGet.mock.inspectFuncGet = f
  428. return mmGet
  429. }
  430. // Return sets up results that will be returned by UserRepository.Get
  431. func (mmGet *mUserRepositoryMockGet) Return(up1 *models.User, err error) *UserRepositoryMock {
  432. if mmGet.mock.funcGet != nil {
  433. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
  434. }
  435. if mmGet.defaultExpectation == nil {
  436. mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{mock: mmGet.mock}
  437. }
  438. mmGet.defaultExpectation.results = &UserRepositoryMockGetResults{up1, err}
  439. return mmGet.mock
  440. }
  441. // Set uses given function f to mock the UserRepository.Get method
  442. func (mmGet *mUserRepositoryMockGet) Set(f func(ctx context.Context, username string) (up1 *models.User, err error)) *UserRepositoryMock {
  443. if mmGet.defaultExpectation != nil {
  444. mmGet.mock.t.Fatalf("Default expectation is already set for the UserRepository.Get method")
  445. }
  446. if len(mmGet.expectations) > 0 {
  447. mmGet.mock.t.Fatalf("Some expectations are already set for the UserRepository.Get method")
  448. }
  449. mmGet.mock.funcGet = f
  450. return mmGet.mock
  451. }
  452. // When sets expectation for the UserRepository.Get which will trigger the result defined by the following
  453. // Then helper
  454. func (mmGet *mUserRepositoryMockGet) When(ctx context.Context, username string) *UserRepositoryMockGetExpectation {
  455. if mmGet.mock.funcGet != nil {
  456. mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
  457. }
  458. expectation := &UserRepositoryMockGetExpectation{
  459. mock: mmGet.mock,
  460. params: &UserRepositoryMockGetParams{ctx, username},
  461. }
  462. mmGet.expectations = append(mmGet.expectations, expectation)
  463. return expectation
  464. }
  465. // Then sets up UserRepository.Get return parameters for the expectation previously defined by the When method
  466. func (e *UserRepositoryMockGetExpectation) Then(up1 *models.User, err error) *UserRepositoryMock {
  467. e.results = &UserRepositoryMockGetResults{up1, err}
  468. return e.mock
  469. }
  470. // Times sets number of times UserRepository.Get should be invoked
  471. func (mmGet *mUserRepositoryMockGet) Times(n uint64) *mUserRepositoryMockGet {
  472. if n == 0 {
  473. mmGet.mock.t.Fatalf("Times of UserRepositoryMock.Get mock can not be zero")
  474. }
  475. mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
  476. return mmGet
  477. }
  478. func (mmGet *mUserRepositoryMockGet) invocationsDone() bool {
  479. if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
  480. return true
  481. }
  482. totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
  483. expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
  484. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  485. }
  486. // Get implements user.UserRepository
  487. func (mmGet *UserRepositoryMock) Get(ctx context.Context, username string) (up1 *models.User, err error) {
  488. mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
  489. defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
  490. if mmGet.inspectFuncGet != nil {
  491. mmGet.inspectFuncGet(ctx, username)
  492. }
  493. mm_params := UserRepositoryMockGetParams{ctx, username}
  494. // Record call args
  495. mmGet.GetMock.mutex.Lock()
  496. mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
  497. mmGet.GetMock.mutex.Unlock()
  498. for _, e := range mmGet.GetMock.expectations {
  499. if minimock.Equal(*e.params, mm_params) {
  500. mm_atomic.AddUint64(&e.Counter, 1)
  501. return e.results.up1, e.results.err
  502. }
  503. }
  504. if mmGet.GetMock.defaultExpectation != nil {
  505. mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
  506. mm_want := mmGet.GetMock.defaultExpectation.params
  507. mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
  508. mm_got := UserRepositoryMockGetParams{ctx, username}
  509. if mm_want_ptrs != nil {
  510. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  511. mmGet.t.Errorf("UserRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
  512. }
  513. if mm_want_ptrs.username != nil && !minimock.Equal(*mm_want_ptrs.username, mm_got.username) {
  514. mmGet.t.Errorf("UserRepositoryMock.Get got unexpected parameter username, want: %#v, got: %#v%s\n", *mm_want_ptrs.username, mm_got.username, minimock.Diff(*mm_want_ptrs.username, mm_got.username))
  515. }
  516. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  517. mmGet.t.Errorf("UserRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  518. }
  519. mm_results := mmGet.GetMock.defaultExpectation.results
  520. if mm_results == nil {
  521. mmGet.t.Fatal("No results are set for the UserRepositoryMock.Get")
  522. }
  523. return (*mm_results).up1, (*mm_results).err
  524. }
  525. if mmGet.funcGet != nil {
  526. return mmGet.funcGet(ctx, username)
  527. }
  528. mmGet.t.Fatalf("Unexpected call to UserRepositoryMock.Get. %v %v", ctx, username)
  529. return
  530. }
  531. // GetAfterCounter returns a count of finished UserRepositoryMock.Get invocations
  532. func (mmGet *UserRepositoryMock) GetAfterCounter() uint64 {
  533. return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
  534. }
  535. // GetBeforeCounter returns a count of UserRepositoryMock.Get invocations
  536. func (mmGet *UserRepositoryMock) GetBeforeCounter() uint64 {
  537. return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
  538. }
  539. // Calls returns a list of arguments used in each call to UserRepositoryMock.Get.
  540. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  541. func (mmGet *mUserRepositoryMockGet) Calls() []*UserRepositoryMockGetParams {
  542. mmGet.mutex.RLock()
  543. argCopy := make([]*UserRepositoryMockGetParams, len(mmGet.callArgs))
  544. copy(argCopy, mmGet.callArgs)
  545. mmGet.mutex.RUnlock()
  546. return argCopy
  547. }
  548. // MinimockGetDone returns true if the count of the Get invocations corresponds
  549. // the number of defined expectations
  550. func (m *UserRepositoryMock) MinimockGetDone() bool {
  551. if m.GetMock.optional {
  552. // Optional methods provide '0 or more' call count restriction.
  553. return true
  554. }
  555. for _, e := range m.GetMock.expectations {
  556. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  557. return false
  558. }
  559. }
  560. return m.GetMock.invocationsDone()
  561. }
  562. // MinimockGetInspect logs each unmet expectation
  563. func (m *UserRepositoryMock) MinimockGetInspect() {
  564. for _, e := range m.GetMock.expectations {
  565. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  566. m.t.Errorf("Expected call to UserRepositoryMock.Get with params: %#v", *e.params)
  567. }
  568. }
  569. afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
  570. // if default expectation was set then invocations count should be greater than zero
  571. if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
  572. if m.GetMock.defaultExpectation.params == nil {
  573. m.t.Error("Expected call to UserRepositoryMock.Get")
  574. } else {
  575. m.t.Errorf("Expected call to UserRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
  576. }
  577. }
  578. // if func was set then invocations count should be greater than zero
  579. if m.funcGet != nil && afterGetCounter < 1 {
  580. m.t.Error("Expected call to UserRepositoryMock.Get")
  581. }
  582. if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
  583. m.t.Errorf("Expected %d calls to UserRepositoryMock.Get but found %d calls",
  584. mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
  585. }
  586. }
  587. type mUserRepositoryMockUpdate struct {
  588. optional bool
  589. mock *UserRepositoryMock
  590. defaultExpectation *UserRepositoryMockUpdateExpectation
  591. expectations []*UserRepositoryMockUpdateExpectation
  592. callArgs []*UserRepositoryMockUpdateParams
  593. mutex sync.RWMutex
  594. expectedInvocations uint64
  595. }
  596. // UserRepositoryMockUpdateExpectation specifies expectation struct of the UserRepository.Update
  597. type UserRepositoryMockUpdateExpectation struct {
  598. mock *UserRepositoryMock
  599. params *UserRepositoryMockUpdateParams
  600. paramPtrs *UserRepositoryMockUpdateParamPtrs
  601. results *UserRepositoryMockUpdateResults
  602. Counter uint64
  603. }
  604. // UserRepositoryMockUpdateParams contains parameters of the UserRepository.Update
  605. type UserRepositoryMockUpdateParams struct {
  606. ctx context.Context
  607. req models.UpdateUserRequest
  608. }
  609. // UserRepositoryMockUpdateParamPtrs contains pointers to parameters of the UserRepository.Update
  610. type UserRepositoryMockUpdateParamPtrs struct {
  611. ctx *context.Context
  612. req *models.UpdateUserRequest
  613. }
  614. // UserRepositoryMockUpdateResults contains results of the UserRepository.Update
  615. type UserRepositoryMockUpdateResults struct {
  616. err error
  617. }
  618. // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
  619. // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
  620. // Optional() makes method check to work in '0 or more' mode.
  621. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
  622. // catch the problems when the expected method call is totally skipped during test run.
  623. func (mmUpdate *mUserRepositoryMockUpdate) Optional() *mUserRepositoryMockUpdate {
  624. mmUpdate.optional = true
  625. return mmUpdate
  626. }
  627. // Expect sets up expected params for UserRepository.Update
  628. func (mmUpdate *mUserRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateUserRequest) *mUserRepositoryMockUpdate {
  629. if mmUpdate.mock.funcUpdate != nil {
  630. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by Set")
  631. }
  632. if mmUpdate.defaultExpectation == nil {
  633. mmUpdate.defaultExpectation = &UserRepositoryMockUpdateExpectation{}
  634. }
  635. if mmUpdate.defaultExpectation.paramPtrs != nil {
  636. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by ExpectParams functions")
  637. }
  638. mmUpdate.defaultExpectation.params = &UserRepositoryMockUpdateParams{ctx, req}
  639. for _, e := range mmUpdate.expectations {
  640. if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
  641. mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
  642. }
  643. }
  644. return mmUpdate
  645. }
  646. // ExpectCtxParam1 sets up expected param ctx for UserRepository.Update
  647. func (mmUpdate *mUserRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockUpdate {
  648. if mmUpdate.mock.funcUpdate != nil {
  649. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by Set")
  650. }
  651. if mmUpdate.defaultExpectation == nil {
  652. mmUpdate.defaultExpectation = &UserRepositoryMockUpdateExpectation{}
  653. }
  654. if mmUpdate.defaultExpectation.params != nil {
  655. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by Expect")
  656. }
  657. if mmUpdate.defaultExpectation.paramPtrs == nil {
  658. mmUpdate.defaultExpectation.paramPtrs = &UserRepositoryMockUpdateParamPtrs{}
  659. }
  660. mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx
  661. return mmUpdate
  662. }
  663. // ExpectReqParam2 sets up expected param req for UserRepository.Update
  664. func (mmUpdate *mUserRepositoryMockUpdate) ExpectReqParam2(req models.UpdateUserRequest) *mUserRepositoryMockUpdate {
  665. if mmUpdate.mock.funcUpdate != nil {
  666. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by Set")
  667. }
  668. if mmUpdate.defaultExpectation == nil {
  669. mmUpdate.defaultExpectation = &UserRepositoryMockUpdateExpectation{}
  670. }
  671. if mmUpdate.defaultExpectation.params != nil {
  672. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by Expect")
  673. }
  674. if mmUpdate.defaultExpectation.paramPtrs == nil {
  675. mmUpdate.defaultExpectation.paramPtrs = &UserRepositoryMockUpdateParamPtrs{}
  676. }
  677. mmUpdate.defaultExpectation.paramPtrs.req = &req
  678. return mmUpdate
  679. }
  680. // Inspect accepts an inspector function that has same arguments as the UserRepository.Update
  681. func (mmUpdate *mUserRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateUserRequest)) *mUserRepositoryMockUpdate {
  682. if mmUpdate.mock.inspectFuncUpdate != nil {
  683. mmUpdate.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Update")
  684. }
  685. mmUpdate.mock.inspectFuncUpdate = f
  686. return mmUpdate
  687. }
  688. // Return sets up results that will be returned by UserRepository.Update
  689. func (mmUpdate *mUserRepositoryMockUpdate) Return(err error) *UserRepositoryMock {
  690. if mmUpdate.mock.funcUpdate != nil {
  691. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by Set")
  692. }
  693. if mmUpdate.defaultExpectation == nil {
  694. mmUpdate.defaultExpectation = &UserRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
  695. }
  696. mmUpdate.defaultExpectation.results = &UserRepositoryMockUpdateResults{err}
  697. return mmUpdate.mock
  698. }
  699. // Set uses given function f to mock the UserRepository.Update method
  700. func (mmUpdate *mUserRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateUserRequest) (err error)) *UserRepositoryMock {
  701. if mmUpdate.defaultExpectation != nil {
  702. mmUpdate.mock.t.Fatalf("Default expectation is already set for the UserRepository.Update method")
  703. }
  704. if len(mmUpdate.expectations) > 0 {
  705. mmUpdate.mock.t.Fatalf("Some expectations are already set for the UserRepository.Update method")
  706. }
  707. mmUpdate.mock.funcUpdate = f
  708. return mmUpdate.mock
  709. }
  710. // When sets expectation for the UserRepository.Update which will trigger the result defined by the following
  711. // Then helper
  712. func (mmUpdate *mUserRepositoryMockUpdate) When(ctx context.Context, req models.UpdateUserRequest) *UserRepositoryMockUpdateExpectation {
  713. if mmUpdate.mock.funcUpdate != nil {
  714. mmUpdate.mock.t.Fatalf("UserRepositoryMock.Update mock is already set by Set")
  715. }
  716. expectation := &UserRepositoryMockUpdateExpectation{
  717. mock: mmUpdate.mock,
  718. params: &UserRepositoryMockUpdateParams{ctx, req},
  719. }
  720. mmUpdate.expectations = append(mmUpdate.expectations, expectation)
  721. return expectation
  722. }
  723. // Then sets up UserRepository.Update return parameters for the expectation previously defined by the When method
  724. func (e *UserRepositoryMockUpdateExpectation) Then(err error) *UserRepositoryMock {
  725. e.results = &UserRepositoryMockUpdateResults{err}
  726. return e.mock
  727. }
  728. // Times sets number of times UserRepository.Update should be invoked
  729. func (mmUpdate *mUserRepositoryMockUpdate) Times(n uint64) *mUserRepositoryMockUpdate {
  730. if n == 0 {
  731. mmUpdate.mock.t.Fatalf("Times of UserRepositoryMock.Update mock can not be zero")
  732. }
  733. mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
  734. return mmUpdate
  735. }
  736. func (mmUpdate *mUserRepositoryMockUpdate) invocationsDone() bool {
  737. if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
  738. return true
  739. }
  740. totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
  741. expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)
  742. return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
  743. }
  744. // Update implements user.UserRepository
  745. func (mmUpdate *UserRepositoryMock) Update(ctx context.Context, req models.UpdateUserRequest) (err error) {
  746. mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
  747. defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
  748. if mmUpdate.inspectFuncUpdate != nil {
  749. mmUpdate.inspectFuncUpdate(ctx, req)
  750. }
  751. mm_params := UserRepositoryMockUpdateParams{ctx, req}
  752. // Record call args
  753. mmUpdate.UpdateMock.mutex.Lock()
  754. mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, &mm_params)
  755. mmUpdate.UpdateMock.mutex.Unlock()
  756. for _, e := range mmUpdate.UpdateMock.expectations {
  757. if minimock.Equal(*e.params, mm_params) {
  758. mm_atomic.AddUint64(&e.Counter, 1)
  759. return e.results.err
  760. }
  761. }
  762. if mmUpdate.UpdateMock.defaultExpectation != nil {
  763. mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
  764. mm_want := mmUpdate.UpdateMock.defaultExpectation.params
  765. mm_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs
  766. mm_got := UserRepositoryMockUpdateParams{ctx, req}
  767. if mm_want_ptrs != nil {
  768. if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
  769. mmUpdate.t.Errorf("UserRepositoryMock.Update 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))
  770. }
  771. if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
  772. mmUpdate.t.Errorf("UserRepositoryMock.Update 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))
  773. }
  774. } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
  775. mmUpdate.t.Errorf("UserRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
  776. }
  777. mm_results := mmUpdate.UpdateMock.defaultExpectation.results
  778. if mm_results == nil {
  779. mmUpdate.t.Fatal("No results are set for the UserRepositoryMock.Update")
  780. }
  781. return (*mm_results).err
  782. }
  783. if mmUpdate.funcUpdate != nil {
  784. return mmUpdate.funcUpdate(ctx, req)
  785. }
  786. mmUpdate.t.Fatalf("Unexpected call to UserRepositoryMock.Update. %v %v", ctx, req)
  787. return
  788. }
  789. // UpdateAfterCounter returns a count of finished UserRepositoryMock.Update invocations
  790. func (mmUpdate *UserRepositoryMock) UpdateAfterCounter() uint64 {
  791. return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
  792. }
  793. // UpdateBeforeCounter returns a count of UserRepositoryMock.Update invocations
  794. func (mmUpdate *UserRepositoryMock) UpdateBeforeCounter() uint64 {
  795. return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
  796. }
  797. // Calls returns a list of arguments used in each call to UserRepositoryMock.Update.
  798. // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
  799. func (mmUpdate *mUserRepositoryMockUpdate) Calls() []*UserRepositoryMockUpdateParams {
  800. mmUpdate.mutex.RLock()
  801. argCopy := make([]*UserRepositoryMockUpdateParams, len(mmUpdate.callArgs))
  802. copy(argCopy, mmUpdate.callArgs)
  803. mmUpdate.mutex.RUnlock()
  804. return argCopy
  805. }
  806. // MinimockUpdateDone returns true if the count of the Update invocations corresponds
  807. // the number of defined expectations
  808. func (m *UserRepositoryMock) MinimockUpdateDone() bool {
  809. if m.UpdateMock.optional {
  810. // Optional methods provide '0 or more' call count restriction.
  811. return true
  812. }
  813. for _, e := range m.UpdateMock.expectations {
  814. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  815. return false
  816. }
  817. }
  818. return m.UpdateMock.invocationsDone()
  819. }
  820. // MinimockUpdateInspect logs each unmet expectation
  821. func (m *UserRepositoryMock) MinimockUpdateInspect() {
  822. for _, e := range m.UpdateMock.expectations {
  823. if mm_atomic.LoadUint64(&e.Counter) < 1 {
  824. m.t.Errorf("Expected call to UserRepositoryMock.Update with params: %#v", *e.params)
  825. }
  826. }
  827. afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
  828. // if default expectation was set then invocations count should be greater than zero
  829. if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
  830. if m.UpdateMock.defaultExpectation.params == nil {
  831. m.t.Error("Expected call to UserRepositoryMock.Update")
  832. } else {
  833. m.t.Errorf("Expected call to UserRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
  834. }
  835. }
  836. // if func was set then invocations count should be greater than zero
  837. if m.funcUpdate != nil && afterUpdateCounter < 1 {
  838. m.t.Error("Expected call to UserRepositoryMock.Update")
  839. }
  840. if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
  841. m.t.Errorf("Expected %d calls to UserRepositoryMock.Update but found %d calls",
  842. mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
  843. }
  844. }
  845. // MinimockFinish checks that all mocked methods have been called the expected number of times
  846. func (m *UserRepositoryMock) MinimockFinish() {
  847. m.finishOnce.Do(func() {
  848. if !m.minimockDone() {
  849. m.MinimockAddInspect()
  850. m.MinimockGetInspect()
  851. m.MinimockUpdateInspect()
  852. }
  853. })
  854. }
  855. // MinimockWait waits for all mocked methods to be called the expected number of times
  856. func (m *UserRepositoryMock) MinimockWait(timeout mm_time.Duration) {
  857. timeoutCh := mm_time.After(timeout)
  858. for {
  859. if m.minimockDone() {
  860. return
  861. }
  862. select {
  863. case <-timeoutCh:
  864. m.MinimockFinish()
  865. return
  866. case <-mm_time.After(10 * mm_time.Millisecond):
  867. }
  868. }
  869. }
  870. func (m *UserRepositoryMock) minimockDone() bool {
  871. done := true
  872. return done &&
  873. m.MinimockAddDone() &&
  874. m.MinimockGetDone() &&
  875. m.MinimockUpdateDone()
  876. }