auth_service_minimock.go 27 KB

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