123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671 |
- // Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
- package mocks
- //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/user.AuthService -o auth_service_minimock.go -n AuthServiceMock -p mocks
- import (
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "github.com/gofiber/fiber/v2"
- "github.com/gojuno/minimock/v3"
- "github.com/golang-jwt/jwt/v4"
- )
- // AuthServiceMock implements user.AuthService
- type AuthServiceMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcGeneratePasswordHash func(password string) (s1 string, err error)
- inspectFuncGeneratePasswordHash func(password string)
- afterGeneratePasswordHashCounter uint64
- beforeGeneratePasswordHashCounter uint64
- GeneratePasswordHashMock mAuthServiceMockGeneratePasswordHash
- funcGetClaims func(fctx *fiber.Ctx) (m1 jwt.MapClaims)
- inspectFuncGetClaims func(fctx *fiber.Ctx)
- afterGetClaimsCounter uint64
- beforeGetClaimsCounter uint64
- GetClaimsMock mAuthServiceMockGetClaims
- }
- // NewAuthServiceMock returns a mock for user.AuthService
- func NewAuthServiceMock(t minimock.Tester) *AuthServiceMock {
- m := &AuthServiceMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.GeneratePasswordHashMock = mAuthServiceMockGeneratePasswordHash{mock: m}
- m.GeneratePasswordHashMock.callArgs = []*AuthServiceMockGeneratePasswordHashParams{}
- m.GetClaimsMock = mAuthServiceMockGetClaims{mock: m}
- m.GetClaimsMock.callArgs = []*AuthServiceMockGetClaimsParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mAuthServiceMockGeneratePasswordHash struct {
- optional bool
- mock *AuthServiceMock
- defaultExpectation *AuthServiceMockGeneratePasswordHashExpectation
- expectations []*AuthServiceMockGeneratePasswordHashExpectation
- callArgs []*AuthServiceMockGeneratePasswordHashParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // AuthServiceMockGeneratePasswordHashExpectation specifies expectation struct of the AuthService.GeneratePasswordHash
- type AuthServiceMockGeneratePasswordHashExpectation struct {
- mock *AuthServiceMock
- params *AuthServiceMockGeneratePasswordHashParams
- paramPtrs *AuthServiceMockGeneratePasswordHashParamPtrs
- results *AuthServiceMockGeneratePasswordHashResults
- Counter uint64
- }
- // AuthServiceMockGeneratePasswordHashParams contains parameters of the AuthService.GeneratePasswordHash
- type AuthServiceMockGeneratePasswordHashParams struct {
- password string
- }
- // AuthServiceMockGeneratePasswordHashParamPtrs contains pointers to parameters of the AuthService.GeneratePasswordHash
- type AuthServiceMockGeneratePasswordHashParamPtrs struct {
- password *string
- }
- // AuthServiceMockGeneratePasswordHashResults contains results of the AuthService.GeneratePasswordHash
- type AuthServiceMockGeneratePasswordHashResults struct {
- s1 string
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) Optional() *mAuthServiceMockGeneratePasswordHash {
- mmGeneratePasswordHash.optional = true
- return mmGeneratePasswordHash
- }
- // Expect sets up expected params for AuthService.GeneratePasswordHash
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) Expect(password string) *mAuthServiceMockGeneratePasswordHash {
- if mmGeneratePasswordHash.mock.funcGeneratePasswordHash != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("AuthServiceMock.GeneratePasswordHash mock is already set by Set")
- }
- if mmGeneratePasswordHash.defaultExpectation == nil {
- mmGeneratePasswordHash.defaultExpectation = &AuthServiceMockGeneratePasswordHashExpectation{}
- }
- if mmGeneratePasswordHash.defaultExpectation.paramPtrs != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("AuthServiceMock.GeneratePasswordHash mock is already set by ExpectParams functions")
- }
- mmGeneratePasswordHash.defaultExpectation.params = &AuthServiceMockGeneratePasswordHashParams{password}
- for _, e := range mmGeneratePasswordHash.expectations {
- if minimock.Equal(e.params, mmGeneratePasswordHash.defaultExpectation.params) {
- mmGeneratePasswordHash.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGeneratePasswordHash.defaultExpectation.params)
- }
- }
- return mmGeneratePasswordHash
- }
- // ExpectPasswordParam1 sets up expected param password for AuthService.GeneratePasswordHash
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) ExpectPasswordParam1(password string) *mAuthServiceMockGeneratePasswordHash {
- if mmGeneratePasswordHash.mock.funcGeneratePasswordHash != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("AuthServiceMock.GeneratePasswordHash mock is already set by Set")
- }
- if mmGeneratePasswordHash.defaultExpectation == nil {
- mmGeneratePasswordHash.defaultExpectation = &AuthServiceMockGeneratePasswordHashExpectation{}
- }
- if mmGeneratePasswordHash.defaultExpectation.params != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("AuthServiceMock.GeneratePasswordHash mock is already set by Expect")
- }
- if mmGeneratePasswordHash.defaultExpectation.paramPtrs == nil {
- mmGeneratePasswordHash.defaultExpectation.paramPtrs = &AuthServiceMockGeneratePasswordHashParamPtrs{}
- }
- mmGeneratePasswordHash.defaultExpectation.paramPtrs.password = &password
- return mmGeneratePasswordHash
- }
- // Inspect accepts an inspector function that has same arguments as the AuthService.GeneratePasswordHash
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) Inspect(f func(password string)) *mAuthServiceMockGeneratePasswordHash {
- if mmGeneratePasswordHash.mock.inspectFuncGeneratePasswordHash != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.GeneratePasswordHash")
- }
- mmGeneratePasswordHash.mock.inspectFuncGeneratePasswordHash = f
- return mmGeneratePasswordHash
- }
- // Return sets up results that will be returned by AuthService.GeneratePasswordHash
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) Return(s1 string, err error) *AuthServiceMock {
- if mmGeneratePasswordHash.mock.funcGeneratePasswordHash != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("AuthServiceMock.GeneratePasswordHash mock is already set by Set")
- }
- if mmGeneratePasswordHash.defaultExpectation == nil {
- mmGeneratePasswordHash.defaultExpectation = &AuthServiceMockGeneratePasswordHashExpectation{mock: mmGeneratePasswordHash.mock}
- }
- mmGeneratePasswordHash.defaultExpectation.results = &AuthServiceMockGeneratePasswordHashResults{s1, err}
- return mmGeneratePasswordHash.mock
- }
- // Set uses given function f to mock the AuthService.GeneratePasswordHash method
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) Set(f func(password string) (s1 string, err error)) *AuthServiceMock {
- if mmGeneratePasswordHash.defaultExpectation != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("Default expectation is already set for the AuthService.GeneratePasswordHash method")
- }
- if len(mmGeneratePasswordHash.expectations) > 0 {
- mmGeneratePasswordHash.mock.t.Fatalf("Some expectations are already set for the AuthService.GeneratePasswordHash method")
- }
- mmGeneratePasswordHash.mock.funcGeneratePasswordHash = f
- return mmGeneratePasswordHash.mock
- }
- // When sets expectation for the AuthService.GeneratePasswordHash which will trigger the result defined by the following
- // Then helper
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) When(password string) *AuthServiceMockGeneratePasswordHashExpectation {
- if mmGeneratePasswordHash.mock.funcGeneratePasswordHash != nil {
- mmGeneratePasswordHash.mock.t.Fatalf("AuthServiceMock.GeneratePasswordHash mock is already set by Set")
- }
- expectation := &AuthServiceMockGeneratePasswordHashExpectation{
- mock: mmGeneratePasswordHash.mock,
- params: &AuthServiceMockGeneratePasswordHashParams{password},
- }
- mmGeneratePasswordHash.expectations = append(mmGeneratePasswordHash.expectations, expectation)
- return expectation
- }
- // Then sets up AuthService.GeneratePasswordHash return parameters for the expectation previously defined by the When method
- func (e *AuthServiceMockGeneratePasswordHashExpectation) Then(s1 string, err error) *AuthServiceMock {
- e.results = &AuthServiceMockGeneratePasswordHashResults{s1, err}
- return e.mock
- }
- // Times sets number of times AuthService.GeneratePasswordHash should be invoked
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) Times(n uint64) *mAuthServiceMockGeneratePasswordHash {
- if n == 0 {
- mmGeneratePasswordHash.mock.t.Fatalf("Times of AuthServiceMock.GeneratePasswordHash mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGeneratePasswordHash.expectedInvocations, n)
- return mmGeneratePasswordHash
- }
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) invocationsDone() bool {
- if len(mmGeneratePasswordHash.expectations) == 0 && mmGeneratePasswordHash.defaultExpectation == nil && mmGeneratePasswordHash.mock.funcGeneratePasswordHash == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGeneratePasswordHash.mock.afterGeneratePasswordHashCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGeneratePasswordHash.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GeneratePasswordHash implements user.AuthService
- func (mmGeneratePasswordHash *AuthServiceMock) GeneratePasswordHash(password string) (s1 string, err error) {
- mm_atomic.AddUint64(&mmGeneratePasswordHash.beforeGeneratePasswordHashCounter, 1)
- defer mm_atomic.AddUint64(&mmGeneratePasswordHash.afterGeneratePasswordHashCounter, 1)
- if mmGeneratePasswordHash.inspectFuncGeneratePasswordHash != nil {
- mmGeneratePasswordHash.inspectFuncGeneratePasswordHash(password)
- }
- mm_params := AuthServiceMockGeneratePasswordHashParams{password}
- // Record call args
- mmGeneratePasswordHash.GeneratePasswordHashMock.mutex.Lock()
- mmGeneratePasswordHash.GeneratePasswordHashMock.callArgs = append(mmGeneratePasswordHash.GeneratePasswordHashMock.callArgs, &mm_params)
- mmGeneratePasswordHash.GeneratePasswordHashMock.mutex.Unlock()
- for _, e := range mmGeneratePasswordHash.GeneratePasswordHashMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.s1, e.results.err
- }
- }
- if mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation.Counter, 1)
- mm_want := mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation.params
- mm_want_ptrs := mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation.paramPtrs
- mm_got := AuthServiceMockGeneratePasswordHashParams{password}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.password != nil && !minimock.Equal(*mm_want_ptrs.password, mm_got.password) {
- 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))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGeneratePasswordHash.t.Errorf("AuthServiceMock.GeneratePasswordHash got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation.results
- if mm_results == nil {
- mmGeneratePasswordHash.t.Fatal("No results are set for the AuthServiceMock.GeneratePasswordHash")
- }
- return (*mm_results).s1, (*mm_results).err
- }
- if mmGeneratePasswordHash.funcGeneratePasswordHash != nil {
- return mmGeneratePasswordHash.funcGeneratePasswordHash(password)
- }
- mmGeneratePasswordHash.t.Fatalf("Unexpected call to AuthServiceMock.GeneratePasswordHash. %v", password)
- return
- }
- // GeneratePasswordHashAfterCounter returns a count of finished AuthServiceMock.GeneratePasswordHash invocations
- func (mmGeneratePasswordHash *AuthServiceMock) GeneratePasswordHashAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGeneratePasswordHash.afterGeneratePasswordHashCounter)
- }
- // GeneratePasswordHashBeforeCounter returns a count of AuthServiceMock.GeneratePasswordHash invocations
- func (mmGeneratePasswordHash *AuthServiceMock) GeneratePasswordHashBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGeneratePasswordHash.beforeGeneratePasswordHashCounter)
- }
- // Calls returns a list of arguments used in each call to AuthServiceMock.GeneratePasswordHash.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGeneratePasswordHash *mAuthServiceMockGeneratePasswordHash) Calls() []*AuthServiceMockGeneratePasswordHashParams {
- mmGeneratePasswordHash.mutex.RLock()
- argCopy := make([]*AuthServiceMockGeneratePasswordHashParams, len(mmGeneratePasswordHash.callArgs))
- copy(argCopy, mmGeneratePasswordHash.callArgs)
- mmGeneratePasswordHash.mutex.RUnlock()
- return argCopy
- }
- // MinimockGeneratePasswordHashDone returns true if the count of the GeneratePasswordHash invocations corresponds
- // the number of defined expectations
- func (m *AuthServiceMock) MinimockGeneratePasswordHashDone() bool {
- if m.GeneratePasswordHashMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GeneratePasswordHashMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GeneratePasswordHashMock.invocationsDone()
- }
- // MinimockGeneratePasswordHashInspect logs each unmet expectation
- func (m *AuthServiceMock) MinimockGeneratePasswordHashInspect() {
- for _, e := range m.GeneratePasswordHashMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to AuthServiceMock.GeneratePasswordHash with params: %#v", *e.params)
- }
- }
- afterGeneratePasswordHashCounter := mm_atomic.LoadUint64(&m.afterGeneratePasswordHashCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GeneratePasswordHashMock.defaultExpectation != nil && afterGeneratePasswordHashCounter < 1 {
- if m.GeneratePasswordHashMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to AuthServiceMock.GeneratePasswordHash")
- } else {
- m.t.Errorf("Expected call to AuthServiceMock.GeneratePasswordHash with params: %#v", *m.GeneratePasswordHashMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGeneratePasswordHash != nil && afterGeneratePasswordHashCounter < 1 {
- m.t.Error("Expected call to AuthServiceMock.GeneratePasswordHash")
- }
- if !m.GeneratePasswordHashMock.invocationsDone() && afterGeneratePasswordHashCounter > 0 {
- m.t.Errorf("Expected %d calls to AuthServiceMock.GeneratePasswordHash but found %d calls",
- mm_atomic.LoadUint64(&m.GeneratePasswordHashMock.expectedInvocations), afterGeneratePasswordHashCounter)
- }
- }
- type mAuthServiceMockGetClaims struct {
- optional bool
- mock *AuthServiceMock
- defaultExpectation *AuthServiceMockGetClaimsExpectation
- expectations []*AuthServiceMockGetClaimsExpectation
- callArgs []*AuthServiceMockGetClaimsParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // AuthServiceMockGetClaimsExpectation specifies expectation struct of the AuthService.GetClaims
- type AuthServiceMockGetClaimsExpectation struct {
- mock *AuthServiceMock
- params *AuthServiceMockGetClaimsParams
- paramPtrs *AuthServiceMockGetClaimsParamPtrs
- results *AuthServiceMockGetClaimsResults
- Counter uint64
- }
- // AuthServiceMockGetClaimsParams contains parameters of the AuthService.GetClaims
- type AuthServiceMockGetClaimsParams struct {
- fctx *fiber.Ctx
- }
- // AuthServiceMockGetClaimsParamPtrs contains pointers to parameters of the AuthService.GetClaims
- type AuthServiceMockGetClaimsParamPtrs struct {
- fctx **fiber.Ctx
- }
- // AuthServiceMockGetClaimsResults contains results of the AuthService.GetClaims
- type AuthServiceMockGetClaimsResults struct {
- m1 jwt.MapClaims
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmGetClaims *mAuthServiceMockGetClaims) Optional() *mAuthServiceMockGetClaims {
- mmGetClaims.optional = true
- return mmGetClaims
- }
- // Expect sets up expected params for AuthService.GetClaims
- func (mmGetClaims *mAuthServiceMockGetClaims) Expect(fctx *fiber.Ctx) *mAuthServiceMockGetClaims {
- if mmGetClaims.mock.funcGetClaims != nil {
- mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Set")
- }
- if mmGetClaims.defaultExpectation == nil {
- mmGetClaims.defaultExpectation = &AuthServiceMockGetClaimsExpectation{}
- }
- if mmGetClaims.defaultExpectation.paramPtrs != nil {
- mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by ExpectParams functions")
- }
- mmGetClaims.defaultExpectation.params = &AuthServiceMockGetClaimsParams{fctx}
- for _, e := range mmGetClaims.expectations {
- if minimock.Equal(e.params, mmGetClaims.defaultExpectation.params) {
- mmGetClaims.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetClaims.defaultExpectation.params)
- }
- }
- return mmGetClaims
- }
- // ExpectFctxParam1 sets up expected param fctx for AuthService.GetClaims
- func (mmGetClaims *mAuthServiceMockGetClaims) ExpectFctxParam1(fctx *fiber.Ctx) *mAuthServiceMockGetClaims {
- if mmGetClaims.mock.funcGetClaims != nil {
- mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Set")
- }
- if mmGetClaims.defaultExpectation == nil {
- mmGetClaims.defaultExpectation = &AuthServiceMockGetClaimsExpectation{}
- }
- if mmGetClaims.defaultExpectation.params != nil {
- mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Expect")
- }
- if mmGetClaims.defaultExpectation.paramPtrs == nil {
- mmGetClaims.defaultExpectation.paramPtrs = &AuthServiceMockGetClaimsParamPtrs{}
- }
- mmGetClaims.defaultExpectation.paramPtrs.fctx = &fctx
- return mmGetClaims
- }
- // Inspect accepts an inspector function that has same arguments as the AuthService.GetClaims
- func (mmGetClaims *mAuthServiceMockGetClaims) Inspect(f func(fctx *fiber.Ctx)) *mAuthServiceMockGetClaims {
- if mmGetClaims.mock.inspectFuncGetClaims != nil {
- mmGetClaims.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.GetClaims")
- }
- mmGetClaims.mock.inspectFuncGetClaims = f
- return mmGetClaims
- }
- // Return sets up results that will be returned by AuthService.GetClaims
- func (mmGetClaims *mAuthServiceMockGetClaims) Return(m1 jwt.MapClaims) *AuthServiceMock {
- if mmGetClaims.mock.funcGetClaims != nil {
- mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Set")
- }
- if mmGetClaims.defaultExpectation == nil {
- mmGetClaims.defaultExpectation = &AuthServiceMockGetClaimsExpectation{mock: mmGetClaims.mock}
- }
- mmGetClaims.defaultExpectation.results = &AuthServiceMockGetClaimsResults{m1}
- return mmGetClaims.mock
- }
- // Set uses given function f to mock the AuthService.GetClaims method
- func (mmGetClaims *mAuthServiceMockGetClaims) Set(f func(fctx *fiber.Ctx) (m1 jwt.MapClaims)) *AuthServiceMock {
- if mmGetClaims.defaultExpectation != nil {
- mmGetClaims.mock.t.Fatalf("Default expectation is already set for the AuthService.GetClaims method")
- }
- if len(mmGetClaims.expectations) > 0 {
- mmGetClaims.mock.t.Fatalf("Some expectations are already set for the AuthService.GetClaims method")
- }
- mmGetClaims.mock.funcGetClaims = f
- return mmGetClaims.mock
- }
- // When sets expectation for the AuthService.GetClaims which will trigger the result defined by the following
- // Then helper
- func (mmGetClaims *mAuthServiceMockGetClaims) When(fctx *fiber.Ctx) *AuthServiceMockGetClaimsExpectation {
- if mmGetClaims.mock.funcGetClaims != nil {
- mmGetClaims.mock.t.Fatalf("AuthServiceMock.GetClaims mock is already set by Set")
- }
- expectation := &AuthServiceMockGetClaimsExpectation{
- mock: mmGetClaims.mock,
- params: &AuthServiceMockGetClaimsParams{fctx},
- }
- mmGetClaims.expectations = append(mmGetClaims.expectations, expectation)
- return expectation
- }
- // Then sets up AuthService.GetClaims return parameters for the expectation previously defined by the When method
- func (e *AuthServiceMockGetClaimsExpectation) Then(m1 jwt.MapClaims) *AuthServiceMock {
- e.results = &AuthServiceMockGetClaimsResults{m1}
- return e.mock
- }
- // Times sets number of times AuthService.GetClaims should be invoked
- func (mmGetClaims *mAuthServiceMockGetClaims) Times(n uint64) *mAuthServiceMockGetClaims {
- if n == 0 {
- mmGetClaims.mock.t.Fatalf("Times of AuthServiceMock.GetClaims mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetClaims.expectedInvocations, n)
- return mmGetClaims
- }
- func (mmGetClaims *mAuthServiceMockGetClaims) invocationsDone() bool {
- if len(mmGetClaims.expectations) == 0 && mmGetClaims.defaultExpectation == nil && mmGetClaims.mock.funcGetClaims == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetClaims.mock.afterGetClaimsCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetClaims.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetClaims implements user.AuthService
- func (mmGetClaims *AuthServiceMock) GetClaims(fctx *fiber.Ctx) (m1 jwt.MapClaims) {
- mm_atomic.AddUint64(&mmGetClaims.beforeGetClaimsCounter, 1)
- defer mm_atomic.AddUint64(&mmGetClaims.afterGetClaimsCounter, 1)
- if mmGetClaims.inspectFuncGetClaims != nil {
- mmGetClaims.inspectFuncGetClaims(fctx)
- }
- mm_params := AuthServiceMockGetClaimsParams{fctx}
- // Record call args
- mmGetClaims.GetClaimsMock.mutex.Lock()
- mmGetClaims.GetClaimsMock.callArgs = append(mmGetClaims.GetClaimsMock.callArgs, &mm_params)
- mmGetClaims.GetClaimsMock.mutex.Unlock()
- for _, e := range mmGetClaims.GetClaimsMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.m1
- }
- }
- if mmGetClaims.GetClaimsMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetClaims.GetClaimsMock.defaultExpectation.Counter, 1)
- mm_want := mmGetClaims.GetClaimsMock.defaultExpectation.params
- mm_want_ptrs := mmGetClaims.GetClaimsMock.defaultExpectation.paramPtrs
- mm_got := AuthServiceMockGetClaimsParams{fctx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.fctx != nil && !minimock.Equal(*mm_want_ptrs.fctx, mm_got.fctx) {
- 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))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGetClaims.t.Errorf("AuthServiceMock.GetClaims got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetClaims.GetClaimsMock.defaultExpectation.results
- if mm_results == nil {
- mmGetClaims.t.Fatal("No results are set for the AuthServiceMock.GetClaims")
- }
- return (*mm_results).m1
- }
- if mmGetClaims.funcGetClaims != nil {
- return mmGetClaims.funcGetClaims(fctx)
- }
- mmGetClaims.t.Fatalf("Unexpected call to AuthServiceMock.GetClaims. %v", fctx)
- return
- }
- // GetClaimsAfterCounter returns a count of finished AuthServiceMock.GetClaims invocations
- func (mmGetClaims *AuthServiceMock) GetClaimsAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetClaims.afterGetClaimsCounter)
- }
- // GetClaimsBeforeCounter returns a count of AuthServiceMock.GetClaims invocations
- func (mmGetClaims *AuthServiceMock) GetClaimsBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetClaims.beforeGetClaimsCounter)
- }
- // Calls returns a list of arguments used in each call to AuthServiceMock.GetClaims.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetClaims *mAuthServiceMockGetClaims) Calls() []*AuthServiceMockGetClaimsParams {
- mmGetClaims.mutex.RLock()
- argCopy := make([]*AuthServiceMockGetClaimsParams, len(mmGetClaims.callArgs))
- copy(argCopy, mmGetClaims.callArgs)
- mmGetClaims.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetClaimsDone returns true if the count of the GetClaims invocations corresponds
- // the number of defined expectations
- func (m *AuthServiceMock) MinimockGetClaimsDone() bool {
- if m.GetClaimsMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetClaimsMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetClaimsMock.invocationsDone()
- }
- // MinimockGetClaimsInspect logs each unmet expectation
- func (m *AuthServiceMock) MinimockGetClaimsInspect() {
- for _, e := range m.GetClaimsMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to AuthServiceMock.GetClaims with params: %#v", *e.params)
- }
- }
- afterGetClaimsCounter := mm_atomic.LoadUint64(&m.afterGetClaimsCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetClaimsMock.defaultExpectation != nil && afterGetClaimsCounter < 1 {
- if m.GetClaimsMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to AuthServiceMock.GetClaims")
- } else {
- m.t.Errorf("Expected call to AuthServiceMock.GetClaims with params: %#v", *m.GetClaimsMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetClaims != nil && afterGetClaimsCounter < 1 {
- m.t.Error("Expected call to AuthServiceMock.GetClaims")
- }
- if !m.GetClaimsMock.invocationsDone() && afterGetClaimsCounter > 0 {
- m.t.Errorf("Expected %d calls to AuthServiceMock.GetClaims but found %d calls",
- mm_atomic.LoadUint64(&m.GetClaimsMock.expectedInvocations), afterGetClaimsCounter)
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *AuthServiceMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockGeneratePasswordHashInspect()
- m.MinimockGetClaimsInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *AuthServiceMock) MinimockWait(timeout mm_time.Duration) {
- timeoutCh := mm_time.After(timeout)
- for {
- if m.minimockDone() {
- return
- }
- select {
- case <-timeoutCh:
- m.MinimockFinish()
- return
- case <-mm_time.After(10 * mm_time.Millisecond):
- }
- }
- }
- func (m *AuthServiceMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockGeneratePasswordHashDone() &&
- m.MinimockGetClaimsDone()
- }
|