auth_service_minimock.go 40 KB

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