2551 lines
116 KiB
Go
2551 lines
116 KiB
Go
// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT.
|
|
|
|
package mocks
|
|
|
|
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/repository.SessionRepository -o session_repository_mock.go -n SessionRepositoryMock -p mocks
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
mm_atomic "sync/atomic"
|
|
mm_time "time"
|
|
|
|
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
|
"github.com/gojuno/minimock/v3"
|
|
)
|
|
|
|
// SessionRepositoryMock implements mm_repository.SessionRepository
|
|
type SessionRepositoryMock struct {
|
|
t minimock.Tester
|
|
finishOnce sync.Once
|
|
|
|
funcCreate func(ctx context.Context, session *model.Session) (err error)
|
|
funcCreateOrigin string
|
|
inspectFuncCreate func(ctx context.Context, session *model.Session)
|
|
afterCreateCounter uint64
|
|
beforeCreateCounter uint64
|
|
CreateMock mSessionRepositoryMockCreate
|
|
|
|
funcDeleteExpired func(ctx context.Context) (i1 int, err error)
|
|
funcDeleteExpiredOrigin string
|
|
inspectFuncDeleteExpired func(ctx context.Context)
|
|
afterDeleteExpiredCounter uint64
|
|
beforeDeleteExpiredCounter uint64
|
|
DeleteExpiredMock mSessionRepositoryMockDeleteExpired
|
|
|
|
funcFindByRefreshToken func(ctx context.Context, token string) (sp1 *model.Session, err error)
|
|
funcFindByRefreshTokenOrigin string
|
|
inspectFuncFindByRefreshToken func(ctx context.Context, token string)
|
|
afterFindByRefreshTokenCounter uint64
|
|
beforeFindByRefreshTokenCounter uint64
|
|
FindByRefreshTokenMock mSessionRepositoryMockFindByRefreshToken
|
|
|
|
funcIsAccessTokenValid func(ctx context.Context, accessToken string) (b1 bool, err error)
|
|
funcIsAccessTokenValidOrigin string
|
|
inspectFuncIsAccessTokenValid func(ctx context.Context, accessToken string)
|
|
afterIsAccessTokenValidCounter uint64
|
|
beforeIsAccessTokenValidCounter uint64
|
|
IsAccessTokenValidMock mSessionRepositoryMockIsAccessTokenValid
|
|
|
|
funcRevoke func(ctx context.Context, refreshToken string) (err error)
|
|
funcRevokeOrigin string
|
|
inspectFuncRevoke func(ctx context.Context, refreshToken string)
|
|
afterRevokeCounter uint64
|
|
beforeRevokeCounter uint64
|
|
RevokeMock mSessionRepositoryMockRevoke
|
|
|
|
funcRevokeByAccessToken func(ctx context.Context, accessToken string) (err error)
|
|
funcRevokeByAccessTokenOrigin string
|
|
inspectFuncRevokeByAccessToken func(ctx context.Context, accessToken string)
|
|
afterRevokeByAccessTokenCounter uint64
|
|
beforeRevokeByAccessTokenCounter uint64
|
|
RevokeByAccessTokenMock mSessionRepositoryMockRevokeByAccessToken
|
|
|
|
funcUpdateAccessToken func(ctx context.Context, refreshToken string, newAccessToken string) (err error)
|
|
funcUpdateAccessTokenOrigin string
|
|
inspectFuncUpdateAccessToken func(ctx context.Context, refreshToken string, newAccessToken string)
|
|
afterUpdateAccessTokenCounter uint64
|
|
beforeUpdateAccessTokenCounter uint64
|
|
UpdateAccessTokenMock mSessionRepositoryMockUpdateAccessToken
|
|
}
|
|
|
|
// NewSessionRepositoryMock returns a mock for mm_repository.SessionRepository
|
|
func NewSessionRepositoryMock(t minimock.Tester) *SessionRepositoryMock {
|
|
m := &SessionRepositoryMock{t: t}
|
|
|
|
if controller, ok := t.(minimock.MockController); ok {
|
|
controller.RegisterMocker(m)
|
|
}
|
|
|
|
m.CreateMock = mSessionRepositoryMockCreate{mock: m}
|
|
m.CreateMock.callArgs = []*SessionRepositoryMockCreateParams{}
|
|
|
|
m.DeleteExpiredMock = mSessionRepositoryMockDeleteExpired{mock: m}
|
|
m.DeleteExpiredMock.callArgs = []*SessionRepositoryMockDeleteExpiredParams{}
|
|
|
|
m.FindByRefreshTokenMock = mSessionRepositoryMockFindByRefreshToken{mock: m}
|
|
m.FindByRefreshTokenMock.callArgs = []*SessionRepositoryMockFindByRefreshTokenParams{}
|
|
|
|
m.IsAccessTokenValidMock = mSessionRepositoryMockIsAccessTokenValid{mock: m}
|
|
m.IsAccessTokenValidMock.callArgs = []*SessionRepositoryMockIsAccessTokenValidParams{}
|
|
|
|
m.RevokeMock = mSessionRepositoryMockRevoke{mock: m}
|
|
m.RevokeMock.callArgs = []*SessionRepositoryMockRevokeParams{}
|
|
|
|
m.RevokeByAccessTokenMock = mSessionRepositoryMockRevokeByAccessToken{mock: m}
|
|
m.RevokeByAccessTokenMock.callArgs = []*SessionRepositoryMockRevokeByAccessTokenParams{}
|
|
|
|
m.UpdateAccessTokenMock = mSessionRepositoryMockUpdateAccessToken{mock: m}
|
|
m.UpdateAccessTokenMock.callArgs = []*SessionRepositoryMockUpdateAccessTokenParams{}
|
|
|
|
t.Cleanup(m.MinimockFinish)
|
|
|
|
return m
|
|
}
|
|
|
|
type mSessionRepositoryMockCreate struct {
|
|
optional bool
|
|
mock *SessionRepositoryMock
|
|
defaultExpectation *SessionRepositoryMockCreateExpectation
|
|
expectations []*SessionRepositoryMockCreateExpectation
|
|
|
|
callArgs []*SessionRepositoryMockCreateParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// SessionRepositoryMockCreateExpectation specifies expectation struct of the SessionRepository.Create
|
|
type SessionRepositoryMockCreateExpectation struct {
|
|
mock *SessionRepositoryMock
|
|
params *SessionRepositoryMockCreateParams
|
|
paramPtrs *SessionRepositoryMockCreateParamPtrs
|
|
expectationOrigins SessionRepositoryMockCreateExpectationOrigins
|
|
results *SessionRepositoryMockCreateResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// SessionRepositoryMockCreateParams contains parameters of the SessionRepository.Create
|
|
type SessionRepositoryMockCreateParams struct {
|
|
ctx context.Context
|
|
session *model.Session
|
|
}
|
|
|
|
// SessionRepositoryMockCreateParamPtrs contains pointers to parameters of the SessionRepository.Create
|
|
type SessionRepositoryMockCreateParamPtrs struct {
|
|
ctx *context.Context
|
|
session **model.Session
|
|
}
|
|
|
|
// SessionRepositoryMockCreateResults contains results of the SessionRepository.Create
|
|
type SessionRepositoryMockCreateResults struct {
|
|
err error
|
|
}
|
|
|
|
// SessionRepositoryMockCreateOrigins contains origins of expectations of the SessionRepository.Create
|
|
type SessionRepositoryMockCreateExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originSession string
|
|
}
|
|
|
|
// 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 (mmCreate *mSessionRepositoryMockCreate) Optional() *mSessionRepositoryMockCreate {
|
|
mmCreate.optional = true
|
|
return mmCreate
|
|
}
|
|
|
|
// Expect sets up expected params for SessionRepository.Create
|
|
func (mmCreate *mSessionRepositoryMockCreate) Expect(ctx context.Context, session *model.Session) *mSessionRepositoryMockCreate {
|
|
if mmCreate.mock.funcCreate != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set")
|
|
}
|
|
|
|
if mmCreate.defaultExpectation == nil {
|
|
mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{}
|
|
}
|
|
|
|
if mmCreate.defaultExpectation.paramPtrs != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmCreate.defaultExpectation.params = &SessionRepositoryMockCreateParams{ctx, session}
|
|
mmCreate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmCreate.expectations {
|
|
if minimock.Equal(e.params, mmCreate.defaultExpectation.params) {
|
|
mmCreate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreate.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmCreate
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.Create
|
|
func (mmCreate *mSessionRepositoryMockCreate) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockCreate {
|
|
if mmCreate.mock.funcCreate != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set")
|
|
}
|
|
|
|
if mmCreate.defaultExpectation == nil {
|
|
mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{}
|
|
}
|
|
|
|
if mmCreate.defaultExpectation.params != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Expect")
|
|
}
|
|
|
|
if mmCreate.defaultExpectation.paramPtrs == nil {
|
|
mmCreate.defaultExpectation.paramPtrs = &SessionRepositoryMockCreateParamPtrs{}
|
|
}
|
|
mmCreate.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmCreate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmCreate
|
|
}
|
|
|
|
// ExpectSessionParam2 sets up expected param session for SessionRepository.Create
|
|
func (mmCreate *mSessionRepositoryMockCreate) ExpectSessionParam2(session *model.Session) *mSessionRepositoryMockCreate {
|
|
if mmCreate.mock.funcCreate != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set")
|
|
}
|
|
|
|
if mmCreate.defaultExpectation == nil {
|
|
mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{}
|
|
}
|
|
|
|
if mmCreate.defaultExpectation.params != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Expect")
|
|
}
|
|
|
|
if mmCreate.defaultExpectation.paramPtrs == nil {
|
|
mmCreate.defaultExpectation.paramPtrs = &SessionRepositoryMockCreateParamPtrs{}
|
|
}
|
|
mmCreate.defaultExpectation.paramPtrs.session = &session
|
|
mmCreate.defaultExpectation.expectationOrigins.originSession = minimock.CallerInfo(1)
|
|
|
|
return mmCreate
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the SessionRepository.Create
|
|
func (mmCreate *mSessionRepositoryMockCreate) Inspect(f func(ctx context.Context, session *model.Session)) *mSessionRepositoryMockCreate {
|
|
if mmCreate.mock.inspectFuncCreate != nil {
|
|
mmCreate.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.Create")
|
|
}
|
|
|
|
mmCreate.mock.inspectFuncCreate = f
|
|
|
|
return mmCreate
|
|
}
|
|
|
|
// Return sets up results that will be returned by SessionRepository.Create
|
|
func (mmCreate *mSessionRepositoryMockCreate) Return(err error) *SessionRepositoryMock {
|
|
if mmCreate.mock.funcCreate != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set")
|
|
}
|
|
|
|
if mmCreate.defaultExpectation == nil {
|
|
mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{mock: mmCreate.mock}
|
|
}
|
|
mmCreate.defaultExpectation.results = &SessionRepositoryMockCreateResults{err}
|
|
mmCreate.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmCreate.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the SessionRepository.Create method
|
|
func (mmCreate *mSessionRepositoryMockCreate) Set(f func(ctx context.Context, session *model.Session) (err error)) *SessionRepositoryMock {
|
|
if mmCreate.defaultExpectation != nil {
|
|
mmCreate.mock.t.Fatalf("Default expectation is already set for the SessionRepository.Create method")
|
|
}
|
|
|
|
if len(mmCreate.expectations) > 0 {
|
|
mmCreate.mock.t.Fatalf("Some expectations are already set for the SessionRepository.Create method")
|
|
}
|
|
|
|
mmCreate.mock.funcCreate = f
|
|
mmCreate.mock.funcCreateOrigin = minimock.CallerInfo(1)
|
|
return mmCreate.mock
|
|
}
|
|
|
|
// When sets expectation for the SessionRepository.Create which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmCreate *mSessionRepositoryMockCreate) When(ctx context.Context, session *model.Session) *SessionRepositoryMockCreateExpectation {
|
|
if mmCreate.mock.funcCreate != nil {
|
|
mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set")
|
|
}
|
|
|
|
expectation := &SessionRepositoryMockCreateExpectation{
|
|
mock: mmCreate.mock,
|
|
params: &SessionRepositoryMockCreateParams{ctx, session},
|
|
expectationOrigins: SessionRepositoryMockCreateExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmCreate.expectations = append(mmCreate.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up SessionRepository.Create return parameters for the expectation previously defined by the When method
|
|
func (e *SessionRepositoryMockCreateExpectation) Then(err error) *SessionRepositoryMock {
|
|
e.results = &SessionRepositoryMockCreateResults{err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times SessionRepository.Create should be invoked
|
|
func (mmCreate *mSessionRepositoryMockCreate) Times(n uint64) *mSessionRepositoryMockCreate {
|
|
if n == 0 {
|
|
mmCreate.mock.t.Fatalf("Times of SessionRepositoryMock.Create mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmCreate.expectedInvocations, n)
|
|
mmCreate.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmCreate
|
|
}
|
|
|
|
func (mmCreate *mSessionRepositoryMockCreate) invocationsDone() bool {
|
|
if len(mmCreate.expectations) == 0 && mmCreate.defaultExpectation == nil && mmCreate.mock.funcCreate == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmCreate.mock.afterCreateCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmCreate.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// Create implements mm_repository.SessionRepository
|
|
func (mmCreate *SessionRepositoryMock) Create(ctx context.Context, session *model.Session) (err error) {
|
|
mm_atomic.AddUint64(&mmCreate.beforeCreateCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmCreate.afterCreateCounter, 1)
|
|
|
|
mmCreate.t.Helper()
|
|
|
|
if mmCreate.inspectFuncCreate != nil {
|
|
mmCreate.inspectFuncCreate(ctx, session)
|
|
}
|
|
|
|
mm_params := SessionRepositoryMockCreateParams{ctx, session}
|
|
|
|
// Record call args
|
|
mmCreate.CreateMock.mutex.Lock()
|
|
mmCreate.CreateMock.callArgs = append(mmCreate.CreateMock.callArgs, &mm_params)
|
|
mmCreate.CreateMock.mutex.Unlock()
|
|
|
|
for _, e := range mmCreate.CreateMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.err
|
|
}
|
|
}
|
|
|
|
if mmCreate.CreateMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmCreate.CreateMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmCreate.CreateMock.defaultExpectation.params
|
|
mm_want_ptrs := mmCreate.CreateMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := SessionRepositoryMockCreateParams{ctx, session}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmCreate.t.Errorf("SessionRepositoryMock.Create got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmCreate.CreateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.session != nil && !minimock.Equal(*mm_want_ptrs.session, mm_got.session) {
|
|
mmCreate.t.Errorf("SessionRepositoryMock.Create got unexpected parameter session, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmCreate.CreateMock.defaultExpectation.expectationOrigins.originSession, *mm_want_ptrs.session, mm_got.session, minimock.Diff(*mm_want_ptrs.session, mm_got.session))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmCreate.t.Errorf("SessionRepositoryMock.Create got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmCreate.CreateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmCreate.CreateMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmCreate.t.Fatal("No results are set for the SessionRepositoryMock.Create")
|
|
}
|
|
return (*mm_results).err
|
|
}
|
|
if mmCreate.funcCreate != nil {
|
|
return mmCreate.funcCreate(ctx, session)
|
|
}
|
|
mmCreate.t.Fatalf("Unexpected call to SessionRepositoryMock.Create. %v %v", ctx, session)
|
|
return
|
|
}
|
|
|
|
// CreateAfterCounter returns a count of finished SessionRepositoryMock.Create invocations
|
|
func (mmCreate *SessionRepositoryMock) CreateAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmCreate.afterCreateCounter)
|
|
}
|
|
|
|
// CreateBeforeCounter returns a count of SessionRepositoryMock.Create invocations
|
|
func (mmCreate *SessionRepositoryMock) CreateBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmCreate.beforeCreateCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to SessionRepositoryMock.Create.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmCreate *mSessionRepositoryMockCreate) Calls() []*SessionRepositoryMockCreateParams {
|
|
mmCreate.mutex.RLock()
|
|
|
|
argCopy := make([]*SessionRepositoryMockCreateParams, len(mmCreate.callArgs))
|
|
copy(argCopy, mmCreate.callArgs)
|
|
|
|
mmCreate.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockCreateDone returns true if the count of the Create invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *SessionRepositoryMock) MinimockCreateDone() bool {
|
|
if m.CreateMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.CreateMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.CreateMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockCreateInspect logs each unmet expectation
|
|
func (m *SessionRepositoryMock) MinimockCreateInspect() {
|
|
for _, e := range m.CreateMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterCreateCounter := mm_atomic.LoadUint64(&m.afterCreateCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.CreateMock.defaultExpectation != nil && afterCreateCounter < 1 {
|
|
if m.CreateMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s", m.CreateMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s with params: %#v", m.CreateMock.defaultExpectation.expectationOrigins.origin, *m.CreateMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcCreate != nil && afterCreateCounter < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s", m.funcCreateOrigin)
|
|
}
|
|
|
|
if !m.CreateMock.invocationsDone() && afterCreateCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to SessionRepositoryMock.Create at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.CreateMock.expectedInvocations), m.CreateMock.expectedInvocationsOrigin, afterCreateCounter)
|
|
}
|
|
}
|
|
|
|
type mSessionRepositoryMockDeleteExpired struct {
|
|
optional bool
|
|
mock *SessionRepositoryMock
|
|
defaultExpectation *SessionRepositoryMockDeleteExpiredExpectation
|
|
expectations []*SessionRepositoryMockDeleteExpiredExpectation
|
|
|
|
callArgs []*SessionRepositoryMockDeleteExpiredParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// SessionRepositoryMockDeleteExpiredExpectation specifies expectation struct of the SessionRepository.DeleteExpired
|
|
type SessionRepositoryMockDeleteExpiredExpectation struct {
|
|
mock *SessionRepositoryMock
|
|
params *SessionRepositoryMockDeleteExpiredParams
|
|
paramPtrs *SessionRepositoryMockDeleteExpiredParamPtrs
|
|
expectationOrigins SessionRepositoryMockDeleteExpiredExpectationOrigins
|
|
results *SessionRepositoryMockDeleteExpiredResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// SessionRepositoryMockDeleteExpiredParams contains parameters of the SessionRepository.DeleteExpired
|
|
type SessionRepositoryMockDeleteExpiredParams struct {
|
|
ctx context.Context
|
|
}
|
|
|
|
// SessionRepositoryMockDeleteExpiredParamPtrs contains pointers to parameters of the SessionRepository.DeleteExpired
|
|
type SessionRepositoryMockDeleteExpiredParamPtrs struct {
|
|
ctx *context.Context
|
|
}
|
|
|
|
// SessionRepositoryMockDeleteExpiredResults contains results of the SessionRepository.DeleteExpired
|
|
type SessionRepositoryMockDeleteExpiredResults struct {
|
|
i1 int
|
|
err error
|
|
}
|
|
|
|
// SessionRepositoryMockDeleteExpiredOrigins contains origins of expectations of the SessionRepository.DeleteExpired
|
|
type SessionRepositoryMockDeleteExpiredExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
}
|
|
|
|
// 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 (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Optional() *mSessionRepositoryMockDeleteExpired {
|
|
mmDeleteExpired.optional = true
|
|
return mmDeleteExpired
|
|
}
|
|
|
|
// Expect sets up expected params for SessionRepository.DeleteExpired
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Expect(ctx context.Context) *mSessionRepositoryMockDeleteExpired {
|
|
if mmDeleteExpired.mock.funcDeleteExpired != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set")
|
|
}
|
|
|
|
if mmDeleteExpired.defaultExpectation == nil {
|
|
mmDeleteExpired.defaultExpectation = &SessionRepositoryMockDeleteExpiredExpectation{}
|
|
}
|
|
|
|
if mmDeleteExpired.defaultExpectation.paramPtrs != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmDeleteExpired.defaultExpectation.params = &SessionRepositoryMockDeleteExpiredParams{ctx}
|
|
mmDeleteExpired.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmDeleteExpired.expectations {
|
|
if minimock.Equal(e.params, mmDeleteExpired.defaultExpectation.params) {
|
|
mmDeleteExpired.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteExpired.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmDeleteExpired
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.DeleteExpired
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockDeleteExpired {
|
|
if mmDeleteExpired.mock.funcDeleteExpired != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set")
|
|
}
|
|
|
|
if mmDeleteExpired.defaultExpectation == nil {
|
|
mmDeleteExpired.defaultExpectation = &SessionRepositoryMockDeleteExpiredExpectation{}
|
|
}
|
|
|
|
if mmDeleteExpired.defaultExpectation.params != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Expect")
|
|
}
|
|
|
|
if mmDeleteExpired.defaultExpectation.paramPtrs == nil {
|
|
mmDeleteExpired.defaultExpectation.paramPtrs = &SessionRepositoryMockDeleteExpiredParamPtrs{}
|
|
}
|
|
mmDeleteExpired.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmDeleteExpired.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmDeleteExpired
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the SessionRepository.DeleteExpired
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Inspect(f func(ctx context.Context)) *mSessionRepositoryMockDeleteExpired {
|
|
if mmDeleteExpired.mock.inspectFuncDeleteExpired != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.DeleteExpired")
|
|
}
|
|
|
|
mmDeleteExpired.mock.inspectFuncDeleteExpired = f
|
|
|
|
return mmDeleteExpired
|
|
}
|
|
|
|
// Return sets up results that will be returned by SessionRepository.DeleteExpired
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Return(i1 int, err error) *SessionRepositoryMock {
|
|
if mmDeleteExpired.mock.funcDeleteExpired != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set")
|
|
}
|
|
|
|
if mmDeleteExpired.defaultExpectation == nil {
|
|
mmDeleteExpired.defaultExpectation = &SessionRepositoryMockDeleteExpiredExpectation{mock: mmDeleteExpired.mock}
|
|
}
|
|
mmDeleteExpired.defaultExpectation.results = &SessionRepositoryMockDeleteExpiredResults{i1, err}
|
|
mmDeleteExpired.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmDeleteExpired.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the SessionRepository.DeleteExpired method
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Set(f func(ctx context.Context) (i1 int, err error)) *SessionRepositoryMock {
|
|
if mmDeleteExpired.defaultExpectation != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("Default expectation is already set for the SessionRepository.DeleteExpired method")
|
|
}
|
|
|
|
if len(mmDeleteExpired.expectations) > 0 {
|
|
mmDeleteExpired.mock.t.Fatalf("Some expectations are already set for the SessionRepository.DeleteExpired method")
|
|
}
|
|
|
|
mmDeleteExpired.mock.funcDeleteExpired = f
|
|
mmDeleteExpired.mock.funcDeleteExpiredOrigin = minimock.CallerInfo(1)
|
|
return mmDeleteExpired.mock
|
|
}
|
|
|
|
// When sets expectation for the SessionRepository.DeleteExpired which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) When(ctx context.Context) *SessionRepositoryMockDeleteExpiredExpectation {
|
|
if mmDeleteExpired.mock.funcDeleteExpired != nil {
|
|
mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set")
|
|
}
|
|
|
|
expectation := &SessionRepositoryMockDeleteExpiredExpectation{
|
|
mock: mmDeleteExpired.mock,
|
|
params: &SessionRepositoryMockDeleteExpiredParams{ctx},
|
|
expectationOrigins: SessionRepositoryMockDeleteExpiredExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmDeleteExpired.expectations = append(mmDeleteExpired.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up SessionRepository.DeleteExpired return parameters for the expectation previously defined by the When method
|
|
func (e *SessionRepositoryMockDeleteExpiredExpectation) Then(i1 int, err error) *SessionRepositoryMock {
|
|
e.results = &SessionRepositoryMockDeleteExpiredResults{i1, err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times SessionRepository.DeleteExpired should be invoked
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Times(n uint64) *mSessionRepositoryMockDeleteExpired {
|
|
if n == 0 {
|
|
mmDeleteExpired.mock.t.Fatalf("Times of SessionRepositoryMock.DeleteExpired mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmDeleteExpired.expectedInvocations, n)
|
|
mmDeleteExpired.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmDeleteExpired
|
|
}
|
|
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) invocationsDone() bool {
|
|
if len(mmDeleteExpired.expectations) == 0 && mmDeleteExpired.defaultExpectation == nil && mmDeleteExpired.mock.funcDeleteExpired == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmDeleteExpired.mock.afterDeleteExpiredCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmDeleteExpired.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// DeleteExpired implements mm_repository.SessionRepository
|
|
func (mmDeleteExpired *SessionRepositoryMock) DeleteExpired(ctx context.Context) (i1 int, err error) {
|
|
mm_atomic.AddUint64(&mmDeleteExpired.beforeDeleteExpiredCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmDeleteExpired.afterDeleteExpiredCounter, 1)
|
|
|
|
mmDeleteExpired.t.Helper()
|
|
|
|
if mmDeleteExpired.inspectFuncDeleteExpired != nil {
|
|
mmDeleteExpired.inspectFuncDeleteExpired(ctx)
|
|
}
|
|
|
|
mm_params := SessionRepositoryMockDeleteExpiredParams{ctx}
|
|
|
|
// Record call args
|
|
mmDeleteExpired.DeleteExpiredMock.mutex.Lock()
|
|
mmDeleteExpired.DeleteExpiredMock.callArgs = append(mmDeleteExpired.DeleteExpiredMock.callArgs, &mm_params)
|
|
mmDeleteExpired.DeleteExpiredMock.mutex.Unlock()
|
|
|
|
for _, e := range mmDeleteExpired.DeleteExpiredMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.i1, e.results.err
|
|
}
|
|
}
|
|
|
|
if mmDeleteExpired.DeleteExpiredMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmDeleteExpired.DeleteExpiredMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmDeleteExpired.DeleteExpiredMock.defaultExpectation.params
|
|
mm_want_ptrs := mmDeleteExpired.DeleteExpiredMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := SessionRepositoryMockDeleteExpiredParams{ctx}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmDeleteExpired.t.Errorf("SessionRepositoryMock.DeleteExpired got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmDeleteExpired.DeleteExpiredMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmDeleteExpired.t.Errorf("SessionRepositoryMock.DeleteExpired got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmDeleteExpired.DeleteExpiredMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmDeleteExpired.DeleteExpiredMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmDeleteExpired.t.Fatal("No results are set for the SessionRepositoryMock.DeleteExpired")
|
|
}
|
|
return (*mm_results).i1, (*mm_results).err
|
|
}
|
|
if mmDeleteExpired.funcDeleteExpired != nil {
|
|
return mmDeleteExpired.funcDeleteExpired(ctx)
|
|
}
|
|
mmDeleteExpired.t.Fatalf("Unexpected call to SessionRepositoryMock.DeleteExpired. %v", ctx)
|
|
return
|
|
}
|
|
|
|
// DeleteExpiredAfterCounter returns a count of finished SessionRepositoryMock.DeleteExpired invocations
|
|
func (mmDeleteExpired *SessionRepositoryMock) DeleteExpiredAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmDeleteExpired.afterDeleteExpiredCounter)
|
|
}
|
|
|
|
// DeleteExpiredBeforeCounter returns a count of SessionRepositoryMock.DeleteExpired invocations
|
|
func (mmDeleteExpired *SessionRepositoryMock) DeleteExpiredBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmDeleteExpired.beforeDeleteExpiredCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to SessionRepositoryMock.DeleteExpired.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Calls() []*SessionRepositoryMockDeleteExpiredParams {
|
|
mmDeleteExpired.mutex.RLock()
|
|
|
|
argCopy := make([]*SessionRepositoryMockDeleteExpiredParams, len(mmDeleteExpired.callArgs))
|
|
copy(argCopy, mmDeleteExpired.callArgs)
|
|
|
|
mmDeleteExpired.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockDeleteExpiredDone returns true if the count of the DeleteExpired invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *SessionRepositoryMock) MinimockDeleteExpiredDone() bool {
|
|
if m.DeleteExpiredMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.DeleteExpiredMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.DeleteExpiredMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockDeleteExpiredInspect logs each unmet expectation
|
|
func (m *SessionRepositoryMock) MinimockDeleteExpiredInspect() {
|
|
for _, e := range m.DeleteExpiredMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterDeleteExpiredCounter := mm_atomic.LoadUint64(&m.afterDeleteExpiredCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.DeleteExpiredMock.defaultExpectation != nil && afterDeleteExpiredCounter < 1 {
|
|
if m.DeleteExpiredMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s", m.DeleteExpiredMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s with params: %#v", m.DeleteExpiredMock.defaultExpectation.expectationOrigins.origin, *m.DeleteExpiredMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcDeleteExpired != nil && afterDeleteExpiredCounter < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s", m.funcDeleteExpiredOrigin)
|
|
}
|
|
|
|
if !m.DeleteExpiredMock.invocationsDone() && afterDeleteExpiredCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to SessionRepositoryMock.DeleteExpired at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.DeleteExpiredMock.expectedInvocations), m.DeleteExpiredMock.expectedInvocationsOrigin, afterDeleteExpiredCounter)
|
|
}
|
|
}
|
|
|
|
type mSessionRepositoryMockFindByRefreshToken struct {
|
|
optional bool
|
|
mock *SessionRepositoryMock
|
|
defaultExpectation *SessionRepositoryMockFindByRefreshTokenExpectation
|
|
expectations []*SessionRepositoryMockFindByRefreshTokenExpectation
|
|
|
|
callArgs []*SessionRepositoryMockFindByRefreshTokenParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// SessionRepositoryMockFindByRefreshTokenExpectation specifies expectation struct of the SessionRepository.FindByRefreshToken
|
|
type SessionRepositoryMockFindByRefreshTokenExpectation struct {
|
|
mock *SessionRepositoryMock
|
|
params *SessionRepositoryMockFindByRefreshTokenParams
|
|
paramPtrs *SessionRepositoryMockFindByRefreshTokenParamPtrs
|
|
expectationOrigins SessionRepositoryMockFindByRefreshTokenExpectationOrigins
|
|
results *SessionRepositoryMockFindByRefreshTokenResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// SessionRepositoryMockFindByRefreshTokenParams contains parameters of the SessionRepository.FindByRefreshToken
|
|
type SessionRepositoryMockFindByRefreshTokenParams struct {
|
|
ctx context.Context
|
|
token string
|
|
}
|
|
|
|
// SessionRepositoryMockFindByRefreshTokenParamPtrs contains pointers to parameters of the SessionRepository.FindByRefreshToken
|
|
type SessionRepositoryMockFindByRefreshTokenParamPtrs struct {
|
|
ctx *context.Context
|
|
token *string
|
|
}
|
|
|
|
// SessionRepositoryMockFindByRefreshTokenResults contains results of the SessionRepository.FindByRefreshToken
|
|
type SessionRepositoryMockFindByRefreshTokenResults struct {
|
|
sp1 *model.Session
|
|
err error
|
|
}
|
|
|
|
// SessionRepositoryMockFindByRefreshTokenOrigins contains origins of expectations of the SessionRepository.FindByRefreshToken
|
|
type SessionRepositoryMockFindByRefreshTokenExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originToken string
|
|
}
|
|
|
|
// 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 (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Optional() *mSessionRepositoryMockFindByRefreshToken {
|
|
mmFindByRefreshToken.optional = true
|
|
return mmFindByRefreshToken
|
|
}
|
|
|
|
// Expect sets up expected params for SessionRepository.FindByRefreshToken
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Expect(ctx context.Context, token string) *mSessionRepositoryMockFindByRefreshToken {
|
|
if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set")
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation == nil {
|
|
mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{}
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation.paramPtrs != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmFindByRefreshToken.defaultExpectation.params = &SessionRepositoryMockFindByRefreshTokenParams{ctx, token}
|
|
mmFindByRefreshToken.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmFindByRefreshToken.expectations {
|
|
if minimock.Equal(e.params, mmFindByRefreshToken.defaultExpectation.params) {
|
|
mmFindByRefreshToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmFindByRefreshToken.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmFindByRefreshToken
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.FindByRefreshToken
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockFindByRefreshToken {
|
|
if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set")
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation == nil {
|
|
mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{}
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation.params != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Expect")
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation.paramPtrs == nil {
|
|
mmFindByRefreshToken.defaultExpectation.paramPtrs = &SessionRepositoryMockFindByRefreshTokenParamPtrs{}
|
|
}
|
|
mmFindByRefreshToken.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmFindByRefreshToken.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmFindByRefreshToken
|
|
}
|
|
|
|
// ExpectTokenParam2 sets up expected param token for SessionRepository.FindByRefreshToken
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) ExpectTokenParam2(token string) *mSessionRepositoryMockFindByRefreshToken {
|
|
if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set")
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation == nil {
|
|
mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{}
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation.params != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Expect")
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation.paramPtrs == nil {
|
|
mmFindByRefreshToken.defaultExpectation.paramPtrs = &SessionRepositoryMockFindByRefreshTokenParamPtrs{}
|
|
}
|
|
mmFindByRefreshToken.defaultExpectation.paramPtrs.token = &token
|
|
mmFindByRefreshToken.defaultExpectation.expectationOrigins.originToken = minimock.CallerInfo(1)
|
|
|
|
return mmFindByRefreshToken
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the SessionRepository.FindByRefreshToken
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Inspect(f func(ctx context.Context, token string)) *mSessionRepositoryMockFindByRefreshToken {
|
|
if mmFindByRefreshToken.mock.inspectFuncFindByRefreshToken != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.FindByRefreshToken")
|
|
}
|
|
|
|
mmFindByRefreshToken.mock.inspectFuncFindByRefreshToken = f
|
|
|
|
return mmFindByRefreshToken
|
|
}
|
|
|
|
// Return sets up results that will be returned by SessionRepository.FindByRefreshToken
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Return(sp1 *model.Session, err error) *SessionRepositoryMock {
|
|
if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set")
|
|
}
|
|
|
|
if mmFindByRefreshToken.defaultExpectation == nil {
|
|
mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{mock: mmFindByRefreshToken.mock}
|
|
}
|
|
mmFindByRefreshToken.defaultExpectation.results = &SessionRepositoryMockFindByRefreshTokenResults{sp1, err}
|
|
mmFindByRefreshToken.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmFindByRefreshToken.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the SessionRepository.FindByRefreshToken method
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Set(f func(ctx context.Context, token string) (sp1 *model.Session, err error)) *SessionRepositoryMock {
|
|
if mmFindByRefreshToken.defaultExpectation != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("Default expectation is already set for the SessionRepository.FindByRefreshToken method")
|
|
}
|
|
|
|
if len(mmFindByRefreshToken.expectations) > 0 {
|
|
mmFindByRefreshToken.mock.t.Fatalf("Some expectations are already set for the SessionRepository.FindByRefreshToken method")
|
|
}
|
|
|
|
mmFindByRefreshToken.mock.funcFindByRefreshToken = f
|
|
mmFindByRefreshToken.mock.funcFindByRefreshTokenOrigin = minimock.CallerInfo(1)
|
|
return mmFindByRefreshToken.mock
|
|
}
|
|
|
|
// When sets expectation for the SessionRepository.FindByRefreshToken which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) When(ctx context.Context, token string) *SessionRepositoryMockFindByRefreshTokenExpectation {
|
|
if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil {
|
|
mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set")
|
|
}
|
|
|
|
expectation := &SessionRepositoryMockFindByRefreshTokenExpectation{
|
|
mock: mmFindByRefreshToken.mock,
|
|
params: &SessionRepositoryMockFindByRefreshTokenParams{ctx, token},
|
|
expectationOrigins: SessionRepositoryMockFindByRefreshTokenExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmFindByRefreshToken.expectations = append(mmFindByRefreshToken.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up SessionRepository.FindByRefreshToken return parameters for the expectation previously defined by the When method
|
|
func (e *SessionRepositoryMockFindByRefreshTokenExpectation) Then(sp1 *model.Session, err error) *SessionRepositoryMock {
|
|
e.results = &SessionRepositoryMockFindByRefreshTokenResults{sp1, err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times SessionRepository.FindByRefreshToken should be invoked
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Times(n uint64) *mSessionRepositoryMockFindByRefreshToken {
|
|
if n == 0 {
|
|
mmFindByRefreshToken.mock.t.Fatalf("Times of SessionRepositoryMock.FindByRefreshToken mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmFindByRefreshToken.expectedInvocations, n)
|
|
mmFindByRefreshToken.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmFindByRefreshToken
|
|
}
|
|
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) invocationsDone() bool {
|
|
if len(mmFindByRefreshToken.expectations) == 0 && mmFindByRefreshToken.defaultExpectation == nil && mmFindByRefreshToken.mock.funcFindByRefreshToken == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmFindByRefreshToken.mock.afterFindByRefreshTokenCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmFindByRefreshToken.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// FindByRefreshToken implements mm_repository.SessionRepository
|
|
func (mmFindByRefreshToken *SessionRepositoryMock) FindByRefreshToken(ctx context.Context, token string) (sp1 *model.Session, err error) {
|
|
mm_atomic.AddUint64(&mmFindByRefreshToken.beforeFindByRefreshTokenCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmFindByRefreshToken.afterFindByRefreshTokenCounter, 1)
|
|
|
|
mmFindByRefreshToken.t.Helper()
|
|
|
|
if mmFindByRefreshToken.inspectFuncFindByRefreshToken != nil {
|
|
mmFindByRefreshToken.inspectFuncFindByRefreshToken(ctx, token)
|
|
}
|
|
|
|
mm_params := SessionRepositoryMockFindByRefreshTokenParams{ctx, token}
|
|
|
|
// Record call args
|
|
mmFindByRefreshToken.FindByRefreshTokenMock.mutex.Lock()
|
|
mmFindByRefreshToken.FindByRefreshTokenMock.callArgs = append(mmFindByRefreshToken.FindByRefreshTokenMock.callArgs, &mm_params)
|
|
mmFindByRefreshToken.FindByRefreshTokenMock.mutex.Unlock()
|
|
|
|
for _, e := range mmFindByRefreshToken.FindByRefreshTokenMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.sp1, e.results.err
|
|
}
|
|
}
|
|
|
|
if mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.params
|
|
mm_want_ptrs := mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := SessionRepositoryMockFindByRefreshTokenParams{ctx, token}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmFindByRefreshToken.t.Errorf("SessionRepositoryMock.FindByRefreshToken got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.token != nil && !minimock.Equal(*mm_want_ptrs.token, mm_got.token) {
|
|
mmFindByRefreshToken.t.Errorf("SessionRepositoryMock.FindByRefreshToken got unexpected parameter token, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.originToken, *mm_want_ptrs.token, mm_got.token, minimock.Diff(*mm_want_ptrs.token, mm_got.token))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmFindByRefreshToken.t.Errorf("SessionRepositoryMock.FindByRefreshToken got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmFindByRefreshToken.t.Fatal("No results are set for the SessionRepositoryMock.FindByRefreshToken")
|
|
}
|
|
return (*mm_results).sp1, (*mm_results).err
|
|
}
|
|
if mmFindByRefreshToken.funcFindByRefreshToken != nil {
|
|
return mmFindByRefreshToken.funcFindByRefreshToken(ctx, token)
|
|
}
|
|
mmFindByRefreshToken.t.Fatalf("Unexpected call to SessionRepositoryMock.FindByRefreshToken. %v %v", ctx, token)
|
|
return
|
|
}
|
|
|
|
// FindByRefreshTokenAfterCounter returns a count of finished SessionRepositoryMock.FindByRefreshToken invocations
|
|
func (mmFindByRefreshToken *SessionRepositoryMock) FindByRefreshTokenAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmFindByRefreshToken.afterFindByRefreshTokenCounter)
|
|
}
|
|
|
|
// FindByRefreshTokenBeforeCounter returns a count of SessionRepositoryMock.FindByRefreshToken invocations
|
|
func (mmFindByRefreshToken *SessionRepositoryMock) FindByRefreshTokenBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmFindByRefreshToken.beforeFindByRefreshTokenCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to SessionRepositoryMock.FindByRefreshToken.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Calls() []*SessionRepositoryMockFindByRefreshTokenParams {
|
|
mmFindByRefreshToken.mutex.RLock()
|
|
|
|
argCopy := make([]*SessionRepositoryMockFindByRefreshTokenParams, len(mmFindByRefreshToken.callArgs))
|
|
copy(argCopy, mmFindByRefreshToken.callArgs)
|
|
|
|
mmFindByRefreshToken.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockFindByRefreshTokenDone returns true if the count of the FindByRefreshToken invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *SessionRepositoryMock) MinimockFindByRefreshTokenDone() bool {
|
|
if m.FindByRefreshTokenMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.FindByRefreshTokenMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.FindByRefreshTokenMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockFindByRefreshTokenInspect logs each unmet expectation
|
|
func (m *SessionRepositoryMock) MinimockFindByRefreshTokenInspect() {
|
|
for _, e := range m.FindByRefreshTokenMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterFindByRefreshTokenCounter := mm_atomic.LoadUint64(&m.afterFindByRefreshTokenCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.FindByRefreshTokenMock.defaultExpectation != nil && afterFindByRefreshTokenCounter < 1 {
|
|
if m.FindByRefreshTokenMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s", m.FindByRefreshTokenMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s with params: %#v", m.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.origin, *m.FindByRefreshTokenMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcFindByRefreshToken != nil && afterFindByRefreshTokenCounter < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s", m.funcFindByRefreshTokenOrigin)
|
|
}
|
|
|
|
if !m.FindByRefreshTokenMock.invocationsDone() && afterFindByRefreshTokenCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to SessionRepositoryMock.FindByRefreshToken at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.FindByRefreshTokenMock.expectedInvocations), m.FindByRefreshTokenMock.expectedInvocationsOrigin, afterFindByRefreshTokenCounter)
|
|
}
|
|
}
|
|
|
|
type mSessionRepositoryMockIsAccessTokenValid struct {
|
|
optional bool
|
|
mock *SessionRepositoryMock
|
|
defaultExpectation *SessionRepositoryMockIsAccessTokenValidExpectation
|
|
expectations []*SessionRepositoryMockIsAccessTokenValidExpectation
|
|
|
|
callArgs []*SessionRepositoryMockIsAccessTokenValidParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// SessionRepositoryMockIsAccessTokenValidExpectation specifies expectation struct of the SessionRepository.IsAccessTokenValid
|
|
type SessionRepositoryMockIsAccessTokenValidExpectation struct {
|
|
mock *SessionRepositoryMock
|
|
params *SessionRepositoryMockIsAccessTokenValidParams
|
|
paramPtrs *SessionRepositoryMockIsAccessTokenValidParamPtrs
|
|
expectationOrigins SessionRepositoryMockIsAccessTokenValidExpectationOrigins
|
|
results *SessionRepositoryMockIsAccessTokenValidResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// SessionRepositoryMockIsAccessTokenValidParams contains parameters of the SessionRepository.IsAccessTokenValid
|
|
type SessionRepositoryMockIsAccessTokenValidParams struct {
|
|
ctx context.Context
|
|
accessToken string
|
|
}
|
|
|
|
// SessionRepositoryMockIsAccessTokenValidParamPtrs contains pointers to parameters of the SessionRepository.IsAccessTokenValid
|
|
type SessionRepositoryMockIsAccessTokenValidParamPtrs struct {
|
|
ctx *context.Context
|
|
accessToken *string
|
|
}
|
|
|
|
// SessionRepositoryMockIsAccessTokenValidResults contains results of the SessionRepository.IsAccessTokenValid
|
|
type SessionRepositoryMockIsAccessTokenValidResults struct {
|
|
b1 bool
|
|
err error
|
|
}
|
|
|
|
// SessionRepositoryMockIsAccessTokenValidOrigins contains origins of expectations of the SessionRepository.IsAccessTokenValid
|
|
type SessionRepositoryMockIsAccessTokenValidExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originAccessToken string
|
|
}
|
|
|
|
// 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 (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Optional() *mSessionRepositoryMockIsAccessTokenValid {
|
|
mmIsAccessTokenValid.optional = true
|
|
return mmIsAccessTokenValid
|
|
}
|
|
|
|
// Expect sets up expected params for SessionRepository.IsAccessTokenValid
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Expect(ctx context.Context, accessToken string) *mSessionRepositoryMockIsAccessTokenValid {
|
|
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation == nil {
|
|
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{}
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation.paramPtrs != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmIsAccessTokenValid.defaultExpectation.params = &SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken}
|
|
mmIsAccessTokenValid.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmIsAccessTokenValid.expectations {
|
|
if minimock.Equal(e.params, mmIsAccessTokenValid.defaultExpectation.params) {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsAccessTokenValid.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmIsAccessTokenValid
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.IsAccessTokenValid
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockIsAccessTokenValid {
|
|
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation == nil {
|
|
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{}
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation.params != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Expect")
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation.paramPtrs == nil {
|
|
mmIsAccessTokenValid.defaultExpectation.paramPtrs = &SessionRepositoryMockIsAccessTokenValidParamPtrs{}
|
|
}
|
|
mmIsAccessTokenValid.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmIsAccessTokenValid.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmIsAccessTokenValid
|
|
}
|
|
|
|
// ExpectAccessTokenParam2 sets up expected param accessToken for SessionRepository.IsAccessTokenValid
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) ExpectAccessTokenParam2(accessToken string) *mSessionRepositoryMockIsAccessTokenValid {
|
|
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation == nil {
|
|
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{}
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation.params != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Expect")
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation.paramPtrs == nil {
|
|
mmIsAccessTokenValid.defaultExpectation.paramPtrs = &SessionRepositoryMockIsAccessTokenValidParamPtrs{}
|
|
}
|
|
mmIsAccessTokenValid.defaultExpectation.paramPtrs.accessToken = &accessToken
|
|
mmIsAccessTokenValid.defaultExpectation.expectationOrigins.originAccessToken = minimock.CallerInfo(1)
|
|
|
|
return mmIsAccessTokenValid
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the SessionRepository.IsAccessTokenValid
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Inspect(f func(ctx context.Context, accessToken string)) *mSessionRepositoryMockIsAccessTokenValid {
|
|
if mmIsAccessTokenValid.mock.inspectFuncIsAccessTokenValid != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.IsAccessTokenValid")
|
|
}
|
|
|
|
mmIsAccessTokenValid.mock.inspectFuncIsAccessTokenValid = f
|
|
|
|
return mmIsAccessTokenValid
|
|
}
|
|
|
|
// Return sets up results that will be returned by SessionRepository.IsAccessTokenValid
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Return(b1 bool, err error) *SessionRepositoryMock {
|
|
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
|
}
|
|
|
|
if mmIsAccessTokenValid.defaultExpectation == nil {
|
|
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{mock: mmIsAccessTokenValid.mock}
|
|
}
|
|
mmIsAccessTokenValid.defaultExpectation.results = &SessionRepositoryMockIsAccessTokenValidResults{b1, err}
|
|
mmIsAccessTokenValid.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmIsAccessTokenValid.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the SessionRepository.IsAccessTokenValid method
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Set(f func(ctx context.Context, accessToken string) (b1 bool, err error)) *SessionRepositoryMock {
|
|
if mmIsAccessTokenValid.defaultExpectation != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("Default expectation is already set for the SessionRepository.IsAccessTokenValid method")
|
|
}
|
|
|
|
if len(mmIsAccessTokenValid.expectations) > 0 {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("Some expectations are already set for the SessionRepository.IsAccessTokenValid method")
|
|
}
|
|
|
|
mmIsAccessTokenValid.mock.funcIsAccessTokenValid = f
|
|
mmIsAccessTokenValid.mock.funcIsAccessTokenValidOrigin = minimock.CallerInfo(1)
|
|
return mmIsAccessTokenValid.mock
|
|
}
|
|
|
|
// When sets expectation for the SessionRepository.IsAccessTokenValid which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) When(ctx context.Context, accessToken string) *SessionRepositoryMockIsAccessTokenValidExpectation {
|
|
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
|
}
|
|
|
|
expectation := &SessionRepositoryMockIsAccessTokenValidExpectation{
|
|
mock: mmIsAccessTokenValid.mock,
|
|
params: &SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken},
|
|
expectationOrigins: SessionRepositoryMockIsAccessTokenValidExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmIsAccessTokenValid.expectations = append(mmIsAccessTokenValid.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up SessionRepository.IsAccessTokenValid return parameters for the expectation previously defined by the When method
|
|
func (e *SessionRepositoryMockIsAccessTokenValidExpectation) Then(b1 bool, err error) *SessionRepositoryMock {
|
|
e.results = &SessionRepositoryMockIsAccessTokenValidResults{b1, err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times SessionRepository.IsAccessTokenValid should be invoked
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Times(n uint64) *mSessionRepositoryMockIsAccessTokenValid {
|
|
if n == 0 {
|
|
mmIsAccessTokenValid.mock.t.Fatalf("Times of SessionRepositoryMock.IsAccessTokenValid mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmIsAccessTokenValid.expectedInvocations, n)
|
|
mmIsAccessTokenValid.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmIsAccessTokenValid
|
|
}
|
|
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) invocationsDone() bool {
|
|
if len(mmIsAccessTokenValid.expectations) == 0 && mmIsAccessTokenValid.defaultExpectation == nil && mmIsAccessTokenValid.mock.funcIsAccessTokenValid == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmIsAccessTokenValid.mock.afterIsAccessTokenValidCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmIsAccessTokenValid.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// IsAccessTokenValid implements mm_repository.SessionRepository
|
|
func (mmIsAccessTokenValid *SessionRepositoryMock) IsAccessTokenValid(ctx context.Context, accessToken string) (b1 bool, err error) {
|
|
mm_atomic.AddUint64(&mmIsAccessTokenValid.beforeIsAccessTokenValidCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmIsAccessTokenValid.afterIsAccessTokenValidCounter, 1)
|
|
|
|
mmIsAccessTokenValid.t.Helper()
|
|
|
|
if mmIsAccessTokenValid.inspectFuncIsAccessTokenValid != nil {
|
|
mmIsAccessTokenValid.inspectFuncIsAccessTokenValid(ctx, accessToken)
|
|
}
|
|
|
|
mm_params := SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken}
|
|
|
|
// Record call args
|
|
mmIsAccessTokenValid.IsAccessTokenValidMock.mutex.Lock()
|
|
mmIsAccessTokenValid.IsAccessTokenValidMock.callArgs = append(mmIsAccessTokenValid.IsAccessTokenValidMock.callArgs, &mm_params)
|
|
mmIsAccessTokenValid.IsAccessTokenValidMock.mutex.Unlock()
|
|
|
|
for _, e := range mmIsAccessTokenValid.IsAccessTokenValidMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.b1, e.results.err
|
|
}
|
|
}
|
|
|
|
if mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.params
|
|
mm_want_ptrs := mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmIsAccessTokenValid.t.Errorf("SessionRepositoryMock.IsAccessTokenValid got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.accessToken != nil && !minimock.Equal(*mm_want_ptrs.accessToken, mm_got.accessToken) {
|
|
mmIsAccessTokenValid.t.Errorf("SessionRepositoryMock.IsAccessTokenValid got unexpected parameter accessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.originAccessToken, *mm_want_ptrs.accessToken, mm_got.accessToken, minimock.Diff(*mm_want_ptrs.accessToken, mm_got.accessToken))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmIsAccessTokenValid.t.Errorf("SessionRepositoryMock.IsAccessTokenValid got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmIsAccessTokenValid.t.Fatal("No results are set for the SessionRepositoryMock.IsAccessTokenValid")
|
|
}
|
|
return (*mm_results).b1, (*mm_results).err
|
|
}
|
|
if mmIsAccessTokenValid.funcIsAccessTokenValid != nil {
|
|
return mmIsAccessTokenValid.funcIsAccessTokenValid(ctx, accessToken)
|
|
}
|
|
mmIsAccessTokenValid.t.Fatalf("Unexpected call to SessionRepositoryMock.IsAccessTokenValid. %v %v", ctx, accessToken)
|
|
return
|
|
}
|
|
|
|
// IsAccessTokenValidAfterCounter returns a count of finished SessionRepositoryMock.IsAccessTokenValid invocations
|
|
func (mmIsAccessTokenValid *SessionRepositoryMock) IsAccessTokenValidAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmIsAccessTokenValid.afterIsAccessTokenValidCounter)
|
|
}
|
|
|
|
// IsAccessTokenValidBeforeCounter returns a count of SessionRepositoryMock.IsAccessTokenValid invocations
|
|
func (mmIsAccessTokenValid *SessionRepositoryMock) IsAccessTokenValidBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmIsAccessTokenValid.beforeIsAccessTokenValidCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to SessionRepositoryMock.IsAccessTokenValid.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Calls() []*SessionRepositoryMockIsAccessTokenValidParams {
|
|
mmIsAccessTokenValid.mutex.RLock()
|
|
|
|
argCopy := make([]*SessionRepositoryMockIsAccessTokenValidParams, len(mmIsAccessTokenValid.callArgs))
|
|
copy(argCopy, mmIsAccessTokenValid.callArgs)
|
|
|
|
mmIsAccessTokenValid.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockIsAccessTokenValidDone returns true if the count of the IsAccessTokenValid invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *SessionRepositoryMock) MinimockIsAccessTokenValidDone() bool {
|
|
if m.IsAccessTokenValidMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.IsAccessTokenValidMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.IsAccessTokenValidMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockIsAccessTokenValidInspect logs each unmet expectation
|
|
func (m *SessionRepositoryMock) MinimockIsAccessTokenValidInspect() {
|
|
for _, e := range m.IsAccessTokenValidMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterIsAccessTokenValidCounter := mm_atomic.LoadUint64(&m.afterIsAccessTokenValidCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.IsAccessTokenValidMock.defaultExpectation != nil && afterIsAccessTokenValidCounter < 1 {
|
|
if m.IsAccessTokenValidMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s", m.IsAccessTokenValidMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s with params: %#v", m.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.origin, *m.IsAccessTokenValidMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcIsAccessTokenValid != nil && afterIsAccessTokenValidCounter < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s", m.funcIsAccessTokenValidOrigin)
|
|
}
|
|
|
|
if !m.IsAccessTokenValidMock.invocationsDone() && afterIsAccessTokenValidCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to SessionRepositoryMock.IsAccessTokenValid at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.IsAccessTokenValidMock.expectedInvocations), m.IsAccessTokenValidMock.expectedInvocationsOrigin, afterIsAccessTokenValidCounter)
|
|
}
|
|
}
|
|
|
|
type mSessionRepositoryMockRevoke struct {
|
|
optional bool
|
|
mock *SessionRepositoryMock
|
|
defaultExpectation *SessionRepositoryMockRevokeExpectation
|
|
expectations []*SessionRepositoryMockRevokeExpectation
|
|
|
|
callArgs []*SessionRepositoryMockRevokeParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeExpectation specifies expectation struct of the SessionRepository.Revoke
|
|
type SessionRepositoryMockRevokeExpectation struct {
|
|
mock *SessionRepositoryMock
|
|
params *SessionRepositoryMockRevokeParams
|
|
paramPtrs *SessionRepositoryMockRevokeParamPtrs
|
|
expectationOrigins SessionRepositoryMockRevokeExpectationOrigins
|
|
results *SessionRepositoryMockRevokeResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeParams contains parameters of the SessionRepository.Revoke
|
|
type SessionRepositoryMockRevokeParams struct {
|
|
ctx context.Context
|
|
refreshToken string
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeParamPtrs contains pointers to parameters of the SessionRepository.Revoke
|
|
type SessionRepositoryMockRevokeParamPtrs struct {
|
|
ctx *context.Context
|
|
refreshToken *string
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeResults contains results of the SessionRepository.Revoke
|
|
type SessionRepositoryMockRevokeResults struct {
|
|
err error
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeOrigins contains origins of expectations of the SessionRepository.Revoke
|
|
type SessionRepositoryMockRevokeExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originRefreshToken string
|
|
}
|
|
|
|
// 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 (mmRevoke *mSessionRepositoryMockRevoke) Optional() *mSessionRepositoryMockRevoke {
|
|
mmRevoke.optional = true
|
|
return mmRevoke
|
|
}
|
|
|
|
// Expect sets up expected params for SessionRepository.Revoke
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) Expect(ctx context.Context, refreshToken string) *mSessionRepositoryMockRevoke {
|
|
if mmRevoke.mock.funcRevoke != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set")
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation == nil {
|
|
mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{}
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation.paramPtrs != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmRevoke.defaultExpectation.params = &SessionRepositoryMockRevokeParams{ctx, refreshToken}
|
|
mmRevoke.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmRevoke.expectations {
|
|
if minimock.Equal(e.params, mmRevoke.defaultExpectation.params) {
|
|
mmRevoke.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRevoke.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmRevoke
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.Revoke
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockRevoke {
|
|
if mmRevoke.mock.funcRevoke != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set")
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation == nil {
|
|
mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{}
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation.params != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Expect")
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation.paramPtrs == nil {
|
|
mmRevoke.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeParamPtrs{}
|
|
}
|
|
mmRevoke.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmRevoke.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmRevoke
|
|
}
|
|
|
|
// ExpectRefreshTokenParam2 sets up expected param refreshToken for SessionRepository.Revoke
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) ExpectRefreshTokenParam2(refreshToken string) *mSessionRepositoryMockRevoke {
|
|
if mmRevoke.mock.funcRevoke != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set")
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation == nil {
|
|
mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{}
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation.params != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Expect")
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation.paramPtrs == nil {
|
|
mmRevoke.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeParamPtrs{}
|
|
}
|
|
mmRevoke.defaultExpectation.paramPtrs.refreshToken = &refreshToken
|
|
mmRevoke.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1)
|
|
|
|
return mmRevoke
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the SessionRepository.Revoke
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) Inspect(f func(ctx context.Context, refreshToken string)) *mSessionRepositoryMockRevoke {
|
|
if mmRevoke.mock.inspectFuncRevoke != nil {
|
|
mmRevoke.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.Revoke")
|
|
}
|
|
|
|
mmRevoke.mock.inspectFuncRevoke = f
|
|
|
|
return mmRevoke
|
|
}
|
|
|
|
// Return sets up results that will be returned by SessionRepository.Revoke
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) Return(err error) *SessionRepositoryMock {
|
|
if mmRevoke.mock.funcRevoke != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set")
|
|
}
|
|
|
|
if mmRevoke.defaultExpectation == nil {
|
|
mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{mock: mmRevoke.mock}
|
|
}
|
|
mmRevoke.defaultExpectation.results = &SessionRepositoryMockRevokeResults{err}
|
|
mmRevoke.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmRevoke.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the SessionRepository.Revoke method
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) Set(f func(ctx context.Context, refreshToken string) (err error)) *SessionRepositoryMock {
|
|
if mmRevoke.defaultExpectation != nil {
|
|
mmRevoke.mock.t.Fatalf("Default expectation is already set for the SessionRepository.Revoke method")
|
|
}
|
|
|
|
if len(mmRevoke.expectations) > 0 {
|
|
mmRevoke.mock.t.Fatalf("Some expectations are already set for the SessionRepository.Revoke method")
|
|
}
|
|
|
|
mmRevoke.mock.funcRevoke = f
|
|
mmRevoke.mock.funcRevokeOrigin = minimock.CallerInfo(1)
|
|
return mmRevoke.mock
|
|
}
|
|
|
|
// When sets expectation for the SessionRepository.Revoke which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) When(ctx context.Context, refreshToken string) *SessionRepositoryMockRevokeExpectation {
|
|
if mmRevoke.mock.funcRevoke != nil {
|
|
mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set")
|
|
}
|
|
|
|
expectation := &SessionRepositoryMockRevokeExpectation{
|
|
mock: mmRevoke.mock,
|
|
params: &SessionRepositoryMockRevokeParams{ctx, refreshToken},
|
|
expectationOrigins: SessionRepositoryMockRevokeExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmRevoke.expectations = append(mmRevoke.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up SessionRepository.Revoke return parameters for the expectation previously defined by the When method
|
|
func (e *SessionRepositoryMockRevokeExpectation) Then(err error) *SessionRepositoryMock {
|
|
e.results = &SessionRepositoryMockRevokeResults{err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times SessionRepository.Revoke should be invoked
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) Times(n uint64) *mSessionRepositoryMockRevoke {
|
|
if n == 0 {
|
|
mmRevoke.mock.t.Fatalf("Times of SessionRepositoryMock.Revoke mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmRevoke.expectedInvocations, n)
|
|
mmRevoke.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmRevoke
|
|
}
|
|
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) invocationsDone() bool {
|
|
if len(mmRevoke.expectations) == 0 && mmRevoke.defaultExpectation == nil && mmRevoke.mock.funcRevoke == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmRevoke.mock.afterRevokeCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmRevoke.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// Revoke implements mm_repository.SessionRepository
|
|
func (mmRevoke *SessionRepositoryMock) Revoke(ctx context.Context, refreshToken string) (err error) {
|
|
mm_atomic.AddUint64(&mmRevoke.beforeRevokeCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmRevoke.afterRevokeCounter, 1)
|
|
|
|
mmRevoke.t.Helper()
|
|
|
|
if mmRevoke.inspectFuncRevoke != nil {
|
|
mmRevoke.inspectFuncRevoke(ctx, refreshToken)
|
|
}
|
|
|
|
mm_params := SessionRepositoryMockRevokeParams{ctx, refreshToken}
|
|
|
|
// Record call args
|
|
mmRevoke.RevokeMock.mutex.Lock()
|
|
mmRevoke.RevokeMock.callArgs = append(mmRevoke.RevokeMock.callArgs, &mm_params)
|
|
mmRevoke.RevokeMock.mutex.Unlock()
|
|
|
|
for _, e := range mmRevoke.RevokeMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.err
|
|
}
|
|
}
|
|
|
|
if mmRevoke.RevokeMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmRevoke.RevokeMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmRevoke.RevokeMock.defaultExpectation.params
|
|
mm_want_ptrs := mmRevoke.RevokeMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := SessionRepositoryMockRevokeParams{ctx, refreshToken}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmRevoke.t.Errorf("SessionRepositoryMock.Revoke got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRevoke.RevokeMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.refreshToken != nil && !minimock.Equal(*mm_want_ptrs.refreshToken, mm_got.refreshToken) {
|
|
mmRevoke.t.Errorf("SessionRepositoryMock.Revoke got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRevoke.RevokeMock.defaultExpectation.expectationOrigins.originRefreshToken, *mm_want_ptrs.refreshToken, mm_got.refreshToken, minimock.Diff(*mm_want_ptrs.refreshToken, mm_got.refreshToken))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmRevoke.t.Errorf("SessionRepositoryMock.Revoke got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRevoke.RevokeMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmRevoke.RevokeMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmRevoke.t.Fatal("No results are set for the SessionRepositoryMock.Revoke")
|
|
}
|
|
return (*mm_results).err
|
|
}
|
|
if mmRevoke.funcRevoke != nil {
|
|
return mmRevoke.funcRevoke(ctx, refreshToken)
|
|
}
|
|
mmRevoke.t.Fatalf("Unexpected call to SessionRepositoryMock.Revoke. %v %v", ctx, refreshToken)
|
|
return
|
|
}
|
|
|
|
// RevokeAfterCounter returns a count of finished SessionRepositoryMock.Revoke invocations
|
|
func (mmRevoke *SessionRepositoryMock) RevokeAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmRevoke.afterRevokeCounter)
|
|
}
|
|
|
|
// RevokeBeforeCounter returns a count of SessionRepositoryMock.Revoke invocations
|
|
func (mmRevoke *SessionRepositoryMock) RevokeBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmRevoke.beforeRevokeCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to SessionRepositoryMock.Revoke.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmRevoke *mSessionRepositoryMockRevoke) Calls() []*SessionRepositoryMockRevokeParams {
|
|
mmRevoke.mutex.RLock()
|
|
|
|
argCopy := make([]*SessionRepositoryMockRevokeParams, len(mmRevoke.callArgs))
|
|
copy(argCopy, mmRevoke.callArgs)
|
|
|
|
mmRevoke.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockRevokeDone returns true if the count of the Revoke invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *SessionRepositoryMock) MinimockRevokeDone() bool {
|
|
if m.RevokeMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.RevokeMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.RevokeMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockRevokeInspect logs each unmet expectation
|
|
func (m *SessionRepositoryMock) MinimockRevokeInspect() {
|
|
for _, e := range m.RevokeMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterRevokeCounter := mm_atomic.LoadUint64(&m.afterRevokeCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.RevokeMock.defaultExpectation != nil && afterRevokeCounter < 1 {
|
|
if m.RevokeMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s", m.RevokeMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s with params: %#v", m.RevokeMock.defaultExpectation.expectationOrigins.origin, *m.RevokeMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcRevoke != nil && afterRevokeCounter < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s", m.funcRevokeOrigin)
|
|
}
|
|
|
|
if !m.RevokeMock.invocationsDone() && afterRevokeCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to SessionRepositoryMock.Revoke at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.RevokeMock.expectedInvocations), m.RevokeMock.expectedInvocationsOrigin, afterRevokeCounter)
|
|
}
|
|
}
|
|
|
|
type mSessionRepositoryMockRevokeByAccessToken struct {
|
|
optional bool
|
|
mock *SessionRepositoryMock
|
|
defaultExpectation *SessionRepositoryMockRevokeByAccessTokenExpectation
|
|
expectations []*SessionRepositoryMockRevokeByAccessTokenExpectation
|
|
|
|
callArgs []*SessionRepositoryMockRevokeByAccessTokenParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeByAccessTokenExpectation specifies expectation struct of the SessionRepository.RevokeByAccessToken
|
|
type SessionRepositoryMockRevokeByAccessTokenExpectation struct {
|
|
mock *SessionRepositoryMock
|
|
params *SessionRepositoryMockRevokeByAccessTokenParams
|
|
paramPtrs *SessionRepositoryMockRevokeByAccessTokenParamPtrs
|
|
expectationOrigins SessionRepositoryMockRevokeByAccessTokenExpectationOrigins
|
|
results *SessionRepositoryMockRevokeByAccessTokenResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeByAccessTokenParams contains parameters of the SessionRepository.RevokeByAccessToken
|
|
type SessionRepositoryMockRevokeByAccessTokenParams struct {
|
|
ctx context.Context
|
|
accessToken string
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeByAccessTokenParamPtrs contains pointers to parameters of the SessionRepository.RevokeByAccessToken
|
|
type SessionRepositoryMockRevokeByAccessTokenParamPtrs struct {
|
|
ctx *context.Context
|
|
accessToken *string
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeByAccessTokenResults contains results of the SessionRepository.RevokeByAccessToken
|
|
type SessionRepositoryMockRevokeByAccessTokenResults struct {
|
|
err error
|
|
}
|
|
|
|
// SessionRepositoryMockRevokeByAccessTokenOrigins contains origins of expectations of the SessionRepository.RevokeByAccessToken
|
|
type SessionRepositoryMockRevokeByAccessTokenExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originAccessToken string
|
|
}
|
|
|
|
// 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 (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Optional() *mSessionRepositoryMockRevokeByAccessToken {
|
|
mmRevokeByAccessToken.optional = true
|
|
return mmRevokeByAccessToken
|
|
}
|
|
|
|
// Expect sets up expected params for SessionRepository.RevokeByAccessToken
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Expect(ctx context.Context, accessToken string) *mSessionRepositoryMockRevokeByAccessToken {
|
|
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation == nil {
|
|
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{}
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation.paramPtrs != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmRevokeByAccessToken.defaultExpectation.params = &SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken}
|
|
mmRevokeByAccessToken.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmRevokeByAccessToken.expectations {
|
|
if minimock.Equal(e.params, mmRevokeByAccessToken.defaultExpectation.params) {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRevokeByAccessToken.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmRevokeByAccessToken
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.RevokeByAccessToken
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockRevokeByAccessToken {
|
|
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation == nil {
|
|
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{}
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation.params != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Expect")
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation.paramPtrs == nil {
|
|
mmRevokeByAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeByAccessTokenParamPtrs{}
|
|
}
|
|
mmRevokeByAccessToken.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmRevokeByAccessToken.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmRevokeByAccessToken
|
|
}
|
|
|
|
// ExpectAccessTokenParam2 sets up expected param accessToken for SessionRepository.RevokeByAccessToken
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) ExpectAccessTokenParam2(accessToken string) *mSessionRepositoryMockRevokeByAccessToken {
|
|
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation == nil {
|
|
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{}
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation.params != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Expect")
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation.paramPtrs == nil {
|
|
mmRevokeByAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeByAccessTokenParamPtrs{}
|
|
}
|
|
mmRevokeByAccessToken.defaultExpectation.paramPtrs.accessToken = &accessToken
|
|
mmRevokeByAccessToken.defaultExpectation.expectationOrigins.originAccessToken = minimock.CallerInfo(1)
|
|
|
|
return mmRevokeByAccessToken
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the SessionRepository.RevokeByAccessToken
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Inspect(f func(ctx context.Context, accessToken string)) *mSessionRepositoryMockRevokeByAccessToken {
|
|
if mmRevokeByAccessToken.mock.inspectFuncRevokeByAccessToken != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.RevokeByAccessToken")
|
|
}
|
|
|
|
mmRevokeByAccessToken.mock.inspectFuncRevokeByAccessToken = f
|
|
|
|
return mmRevokeByAccessToken
|
|
}
|
|
|
|
// Return sets up results that will be returned by SessionRepository.RevokeByAccessToken
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Return(err error) *SessionRepositoryMock {
|
|
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmRevokeByAccessToken.defaultExpectation == nil {
|
|
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{mock: mmRevokeByAccessToken.mock}
|
|
}
|
|
mmRevokeByAccessToken.defaultExpectation.results = &SessionRepositoryMockRevokeByAccessTokenResults{err}
|
|
mmRevokeByAccessToken.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmRevokeByAccessToken.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the SessionRepository.RevokeByAccessToken method
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Set(f func(ctx context.Context, accessToken string) (err error)) *SessionRepositoryMock {
|
|
if mmRevokeByAccessToken.defaultExpectation != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("Default expectation is already set for the SessionRepository.RevokeByAccessToken method")
|
|
}
|
|
|
|
if len(mmRevokeByAccessToken.expectations) > 0 {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("Some expectations are already set for the SessionRepository.RevokeByAccessToken method")
|
|
}
|
|
|
|
mmRevokeByAccessToken.mock.funcRevokeByAccessToken = f
|
|
mmRevokeByAccessToken.mock.funcRevokeByAccessTokenOrigin = minimock.CallerInfo(1)
|
|
return mmRevokeByAccessToken.mock
|
|
}
|
|
|
|
// When sets expectation for the SessionRepository.RevokeByAccessToken which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) When(ctx context.Context, accessToken string) *SessionRepositoryMockRevokeByAccessTokenExpectation {
|
|
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
|
}
|
|
|
|
expectation := &SessionRepositoryMockRevokeByAccessTokenExpectation{
|
|
mock: mmRevokeByAccessToken.mock,
|
|
params: &SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken},
|
|
expectationOrigins: SessionRepositoryMockRevokeByAccessTokenExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmRevokeByAccessToken.expectations = append(mmRevokeByAccessToken.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up SessionRepository.RevokeByAccessToken return parameters for the expectation previously defined by the When method
|
|
func (e *SessionRepositoryMockRevokeByAccessTokenExpectation) Then(err error) *SessionRepositoryMock {
|
|
e.results = &SessionRepositoryMockRevokeByAccessTokenResults{err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times SessionRepository.RevokeByAccessToken should be invoked
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Times(n uint64) *mSessionRepositoryMockRevokeByAccessToken {
|
|
if n == 0 {
|
|
mmRevokeByAccessToken.mock.t.Fatalf("Times of SessionRepositoryMock.RevokeByAccessToken mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmRevokeByAccessToken.expectedInvocations, n)
|
|
mmRevokeByAccessToken.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmRevokeByAccessToken
|
|
}
|
|
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) invocationsDone() bool {
|
|
if len(mmRevokeByAccessToken.expectations) == 0 && mmRevokeByAccessToken.defaultExpectation == nil && mmRevokeByAccessToken.mock.funcRevokeByAccessToken == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmRevokeByAccessToken.mock.afterRevokeByAccessTokenCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmRevokeByAccessToken.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// RevokeByAccessToken implements mm_repository.SessionRepository
|
|
func (mmRevokeByAccessToken *SessionRepositoryMock) RevokeByAccessToken(ctx context.Context, accessToken string) (err error) {
|
|
mm_atomic.AddUint64(&mmRevokeByAccessToken.beforeRevokeByAccessTokenCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmRevokeByAccessToken.afterRevokeByAccessTokenCounter, 1)
|
|
|
|
mmRevokeByAccessToken.t.Helper()
|
|
|
|
if mmRevokeByAccessToken.inspectFuncRevokeByAccessToken != nil {
|
|
mmRevokeByAccessToken.inspectFuncRevokeByAccessToken(ctx, accessToken)
|
|
}
|
|
|
|
mm_params := SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken}
|
|
|
|
// Record call args
|
|
mmRevokeByAccessToken.RevokeByAccessTokenMock.mutex.Lock()
|
|
mmRevokeByAccessToken.RevokeByAccessTokenMock.callArgs = append(mmRevokeByAccessToken.RevokeByAccessTokenMock.callArgs, &mm_params)
|
|
mmRevokeByAccessToken.RevokeByAccessTokenMock.mutex.Unlock()
|
|
|
|
for _, e := range mmRevokeByAccessToken.RevokeByAccessTokenMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.err
|
|
}
|
|
}
|
|
|
|
if mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.params
|
|
mm_want_ptrs := mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmRevokeByAccessToken.t.Errorf("SessionRepositoryMock.RevokeByAccessToken got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.accessToken != nil && !minimock.Equal(*mm_want_ptrs.accessToken, mm_got.accessToken) {
|
|
mmRevokeByAccessToken.t.Errorf("SessionRepositoryMock.RevokeByAccessToken got unexpected parameter accessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.originAccessToken, *mm_want_ptrs.accessToken, mm_got.accessToken, minimock.Diff(*mm_want_ptrs.accessToken, mm_got.accessToken))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmRevokeByAccessToken.t.Errorf("SessionRepositoryMock.RevokeByAccessToken got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmRevokeByAccessToken.t.Fatal("No results are set for the SessionRepositoryMock.RevokeByAccessToken")
|
|
}
|
|
return (*mm_results).err
|
|
}
|
|
if mmRevokeByAccessToken.funcRevokeByAccessToken != nil {
|
|
return mmRevokeByAccessToken.funcRevokeByAccessToken(ctx, accessToken)
|
|
}
|
|
mmRevokeByAccessToken.t.Fatalf("Unexpected call to SessionRepositoryMock.RevokeByAccessToken. %v %v", ctx, accessToken)
|
|
return
|
|
}
|
|
|
|
// RevokeByAccessTokenAfterCounter returns a count of finished SessionRepositoryMock.RevokeByAccessToken invocations
|
|
func (mmRevokeByAccessToken *SessionRepositoryMock) RevokeByAccessTokenAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmRevokeByAccessToken.afterRevokeByAccessTokenCounter)
|
|
}
|
|
|
|
// RevokeByAccessTokenBeforeCounter returns a count of SessionRepositoryMock.RevokeByAccessToken invocations
|
|
func (mmRevokeByAccessToken *SessionRepositoryMock) RevokeByAccessTokenBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmRevokeByAccessToken.beforeRevokeByAccessTokenCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to SessionRepositoryMock.RevokeByAccessToken.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Calls() []*SessionRepositoryMockRevokeByAccessTokenParams {
|
|
mmRevokeByAccessToken.mutex.RLock()
|
|
|
|
argCopy := make([]*SessionRepositoryMockRevokeByAccessTokenParams, len(mmRevokeByAccessToken.callArgs))
|
|
copy(argCopy, mmRevokeByAccessToken.callArgs)
|
|
|
|
mmRevokeByAccessToken.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockRevokeByAccessTokenDone returns true if the count of the RevokeByAccessToken invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *SessionRepositoryMock) MinimockRevokeByAccessTokenDone() bool {
|
|
if m.RevokeByAccessTokenMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.RevokeByAccessTokenMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.RevokeByAccessTokenMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockRevokeByAccessTokenInspect logs each unmet expectation
|
|
func (m *SessionRepositoryMock) MinimockRevokeByAccessTokenInspect() {
|
|
for _, e := range m.RevokeByAccessTokenMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterRevokeByAccessTokenCounter := mm_atomic.LoadUint64(&m.afterRevokeByAccessTokenCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.RevokeByAccessTokenMock.defaultExpectation != nil && afterRevokeByAccessTokenCounter < 1 {
|
|
if m.RevokeByAccessTokenMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s", m.RevokeByAccessTokenMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s with params: %#v", m.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.origin, *m.RevokeByAccessTokenMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcRevokeByAccessToken != nil && afterRevokeByAccessTokenCounter < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s", m.funcRevokeByAccessTokenOrigin)
|
|
}
|
|
|
|
if !m.RevokeByAccessTokenMock.invocationsDone() && afterRevokeByAccessTokenCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to SessionRepositoryMock.RevokeByAccessToken at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.RevokeByAccessTokenMock.expectedInvocations), m.RevokeByAccessTokenMock.expectedInvocationsOrigin, afterRevokeByAccessTokenCounter)
|
|
}
|
|
}
|
|
|
|
type mSessionRepositoryMockUpdateAccessToken struct {
|
|
optional bool
|
|
mock *SessionRepositoryMock
|
|
defaultExpectation *SessionRepositoryMockUpdateAccessTokenExpectation
|
|
expectations []*SessionRepositoryMockUpdateAccessTokenExpectation
|
|
|
|
callArgs []*SessionRepositoryMockUpdateAccessTokenParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// SessionRepositoryMockUpdateAccessTokenExpectation specifies expectation struct of the SessionRepository.UpdateAccessToken
|
|
type SessionRepositoryMockUpdateAccessTokenExpectation struct {
|
|
mock *SessionRepositoryMock
|
|
params *SessionRepositoryMockUpdateAccessTokenParams
|
|
paramPtrs *SessionRepositoryMockUpdateAccessTokenParamPtrs
|
|
expectationOrigins SessionRepositoryMockUpdateAccessTokenExpectationOrigins
|
|
results *SessionRepositoryMockUpdateAccessTokenResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// SessionRepositoryMockUpdateAccessTokenParams contains parameters of the SessionRepository.UpdateAccessToken
|
|
type SessionRepositoryMockUpdateAccessTokenParams struct {
|
|
ctx context.Context
|
|
refreshToken string
|
|
newAccessToken string
|
|
}
|
|
|
|
// SessionRepositoryMockUpdateAccessTokenParamPtrs contains pointers to parameters of the SessionRepository.UpdateAccessToken
|
|
type SessionRepositoryMockUpdateAccessTokenParamPtrs struct {
|
|
ctx *context.Context
|
|
refreshToken *string
|
|
newAccessToken *string
|
|
}
|
|
|
|
// SessionRepositoryMockUpdateAccessTokenResults contains results of the SessionRepository.UpdateAccessToken
|
|
type SessionRepositoryMockUpdateAccessTokenResults struct {
|
|
err error
|
|
}
|
|
|
|
// SessionRepositoryMockUpdateAccessTokenOrigins contains origins of expectations of the SessionRepository.UpdateAccessToken
|
|
type SessionRepositoryMockUpdateAccessTokenExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originRefreshToken string
|
|
originNewAccessToken string
|
|
}
|
|
|
|
// 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 (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Optional() *mSessionRepositoryMockUpdateAccessToken {
|
|
mmUpdateAccessToken.optional = true
|
|
return mmUpdateAccessToken
|
|
}
|
|
|
|
// Expect sets up expected params for SessionRepository.UpdateAccessToken
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Expect(ctx context.Context, refreshToken string, newAccessToken string) *mSessionRepositoryMockUpdateAccessToken {
|
|
if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation == nil {
|
|
mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{}
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation.paramPtrs != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmUpdateAccessToken.defaultExpectation.params = &SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken}
|
|
mmUpdateAccessToken.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmUpdateAccessToken.expectations {
|
|
if minimock.Equal(e.params, mmUpdateAccessToken.defaultExpectation.params) {
|
|
mmUpdateAccessToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateAccessToken.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmUpdateAccessToken
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.UpdateAccessToken
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockUpdateAccessToken {
|
|
if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation == nil {
|
|
mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{}
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation.params != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Expect")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation.paramPtrs == nil {
|
|
mmUpdateAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockUpdateAccessTokenParamPtrs{}
|
|
}
|
|
mmUpdateAccessToken.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmUpdateAccessToken.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmUpdateAccessToken
|
|
}
|
|
|
|
// ExpectRefreshTokenParam2 sets up expected param refreshToken for SessionRepository.UpdateAccessToken
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) ExpectRefreshTokenParam2(refreshToken string) *mSessionRepositoryMockUpdateAccessToken {
|
|
if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation == nil {
|
|
mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{}
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation.params != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Expect")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation.paramPtrs == nil {
|
|
mmUpdateAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockUpdateAccessTokenParamPtrs{}
|
|
}
|
|
mmUpdateAccessToken.defaultExpectation.paramPtrs.refreshToken = &refreshToken
|
|
mmUpdateAccessToken.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1)
|
|
|
|
return mmUpdateAccessToken
|
|
}
|
|
|
|
// ExpectNewAccessTokenParam3 sets up expected param newAccessToken for SessionRepository.UpdateAccessToken
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) ExpectNewAccessTokenParam3(newAccessToken string) *mSessionRepositoryMockUpdateAccessToken {
|
|
if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation == nil {
|
|
mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{}
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation.params != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Expect")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation.paramPtrs == nil {
|
|
mmUpdateAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockUpdateAccessTokenParamPtrs{}
|
|
}
|
|
mmUpdateAccessToken.defaultExpectation.paramPtrs.newAccessToken = &newAccessToken
|
|
mmUpdateAccessToken.defaultExpectation.expectationOrigins.originNewAccessToken = minimock.CallerInfo(1)
|
|
|
|
return mmUpdateAccessToken
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the SessionRepository.UpdateAccessToken
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Inspect(f func(ctx context.Context, refreshToken string, newAccessToken string)) *mSessionRepositoryMockUpdateAccessToken {
|
|
if mmUpdateAccessToken.mock.inspectFuncUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.UpdateAccessToken")
|
|
}
|
|
|
|
mmUpdateAccessToken.mock.inspectFuncUpdateAccessToken = f
|
|
|
|
return mmUpdateAccessToken
|
|
}
|
|
|
|
// Return sets up results that will be returned by SessionRepository.UpdateAccessToken
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Return(err error) *SessionRepositoryMock {
|
|
if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set")
|
|
}
|
|
|
|
if mmUpdateAccessToken.defaultExpectation == nil {
|
|
mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{mock: mmUpdateAccessToken.mock}
|
|
}
|
|
mmUpdateAccessToken.defaultExpectation.results = &SessionRepositoryMockUpdateAccessTokenResults{err}
|
|
mmUpdateAccessToken.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmUpdateAccessToken.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the SessionRepository.UpdateAccessToken method
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Set(f func(ctx context.Context, refreshToken string, newAccessToken string) (err error)) *SessionRepositoryMock {
|
|
if mmUpdateAccessToken.defaultExpectation != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("Default expectation is already set for the SessionRepository.UpdateAccessToken method")
|
|
}
|
|
|
|
if len(mmUpdateAccessToken.expectations) > 0 {
|
|
mmUpdateAccessToken.mock.t.Fatalf("Some expectations are already set for the SessionRepository.UpdateAccessToken method")
|
|
}
|
|
|
|
mmUpdateAccessToken.mock.funcUpdateAccessToken = f
|
|
mmUpdateAccessToken.mock.funcUpdateAccessTokenOrigin = minimock.CallerInfo(1)
|
|
return mmUpdateAccessToken.mock
|
|
}
|
|
|
|
// When sets expectation for the SessionRepository.UpdateAccessToken which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) When(ctx context.Context, refreshToken string, newAccessToken string) *SessionRepositoryMockUpdateAccessTokenExpectation {
|
|
if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set")
|
|
}
|
|
|
|
expectation := &SessionRepositoryMockUpdateAccessTokenExpectation{
|
|
mock: mmUpdateAccessToken.mock,
|
|
params: &SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken},
|
|
expectationOrigins: SessionRepositoryMockUpdateAccessTokenExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmUpdateAccessToken.expectations = append(mmUpdateAccessToken.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up SessionRepository.UpdateAccessToken return parameters for the expectation previously defined by the When method
|
|
func (e *SessionRepositoryMockUpdateAccessTokenExpectation) Then(err error) *SessionRepositoryMock {
|
|
e.results = &SessionRepositoryMockUpdateAccessTokenResults{err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times SessionRepository.UpdateAccessToken should be invoked
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Times(n uint64) *mSessionRepositoryMockUpdateAccessToken {
|
|
if n == 0 {
|
|
mmUpdateAccessToken.mock.t.Fatalf("Times of SessionRepositoryMock.UpdateAccessToken mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmUpdateAccessToken.expectedInvocations, n)
|
|
mmUpdateAccessToken.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmUpdateAccessToken
|
|
}
|
|
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) invocationsDone() bool {
|
|
if len(mmUpdateAccessToken.expectations) == 0 && mmUpdateAccessToken.defaultExpectation == nil && mmUpdateAccessToken.mock.funcUpdateAccessToken == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmUpdateAccessToken.mock.afterUpdateAccessTokenCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmUpdateAccessToken.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// UpdateAccessToken implements mm_repository.SessionRepository
|
|
func (mmUpdateAccessToken *SessionRepositoryMock) UpdateAccessToken(ctx context.Context, refreshToken string, newAccessToken string) (err error) {
|
|
mm_atomic.AddUint64(&mmUpdateAccessToken.beforeUpdateAccessTokenCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmUpdateAccessToken.afterUpdateAccessTokenCounter, 1)
|
|
|
|
mmUpdateAccessToken.t.Helper()
|
|
|
|
if mmUpdateAccessToken.inspectFuncUpdateAccessToken != nil {
|
|
mmUpdateAccessToken.inspectFuncUpdateAccessToken(ctx, refreshToken, newAccessToken)
|
|
}
|
|
|
|
mm_params := SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken}
|
|
|
|
// Record call args
|
|
mmUpdateAccessToken.UpdateAccessTokenMock.mutex.Lock()
|
|
mmUpdateAccessToken.UpdateAccessTokenMock.callArgs = append(mmUpdateAccessToken.UpdateAccessTokenMock.callArgs, &mm_params)
|
|
mmUpdateAccessToken.UpdateAccessTokenMock.mutex.Unlock()
|
|
|
|
for _, e := range mmUpdateAccessToken.UpdateAccessTokenMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.err
|
|
}
|
|
}
|
|
|
|
if mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.params
|
|
mm_want_ptrs := mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.refreshToken != nil && !minimock.Equal(*mm_want_ptrs.refreshToken, mm_got.refreshToken) {
|
|
mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.originRefreshToken, *mm_want_ptrs.refreshToken, mm_got.refreshToken, minimock.Diff(*mm_want_ptrs.refreshToken, mm_got.refreshToken))
|
|
}
|
|
|
|
if mm_want_ptrs.newAccessToken != nil && !minimock.Equal(*mm_want_ptrs.newAccessToken, mm_got.newAccessToken) {
|
|
mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameter newAccessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.originNewAccessToken, *mm_want_ptrs.newAccessToken, mm_got.newAccessToken, minimock.Diff(*mm_want_ptrs.newAccessToken, mm_got.newAccessToken))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmUpdateAccessToken.t.Fatal("No results are set for the SessionRepositoryMock.UpdateAccessToken")
|
|
}
|
|
return (*mm_results).err
|
|
}
|
|
if mmUpdateAccessToken.funcUpdateAccessToken != nil {
|
|
return mmUpdateAccessToken.funcUpdateAccessToken(ctx, refreshToken, newAccessToken)
|
|
}
|
|
mmUpdateAccessToken.t.Fatalf("Unexpected call to SessionRepositoryMock.UpdateAccessToken. %v %v %v", ctx, refreshToken, newAccessToken)
|
|
return
|
|
}
|
|
|
|
// UpdateAccessTokenAfterCounter returns a count of finished SessionRepositoryMock.UpdateAccessToken invocations
|
|
func (mmUpdateAccessToken *SessionRepositoryMock) UpdateAccessTokenAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmUpdateAccessToken.afterUpdateAccessTokenCounter)
|
|
}
|
|
|
|
// UpdateAccessTokenBeforeCounter returns a count of SessionRepositoryMock.UpdateAccessToken invocations
|
|
func (mmUpdateAccessToken *SessionRepositoryMock) UpdateAccessTokenBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmUpdateAccessToken.beforeUpdateAccessTokenCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to SessionRepositoryMock.UpdateAccessToken.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Calls() []*SessionRepositoryMockUpdateAccessTokenParams {
|
|
mmUpdateAccessToken.mutex.RLock()
|
|
|
|
argCopy := make([]*SessionRepositoryMockUpdateAccessTokenParams, len(mmUpdateAccessToken.callArgs))
|
|
copy(argCopy, mmUpdateAccessToken.callArgs)
|
|
|
|
mmUpdateAccessToken.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockUpdateAccessTokenDone returns true if the count of the UpdateAccessToken invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *SessionRepositoryMock) MinimockUpdateAccessTokenDone() bool {
|
|
if m.UpdateAccessTokenMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.UpdateAccessTokenMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.UpdateAccessTokenMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockUpdateAccessTokenInspect logs each unmet expectation
|
|
func (m *SessionRepositoryMock) MinimockUpdateAccessTokenInspect() {
|
|
for _, e := range m.UpdateAccessTokenMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterUpdateAccessTokenCounter := mm_atomic.LoadUint64(&m.afterUpdateAccessTokenCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.UpdateAccessTokenMock.defaultExpectation != nil && afterUpdateAccessTokenCounter < 1 {
|
|
if m.UpdateAccessTokenMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s", m.UpdateAccessTokenMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s with params: %#v", m.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.origin, *m.UpdateAccessTokenMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcUpdateAccessToken != nil && afterUpdateAccessTokenCounter < 1 {
|
|
m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s", m.funcUpdateAccessTokenOrigin)
|
|
}
|
|
|
|
if !m.UpdateAccessTokenMock.invocationsDone() && afterUpdateAccessTokenCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to SessionRepositoryMock.UpdateAccessToken at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.UpdateAccessTokenMock.expectedInvocations), m.UpdateAccessTokenMock.expectedInvocationsOrigin, afterUpdateAccessTokenCounter)
|
|
}
|
|
}
|
|
|
|
// MinimockFinish checks that all mocked methods have been called the expected number of times
|
|
func (m *SessionRepositoryMock) MinimockFinish() {
|
|
m.finishOnce.Do(func() {
|
|
if !m.minimockDone() {
|
|
m.MinimockCreateInspect()
|
|
|
|
m.MinimockDeleteExpiredInspect()
|
|
|
|
m.MinimockFindByRefreshTokenInspect()
|
|
|
|
m.MinimockIsAccessTokenValidInspect()
|
|
|
|
m.MinimockRevokeInspect()
|
|
|
|
m.MinimockRevokeByAccessTokenInspect()
|
|
|
|
m.MinimockUpdateAccessTokenInspect()
|
|
}
|
|
})
|
|
}
|
|
|
|
// MinimockWait waits for all mocked methods to be called the expected number of times
|
|
func (m *SessionRepositoryMock) 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 *SessionRepositoryMock) minimockDone() bool {
|
|
done := true
|
|
return done &&
|
|
m.MinimockCreateDone() &&
|
|
m.MinimockDeleteExpiredDone() &&
|
|
m.MinimockFindByRefreshTokenDone() &&
|
|
m.MinimockIsAccessTokenValidDone() &&
|
|
m.MinimockRevokeDone() &&
|
|
m.MinimockRevokeByAccessTokenDone() &&
|
|
m.MinimockUpdateAccessTokenDone()
|
|
}
|