Files
smart-search-back/internal/mocks/auth_service_mock.go
vallyenfail d959dcca96 add service
2026-01-17 17:39:33 +03:00

1579 lines
61 KiB
Go

// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT.
package mocks
//go:generate minimock -i smart-search-back/internal/service.AuthService -o auth_service_mock.go -n AuthServiceMock -p mocks
import (
"context"
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
)
// AuthServiceMock implements mm_service.AuthService
type AuthServiceMock struct {
t minimock.Tester
finishOnce sync.Once
funcLogin func(ctx context.Context, email string, password string, ip string, userAgent string) (accessToken string, refreshToken string, err error)
funcLoginOrigin string
inspectFuncLogin func(ctx context.Context, email string, password string, ip string, userAgent string)
afterLoginCounter uint64
beforeLoginCounter uint64
LoginMock mAuthServiceMockLogin
funcLogout func(ctx context.Context, refreshToken string) (err error)
funcLogoutOrigin string
inspectFuncLogout func(ctx context.Context, refreshToken string)
afterLogoutCounter uint64
beforeLogoutCounter uint64
LogoutMock mAuthServiceMockLogout
funcRefresh func(ctx context.Context, refreshToken string) (s1 string, err error)
funcRefreshOrigin string
inspectFuncRefresh func(ctx context.Context, refreshToken string)
afterRefreshCounter uint64
beforeRefreshCounter uint64
RefreshMock mAuthServiceMockRefresh
funcValidate func(ctx context.Context, accessToken string) (i1 int, err error)
funcValidateOrigin string
inspectFuncValidate func(ctx context.Context, accessToken string)
afterValidateCounter uint64
beforeValidateCounter uint64
ValidateMock mAuthServiceMockValidate
}
// NewAuthServiceMock returns a mock for mm_service.AuthService
func NewAuthServiceMock(t minimock.Tester) *AuthServiceMock {
m := &AuthServiceMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.LoginMock = mAuthServiceMockLogin{mock: m}
m.LoginMock.callArgs = []*AuthServiceMockLoginParams{}
m.LogoutMock = mAuthServiceMockLogout{mock: m}
m.LogoutMock.callArgs = []*AuthServiceMockLogoutParams{}
m.RefreshMock = mAuthServiceMockRefresh{mock: m}
m.RefreshMock.callArgs = []*AuthServiceMockRefreshParams{}
m.ValidateMock = mAuthServiceMockValidate{mock: m}
m.ValidateMock.callArgs = []*AuthServiceMockValidateParams{}
t.Cleanup(m.MinimockFinish)
return m
}
type mAuthServiceMockLogin struct {
optional bool
mock *AuthServiceMock
defaultExpectation *AuthServiceMockLoginExpectation
expectations []*AuthServiceMockLoginExpectation
callArgs []*AuthServiceMockLoginParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// AuthServiceMockLoginExpectation specifies expectation struct of the AuthService.Login
type AuthServiceMockLoginExpectation struct {
mock *AuthServiceMock
params *AuthServiceMockLoginParams
paramPtrs *AuthServiceMockLoginParamPtrs
expectationOrigins AuthServiceMockLoginExpectationOrigins
results *AuthServiceMockLoginResults
returnOrigin string
Counter uint64
}
// AuthServiceMockLoginParams contains parameters of the AuthService.Login
type AuthServiceMockLoginParams struct {
ctx context.Context
email string
password string
ip string
userAgent string
}
// AuthServiceMockLoginParamPtrs contains pointers to parameters of the AuthService.Login
type AuthServiceMockLoginParamPtrs struct {
ctx *context.Context
email *string
password *string
ip *string
userAgent *string
}
// AuthServiceMockLoginResults contains results of the AuthService.Login
type AuthServiceMockLoginResults struct {
accessToken string
refreshToken string
err error
}
// AuthServiceMockLoginOrigins contains origins of expectations of the AuthService.Login
type AuthServiceMockLoginExpectationOrigins struct {
origin string
originCtx string
originEmail string
originPassword string
originIp string
originUserAgent 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 (mmLogin *mAuthServiceMockLogin) Optional() *mAuthServiceMockLogin {
mmLogin.optional = true
return mmLogin
}
// Expect sets up expected params for AuthService.Login
func (mmLogin *mAuthServiceMockLogin) Expect(ctx context.Context, email string, password string, ip string, userAgent string) *mAuthServiceMockLogin {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
if mmLogin.defaultExpectation == nil {
mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{}
}
if mmLogin.defaultExpectation.paramPtrs != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by ExpectParams functions")
}
mmLogin.defaultExpectation.params = &AuthServiceMockLoginParams{ctx, email, password, ip, userAgent}
mmLogin.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmLogin.expectations {
if minimock.Equal(e.params, mmLogin.defaultExpectation.params) {
mmLogin.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmLogin.defaultExpectation.params)
}
}
return mmLogin
}
// ExpectCtxParam1 sets up expected param ctx for AuthService.Login
func (mmLogin *mAuthServiceMockLogin) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockLogin {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
if mmLogin.defaultExpectation == nil {
mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{}
}
if mmLogin.defaultExpectation.params != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect")
}
if mmLogin.defaultExpectation.paramPtrs == nil {
mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{}
}
mmLogin.defaultExpectation.paramPtrs.ctx = &ctx
mmLogin.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmLogin
}
// ExpectEmailParam2 sets up expected param email for AuthService.Login
func (mmLogin *mAuthServiceMockLogin) ExpectEmailParam2(email string) *mAuthServiceMockLogin {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
if mmLogin.defaultExpectation == nil {
mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{}
}
if mmLogin.defaultExpectation.params != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect")
}
if mmLogin.defaultExpectation.paramPtrs == nil {
mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{}
}
mmLogin.defaultExpectation.paramPtrs.email = &email
mmLogin.defaultExpectation.expectationOrigins.originEmail = minimock.CallerInfo(1)
return mmLogin
}
// ExpectPasswordParam3 sets up expected param password for AuthService.Login
func (mmLogin *mAuthServiceMockLogin) ExpectPasswordParam3(password string) *mAuthServiceMockLogin {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
if mmLogin.defaultExpectation == nil {
mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{}
}
if mmLogin.defaultExpectation.params != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect")
}
if mmLogin.defaultExpectation.paramPtrs == nil {
mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{}
}
mmLogin.defaultExpectation.paramPtrs.password = &password
mmLogin.defaultExpectation.expectationOrigins.originPassword = minimock.CallerInfo(1)
return mmLogin
}
// ExpectIpParam4 sets up expected param ip for AuthService.Login
func (mmLogin *mAuthServiceMockLogin) ExpectIpParam4(ip string) *mAuthServiceMockLogin {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
if mmLogin.defaultExpectation == nil {
mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{}
}
if mmLogin.defaultExpectation.params != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect")
}
if mmLogin.defaultExpectation.paramPtrs == nil {
mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{}
}
mmLogin.defaultExpectation.paramPtrs.ip = &ip
mmLogin.defaultExpectation.expectationOrigins.originIp = minimock.CallerInfo(1)
return mmLogin
}
// ExpectUserAgentParam5 sets up expected param userAgent for AuthService.Login
func (mmLogin *mAuthServiceMockLogin) ExpectUserAgentParam5(userAgent string) *mAuthServiceMockLogin {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
if mmLogin.defaultExpectation == nil {
mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{}
}
if mmLogin.defaultExpectation.params != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect")
}
if mmLogin.defaultExpectation.paramPtrs == nil {
mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{}
}
mmLogin.defaultExpectation.paramPtrs.userAgent = &userAgent
mmLogin.defaultExpectation.expectationOrigins.originUserAgent = minimock.CallerInfo(1)
return mmLogin
}
// Inspect accepts an inspector function that has same arguments as the AuthService.Login
func (mmLogin *mAuthServiceMockLogin) Inspect(f func(ctx context.Context, email string, password string, ip string, userAgent string)) *mAuthServiceMockLogin {
if mmLogin.mock.inspectFuncLogin != nil {
mmLogin.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Login")
}
mmLogin.mock.inspectFuncLogin = f
return mmLogin
}
// Return sets up results that will be returned by AuthService.Login
func (mmLogin *mAuthServiceMockLogin) Return(accessToken string, refreshToken string, err error) *AuthServiceMock {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
if mmLogin.defaultExpectation == nil {
mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{mock: mmLogin.mock}
}
mmLogin.defaultExpectation.results = &AuthServiceMockLoginResults{accessToken, refreshToken, err}
mmLogin.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmLogin.mock
}
// Set uses given function f to mock the AuthService.Login method
func (mmLogin *mAuthServiceMockLogin) Set(f func(ctx context.Context, email string, password string, ip string, userAgent string) (accessToken string, refreshToken string, err error)) *AuthServiceMock {
if mmLogin.defaultExpectation != nil {
mmLogin.mock.t.Fatalf("Default expectation is already set for the AuthService.Login method")
}
if len(mmLogin.expectations) > 0 {
mmLogin.mock.t.Fatalf("Some expectations are already set for the AuthService.Login method")
}
mmLogin.mock.funcLogin = f
mmLogin.mock.funcLoginOrigin = minimock.CallerInfo(1)
return mmLogin.mock
}
// When sets expectation for the AuthService.Login which will trigger the result defined by the following
// Then helper
func (mmLogin *mAuthServiceMockLogin) When(ctx context.Context, email string, password string, ip string, userAgent string) *AuthServiceMockLoginExpectation {
if mmLogin.mock.funcLogin != nil {
mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set")
}
expectation := &AuthServiceMockLoginExpectation{
mock: mmLogin.mock,
params: &AuthServiceMockLoginParams{ctx, email, password, ip, userAgent},
expectationOrigins: AuthServiceMockLoginExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmLogin.expectations = append(mmLogin.expectations, expectation)
return expectation
}
// Then sets up AuthService.Login return parameters for the expectation previously defined by the When method
func (e *AuthServiceMockLoginExpectation) Then(accessToken string, refreshToken string, err error) *AuthServiceMock {
e.results = &AuthServiceMockLoginResults{accessToken, refreshToken, err}
return e.mock
}
// Times sets number of times AuthService.Login should be invoked
func (mmLogin *mAuthServiceMockLogin) Times(n uint64) *mAuthServiceMockLogin {
if n == 0 {
mmLogin.mock.t.Fatalf("Times of AuthServiceMock.Login mock can not be zero")
}
mm_atomic.StoreUint64(&mmLogin.expectedInvocations, n)
mmLogin.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmLogin
}
func (mmLogin *mAuthServiceMockLogin) invocationsDone() bool {
if len(mmLogin.expectations) == 0 && mmLogin.defaultExpectation == nil && mmLogin.mock.funcLogin == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmLogin.mock.afterLoginCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmLogin.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// Login implements mm_service.AuthService
func (mmLogin *AuthServiceMock) Login(ctx context.Context, email string, password string, ip string, userAgent string) (accessToken string, refreshToken string, err error) {
mm_atomic.AddUint64(&mmLogin.beforeLoginCounter, 1)
defer mm_atomic.AddUint64(&mmLogin.afterLoginCounter, 1)
mmLogin.t.Helper()
if mmLogin.inspectFuncLogin != nil {
mmLogin.inspectFuncLogin(ctx, email, password, ip, userAgent)
}
mm_params := AuthServiceMockLoginParams{ctx, email, password, ip, userAgent}
// Record call args
mmLogin.LoginMock.mutex.Lock()
mmLogin.LoginMock.callArgs = append(mmLogin.LoginMock.callArgs, &mm_params)
mmLogin.LoginMock.mutex.Unlock()
for _, e := range mmLogin.LoginMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.accessToken, e.results.refreshToken, e.results.err
}
}
if mmLogin.LoginMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmLogin.LoginMock.defaultExpectation.Counter, 1)
mm_want := mmLogin.LoginMock.defaultExpectation.params
mm_want_ptrs := mmLogin.LoginMock.defaultExpectation.paramPtrs
mm_got := AuthServiceMockLoginParams{ctx, email, password, ip, userAgent}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogin.LoginMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
}
if mm_want_ptrs.email != nil && !minimock.Equal(*mm_want_ptrs.email, mm_got.email) {
mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter email, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogin.LoginMock.defaultExpectation.expectationOrigins.originEmail, *mm_want_ptrs.email, mm_got.email, minimock.Diff(*mm_want_ptrs.email, mm_got.email))
}
if mm_want_ptrs.password != nil && !minimock.Equal(*mm_want_ptrs.password, mm_got.password) {
mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter password, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogin.LoginMock.defaultExpectation.expectationOrigins.originPassword, *mm_want_ptrs.password, mm_got.password, minimock.Diff(*mm_want_ptrs.password, mm_got.password))
}
if mm_want_ptrs.ip != nil && !minimock.Equal(*mm_want_ptrs.ip, mm_got.ip) {
mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter ip, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogin.LoginMock.defaultExpectation.expectationOrigins.originIp, *mm_want_ptrs.ip, mm_got.ip, minimock.Diff(*mm_want_ptrs.ip, mm_got.ip))
}
if mm_want_ptrs.userAgent != nil && !minimock.Equal(*mm_want_ptrs.userAgent, mm_got.userAgent) {
mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter userAgent, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogin.LoginMock.defaultExpectation.expectationOrigins.originUserAgent, *mm_want_ptrs.userAgent, mm_got.userAgent, minimock.Diff(*mm_want_ptrs.userAgent, mm_got.userAgent))
}
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogin.LoginMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmLogin.LoginMock.defaultExpectation.results
if mm_results == nil {
mmLogin.t.Fatal("No results are set for the AuthServiceMock.Login")
}
return (*mm_results).accessToken, (*mm_results).refreshToken, (*mm_results).err
}
if mmLogin.funcLogin != nil {
return mmLogin.funcLogin(ctx, email, password, ip, userAgent)
}
mmLogin.t.Fatalf("Unexpected call to AuthServiceMock.Login. %v %v %v %v %v", ctx, email, password, ip, userAgent)
return
}
// LoginAfterCounter returns a count of finished AuthServiceMock.Login invocations
func (mmLogin *AuthServiceMock) LoginAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmLogin.afterLoginCounter)
}
// LoginBeforeCounter returns a count of AuthServiceMock.Login invocations
func (mmLogin *AuthServiceMock) LoginBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmLogin.beforeLoginCounter)
}
// Calls returns a list of arguments used in each call to AuthServiceMock.Login.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmLogin *mAuthServiceMockLogin) Calls() []*AuthServiceMockLoginParams {
mmLogin.mutex.RLock()
argCopy := make([]*AuthServiceMockLoginParams, len(mmLogin.callArgs))
copy(argCopy, mmLogin.callArgs)
mmLogin.mutex.RUnlock()
return argCopy
}
// MinimockLoginDone returns true if the count of the Login invocations corresponds
// the number of defined expectations
func (m *AuthServiceMock) MinimockLoginDone() bool {
if m.LoginMock.optional {
// Optional methods provide '0 or more' call count restriction.
return true
}
for _, e := range m.LoginMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
return m.LoginMock.invocationsDone()
}
// MinimockLoginInspect logs each unmet expectation
func (m *AuthServiceMock) MinimockLoginInspect() {
for _, e := range m.LoginMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
}
}
afterLoginCounter := mm_atomic.LoadUint64(&m.afterLoginCounter)
// if default expectation was set then invocations count should be greater than zero
if m.LoginMock.defaultExpectation != nil && afterLoginCounter < 1 {
if m.LoginMock.defaultExpectation.params == nil {
m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s", m.LoginMock.defaultExpectation.returnOrigin)
} else {
m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s with params: %#v", m.LoginMock.defaultExpectation.expectationOrigins.origin, *m.LoginMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcLogin != nil && afterLoginCounter < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s", m.funcLoginOrigin)
}
if !m.LoginMock.invocationsDone() && afterLoginCounter > 0 {
m.t.Errorf("Expected %d calls to AuthServiceMock.Login at\n%s but found %d calls",
mm_atomic.LoadUint64(&m.LoginMock.expectedInvocations), m.LoginMock.expectedInvocationsOrigin, afterLoginCounter)
}
}
type mAuthServiceMockLogout struct {
optional bool
mock *AuthServiceMock
defaultExpectation *AuthServiceMockLogoutExpectation
expectations []*AuthServiceMockLogoutExpectation
callArgs []*AuthServiceMockLogoutParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// AuthServiceMockLogoutExpectation specifies expectation struct of the AuthService.Logout
type AuthServiceMockLogoutExpectation struct {
mock *AuthServiceMock
params *AuthServiceMockLogoutParams
paramPtrs *AuthServiceMockLogoutParamPtrs
expectationOrigins AuthServiceMockLogoutExpectationOrigins
results *AuthServiceMockLogoutResults
returnOrigin string
Counter uint64
}
// AuthServiceMockLogoutParams contains parameters of the AuthService.Logout
type AuthServiceMockLogoutParams struct {
ctx context.Context
refreshToken string
}
// AuthServiceMockLogoutParamPtrs contains pointers to parameters of the AuthService.Logout
type AuthServiceMockLogoutParamPtrs struct {
ctx *context.Context
refreshToken *string
}
// AuthServiceMockLogoutResults contains results of the AuthService.Logout
type AuthServiceMockLogoutResults struct {
err error
}
// AuthServiceMockLogoutOrigins contains origins of expectations of the AuthService.Logout
type AuthServiceMockLogoutExpectationOrigins 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 (mmLogout *mAuthServiceMockLogout) Optional() *mAuthServiceMockLogout {
mmLogout.optional = true
return mmLogout
}
// Expect sets up expected params for AuthService.Logout
func (mmLogout *mAuthServiceMockLogout) Expect(ctx context.Context, refreshToken string) *mAuthServiceMockLogout {
if mmLogout.mock.funcLogout != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set")
}
if mmLogout.defaultExpectation == nil {
mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{}
}
if mmLogout.defaultExpectation.paramPtrs != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by ExpectParams functions")
}
mmLogout.defaultExpectation.params = &AuthServiceMockLogoutParams{ctx, refreshToken}
mmLogout.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmLogout.expectations {
if minimock.Equal(e.params, mmLogout.defaultExpectation.params) {
mmLogout.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmLogout.defaultExpectation.params)
}
}
return mmLogout
}
// ExpectCtxParam1 sets up expected param ctx for AuthService.Logout
func (mmLogout *mAuthServiceMockLogout) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockLogout {
if mmLogout.mock.funcLogout != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set")
}
if mmLogout.defaultExpectation == nil {
mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{}
}
if mmLogout.defaultExpectation.params != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Expect")
}
if mmLogout.defaultExpectation.paramPtrs == nil {
mmLogout.defaultExpectation.paramPtrs = &AuthServiceMockLogoutParamPtrs{}
}
mmLogout.defaultExpectation.paramPtrs.ctx = &ctx
mmLogout.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmLogout
}
// ExpectRefreshTokenParam2 sets up expected param refreshToken for AuthService.Logout
func (mmLogout *mAuthServiceMockLogout) ExpectRefreshTokenParam2(refreshToken string) *mAuthServiceMockLogout {
if mmLogout.mock.funcLogout != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set")
}
if mmLogout.defaultExpectation == nil {
mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{}
}
if mmLogout.defaultExpectation.params != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Expect")
}
if mmLogout.defaultExpectation.paramPtrs == nil {
mmLogout.defaultExpectation.paramPtrs = &AuthServiceMockLogoutParamPtrs{}
}
mmLogout.defaultExpectation.paramPtrs.refreshToken = &refreshToken
mmLogout.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1)
return mmLogout
}
// Inspect accepts an inspector function that has same arguments as the AuthService.Logout
func (mmLogout *mAuthServiceMockLogout) Inspect(f func(ctx context.Context, refreshToken string)) *mAuthServiceMockLogout {
if mmLogout.mock.inspectFuncLogout != nil {
mmLogout.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Logout")
}
mmLogout.mock.inspectFuncLogout = f
return mmLogout
}
// Return sets up results that will be returned by AuthService.Logout
func (mmLogout *mAuthServiceMockLogout) Return(err error) *AuthServiceMock {
if mmLogout.mock.funcLogout != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set")
}
if mmLogout.defaultExpectation == nil {
mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{mock: mmLogout.mock}
}
mmLogout.defaultExpectation.results = &AuthServiceMockLogoutResults{err}
mmLogout.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmLogout.mock
}
// Set uses given function f to mock the AuthService.Logout method
func (mmLogout *mAuthServiceMockLogout) Set(f func(ctx context.Context, refreshToken string) (err error)) *AuthServiceMock {
if mmLogout.defaultExpectation != nil {
mmLogout.mock.t.Fatalf("Default expectation is already set for the AuthService.Logout method")
}
if len(mmLogout.expectations) > 0 {
mmLogout.mock.t.Fatalf("Some expectations are already set for the AuthService.Logout method")
}
mmLogout.mock.funcLogout = f
mmLogout.mock.funcLogoutOrigin = minimock.CallerInfo(1)
return mmLogout.mock
}
// When sets expectation for the AuthService.Logout which will trigger the result defined by the following
// Then helper
func (mmLogout *mAuthServiceMockLogout) When(ctx context.Context, refreshToken string) *AuthServiceMockLogoutExpectation {
if mmLogout.mock.funcLogout != nil {
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set")
}
expectation := &AuthServiceMockLogoutExpectation{
mock: mmLogout.mock,
params: &AuthServiceMockLogoutParams{ctx, refreshToken},
expectationOrigins: AuthServiceMockLogoutExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmLogout.expectations = append(mmLogout.expectations, expectation)
return expectation
}
// Then sets up AuthService.Logout return parameters for the expectation previously defined by the When method
func (e *AuthServiceMockLogoutExpectation) Then(err error) *AuthServiceMock {
e.results = &AuthServiceMockLogoutResults{err}
return e.mock
}
// Times sets number of times AuthService.Logout should be invoked
func (mmLogout *mAuthServiceMockLogout) Times(n uint64) *mAuthServiceMockLogout {
if n == 0 {
mmLogout.mock.t.Fatalf("Times of AuthServiceMock.Logout mock can not be zero")
}
mm_atomic.StoreUint64(&mmLogout.expectedInvocations, n)
mmLogout.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmLogout
}
func (mmLogout *mAuthServiceMockLogout) invocationsDone() bool {
if len(mmLogout.expectations) == 0 && mmLogout.defaultExpectation == nil && mmLogout.mock.funcLogout == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmLogout.mock.afterLogoutCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmLogout.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// Logout implements mm_service.AuthService
func (mmLogout *AuthServiceMock) Logout(ctx context.Context, refreshToken string) (err error) {
mm_atomic.AddUint64(&mmLogout.beforeLogoutCounter, 1)
defer mm_atomic.AddUint64(&mmLogout.afterLogoutCounter, 1)
mmLogout.t.Helper()
if mmLogout.inspectFuncLogout != nil {
mmLogout.inspectFuncLogout(ctx, refreshToken)
}
mm_params := AuthServiceMockLogoutParams{ctx, refreshToken}
// Record call args
mmLogout.LogoutMock.mutex.Lock()
mmLogout.LogoutMock.callArgs = append(mmLogout.LogoutMock.callArgs, &mm_params)
mmLogout.LogoutMock.mutex.Unlock()
for _, e := range mmLogout.LogoutMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.err
}
}
if mmLogout.LogoutMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmLogout.LogoutMock.defaultExpectation.Counter, 1)
mm_want := mmLogout.LogoutMock.defaultExpectation.params
mm_want_ptrs := mmLogout.LogoutMock.defaultExpectation.paramPtrs
mm_got := AuthServiceMockLogoutParams{ctx, refreshToken}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmLogout.t.Errorf("AuthServiceMock.Logout got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogout.LogoutMock.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) {
mmLogout.t.Errorf("AuthServiceMock.Logout got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogout.LogoutMock.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) {
mmLogout.t.Errorf("AuthServiceMock.Logout got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmLogout.LogoutMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmLogout.LogoutMock.defaultExpectation.results
if mm_results == nil {
mmLogout.t.Fatal("No results are set for the AuthServiceMock.Logout")
}
return (*mm_results).err
}
if mmLogout.funcLogout != nil {
return mmLogout.funcLogout(ctx, refreshToken)
}
mmLogout.t.Fatalf("Unexpected call to AuthServiceMock.Logout. %v %v", ctx, refreshToken)
return
}
// LogoutAfterCounter returns a count of finished AuthServiceMock.Logout invocations
func (mmLogout *AuthServiceMock) LogoutAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmLogout.afterLogoutCounter)
}
// LogoutBeforeCounter returns a count of AuthServiceMock.Logout invocations
func (mmLogout *AuthServiceMock) LogoutBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmLogout.beforeLogoutCounter)
}
// Calls returns a list of arguments used in each call to AuthServiceMock.Logout.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmLogout *mAuthServiceMockLogout) Calls() []*AuthServiceMockLogoutParams {
mmLogout.mutex.RLock()
argCopy := make([]*AuthServiceMockLogoutParams, len(mmLogout.callArgs))
copy(argCopy, mmLogout.callArgs)
mmLogout.mutex.RUnlock()
return argCopy
}
// MinimockLogoutDone returns true if the count of the Logout invocations corresponds
// the number of defined expectations
func (m *AuthServiceMock) MinimockLogoutDone() bool {
if m.LogoutMock.optional {
// Optional methods provide '0 or more' call count restriction.
return true
}
for _, e := range m.LogoutMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
return m.LogoutMock.invocationsDone()
}
// MinimockLogoutInspect logs each unmet expectation
func (m *AuthServiceMock) MinimockLogoutInspect() {
for _, e := range m.LogoutMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
}
}
afterLogoutCounter := mm_atomic.LoadUint64(&m.afterLogoutCounter)
// if default expectation was set then invocations count should be greater than zero
if m.LogoutMock.defaultExpectation != nil && afterLogoutCounter < 1 {
if m.LogoutMock.defaultExpectation.params == nil {
m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s", m.LogoutMock.defaultExpectation.returnOrigin)
} else {
m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s with params: %#v", m.LogoutMock.defaultExpectation.expectationOrigins.origin, *m.LogoutMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcLogout != nil && afterLogoutCounter < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s", m.funcLogoutOrigin)
}
if !m.LogoutMock.invocationsDone() && afterLogoutCounter > 0 {
m.t.Errorf("Expected %d calls to AuthServiceMock.Logout at\n%s but found %d calls",
mm_atomic.LoadUint64(&m.LogoutMock.expectedInvocations), m.LogoutMock.expectedInvocationsOrigin, afterLogoutCounter)
}
}
type mAuthServiceMockRefresh struct {
optional bool
mock *AuthServiceMock
defaultExpectation *AuthServiceMockRefreshExpectation
expectations []*AuthServiceMockRefreshExpectation
callArgs []*AuthServiceMockRefreshParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// AuthServiceMockRefreshExpectation specifies expectation struct of the AuthService.Refresh
type AuthServiceMockRefreshExpectation struct {
mock *AuthServiceMock
params *AuthServiceMockRefreshParams
paramPtrs *AuthServiceMockRefreshParamPtrs
expectationOrigins AuthServiceMockRefreshExpectationOrigins
results *AuthServiceMockRefreshResults
returnOrigin string
Counter uint64
}
// AuthServiceMockRefreshParams contains parameters of the AuthService.Refresh
type AuthServiceMockRefreshParams struct {
ctx context.Context
refreshToken string
}
// AuthServiceMockRefreshParamPtrs contains pointers to parameters of the AuthService.Refresh
type AuthServiceMockRefreshParamPtrs struct {
ctx *context.Context
refreshToken *string
}
// AuthServiceMockRefreshResults contains results of the AuthService.Refresh
type AuthServiceMockRefreshResults struct {
s1 string
err error
}
// AuthServiceMockRefreshOrigins contains origins of expectations of the AuthService.Refresh
type AuthServiceMockRefreshExpectationOrigins 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 (mmRefresh *mAuthServiceMockRefresh) Optional() *mAuthServiceMockRefresh {
mmRefresh.optional = true
return mmRefresh
}
// Expect sets up expected params for AuthService.Refresh
func (mmRefresh *mAuthServiceMockRefresh) Expect(ctx context.Context, refreshToken string) *mAuthServiceMockRefresh {
if mmRefresh.mock.funcRefresh != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set")
}
if mmRefresh.defaultExpectation == nil {
mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{}
}
if mmRefresh.defaultExpectation.paramPtrs != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by ExpectParams functions")
}
mmRefresh.defaultExpectation.params = &AuthServiceMockRefreshParams{ctx, refreshToken}
mmRefresh.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmRefresh.expectations {
if minimock.Equal(e.params, mmRefresh.defaultExpectation.params) {
mmRefresh.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRefresh.defaultExpectation.params)
}
}
return mmRefresh
}
// ExpectCtxParam1 sets up expected param ctx for AuthService.Refresh
func (mmRefresh *mAuthServiceMockRefresh) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockRefresh {
if mmRefresh.mock.funcRefresh != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set")
}
if mmRefresh.defaultExpectation == nil {
mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{}
}
if mmRefresh.defaultExpectation.params != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Expect")
}
if mmRefresh.defaultExpectation.paramPtrs == nil {
mmRefresh.defaultExpectation.paramPtrs = &AuthServiceMockRefreshParamPtrs{}
}
mmRefresh.defaultExpectation.paramPtrs.ctx = &ctx
mmRefresh.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmRefresh
}
// ExpectRefreshTokenParam2 sets up expected param refreshToken for AuthService.Refresh
func (mmRefresh *mAuthServiceMockRefresh) ExpectRefreshTokenParam2(refreshToken string) *mAuthServiceMockRefresh {
if mmRefresh.mock.funcRefresh != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set")
}
if mmRefresh.defaultExpectation == nil {
mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{}
}
if mmRefresh.defaultExpectation.params != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Expect")
}
if mmRefresh.defaultExpectation.paramPtrs == nil {
mmRefresh.defaultExpectation.paramPtrs = &AuthServiceMockRefreshParamPtrs{}
}
mmRefresh.defaultExpectation.paramPtrs.refreshToken = &refreshToken
mmRefresh.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1)
return mmRefresh
}
// Inspect accepts an inspector function that has same arguments as the AuthService.Refresh
func (mmRefresh *mAuthServiceMockRefresh) Inspect(f func(ctx context.Context, refreshToken string)) *mAuthServiceMockRefresh {
if mmRefresh.mock.inspectFuncRefresh != nil {
mmRefresh.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Refresh")
}
mmRefresh.mock.inspectFuncRefresh = f
return mmRefresh
}
// Return sets up results that will be returned by AuthService.Refresh
func (mmRefresh *mAuthServiceMockRefresh) Return(s1 string, err error) *AuthServiceMock {
if mmRefresh.mock.funcRefresh != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set")
}
if mmRefresh.defaultExpectation == nil {
mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{mock: mmRefresh.mock}
}
mmRefresh.defaultExpectation.results = &AuthServiceMockRefreshResults{s1, err}
mmRefresh.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmRefresh.mock
}
// Set uses given function f to mock the AuthService.Refresh method
func (mmRefresh *mAuthServiceMockRefresh) Set(f func(ctx context.Context, refreshToken string) (s1 string, err error)) *AuthServiceMock {
if mmRefresh.defaultExpectation != nil {
mmRefresh.mock.t.Fatalf("Default expectation is already set for the AuthService.Refresh method")
}
if len(mmRefresh.expectations) > 0 {
mmRefresh.mock.t.Fatalf("Some expectations are already set for the AuthService.Refresh method")
}
mmRefresh.mock.funcRefresh = f
mmRefresh.mock.funcRefreshOrigin = minimock.CallerInfo(1)
return mmRefresh.mock
}
// When sets expectation for the AuthService.Refresh which will trigger the result defined by the following
// Then helper
func (mmRefresh *mAuthServiceMockRefresh) When(ctx context.Context, refreshToken string) *AuthServiceMockRefreshExpectation {
if mmRefresh.mock.funcRefresh != nil {
mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set")
}
expectation := &AuthServiceMockRefreshExpectation{
mock: mmRefresh.mock,
params: &AuthServiceMockRefreshParams{ctx, refreshToken},
expectationOrigins: AuthServiceMockRefreshExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmRefresh.expectations = append(mmRefresh.expectations, expectation)
return expectation
}
// Then sets up AuthService.Refresh return parameters for the expectation previously defined by the When method
func (e *AuthServiceMockRefreshExpectation) Then(s1 string, err error) *AuthServiceMock {
e.results = &AuthServiceMockRefreshResults{s1, err}
return e.mock
}
// Times sets number of times AuthService.Refresh should be invoked
func (mmRefresh *mAuthServiceMockRefresh) Times(n uint64) *mAuthServiceMockRefresh {
if n == 0 {
mmRefresh.mock.t.Fatalf("Times of AuthServiceMock.Refresh mock can not be zero")
}
mm_atomic.StoreUint64(&mmRefresh.expectedInvocations, n)
mmRefresh.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmRefresh
}
func (mmRefresh *mAuthServiceMockRefresh) invocationsDone() bool {
if len(mmRefresh.expectations) == 0 && mmRefresh.defaultExpectation == nil && mmRefresh.mock.funcRefresh == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmRefresh.mock.afterRefreshCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmRefresh.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// Refresh implements mm_service.AuthService
func (mmRefresh *AuthServiceMock) Refresh(ctx context.Context, refreshToken string) (s1 string, err error) {
mm_atomic.AddUint64(&mmRefresh.beforeRefreshCounter, 1)
defer mm_atomic.AddUint64(&mmRefresh.afterRefreshCounter, 1)
mmRefresh.t.Helper()
if mmRefresh.inspectFuncRefresh != nil {
mmRefresh.inspectFuncRefresh(ctx, refreshToken)
}
mm_params := AuthServiceMockRefreshParams{ctx, refreshToken}
// Record call args
mmRefresh.RefreshMock.mutex.Lock()
mmRefresh.RefreshMock.callArgs = append(mmRefresh.RefreshMock.callArgs, &mm_params)
mmRefresh.RefreshMock.mutex.Unlock()
for _, e := range mmRefresh.RefreshMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.s1, e.results.err
}
}
if mmRefresh.RefreshMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmRefresh.RefreshMock.defaultExpectation.Counter, 1)
mm_want := mmRefresh.RefreshMock.defaultExpectation.params
mm_want_ptrs := mmRefresh.RefreshMock.defaultExpectation.paramPtrs
mm_got := AuthServiceMockRefreshParams{ctx, refreshToken}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmRefresh.t.Errorf("AuthServiceMock.Refresh got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmRefresh.RefreshMock.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) {
mmRefresh.t.Errorf("AuthServiceMock.Refresh got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmRefresh.RefreshMock.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) {
mmRefresh.t.Errorf("AuthServiceMock.Refresh got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmRefresh.RefreshMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmRefresh.RefreshMock.defaultExpectation.results
if mm_results == nil {
mmRefresh.t.Fatal("No results are set for the AuthServiceMock.Refresh")
}
return (*mm_results).s1, (*mm_results).err
}
if mmRefresh.funcRefresh != nil {
return mmRefresh.funcRefresh(ctx, refreshToken)
}
mmRefresh.t.Fatalf("Unexpected call to AuthServiceMock.Refresh. %v %v", ctx, refreshToken)
return
}
// RefreshAfterCounter returns a count of finished AuthServiceMock.Refresh invocations
func (mmRefresh *AuthServiceMock) RefreshAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmRefresh.afterRefreshCounter)
}
// RefreshBeforeCounter returns a count of AuthServiceMock.Refresh invocations
func (mmRefresh *AuthServiceMock) RefreshBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmRefresh.beforeRefreshCounter)
}
// Calls returns a list of arguments used in each call to AuthServiceMock.Refresh.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmRefresh *mAuthServiceMockRefresh) Calls() []*AuthServiceMockRefreshParams {
mmRefresh.mutex.RLock()
argCopy := make([]*AuthServiceMockRefreshParams, len(mmRefresh.callArgs))
copy(argCopy, mmRefresh.callArgs)
mmRefresh.mutex.RUnlock()
return argCopy
}
// MinimockRefreshDone returns true if the count of the Refresh invocations corresponds
// the number of defined expectations
func (m *AuthServiceMock) MinimockRefreshDone() bool {
if m.RefreshMock.optional {
// Optional methods provide '0 or more' call count restriction.
return true
}
for _, e := range m.RefreshMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
return m.RefreshMock.invocationsDone()
}
// MinimockRefreshInspect logs each unmet expectation
func (m *AuthServiceMock) MinimockRefreshInspect() {
for _, e := range m.RefreshMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
}
}
afterRefreshCounter := mm_atomic.LoadUint64(&m.afterRefreshCounter)
// if default expectation was set then invocations count should be greater than zero
if m.RefreshMock.defaultExpectation != nil && afterRefreshCounter < 1 {
if m.RefreshMock.defaultExpectation.params == nil {
m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s", m.RefreshMock.defaultExpectation.returnOrigin)
} else {
m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s with params: %#v", m.RefreshMock.defaultExpectation.expectationOrigins.origin, *m.RefreshMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcRefresh != nil && afterRefreshCounter < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s", m.funcRefreshOrigin)
}
if !m.RefreshMock.invocationsDone() && afterRefreshCounter > 0 {
m.t.Errorf("Expected %d calls to AuthServiceMock.Refresh at\n%s but found %d calls",
mm_atomic.LoadUint64(&m.RefreshMock.expectedInvocations), m.RefreshMock.expectedInvocationsOrigin, afterRefreshCounter)
}
}
type mAuthServiceMockValidate struct {
optional bool
mock *AuthServiceMock
defaultExpectation *AuthServiceMockValidateExpectation
expectations []*AuthServiceMockValidateExpectation
callArgs []*AuthServiceMockValidateParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// AuthServiceMockValidateExpectation specifies expectation struct of the AuthService.Validate
type AuthServiceMockValidateExpectation struct {
mock *AuthServiceMock
params *AuthServiceMockValidateParams
paramPtrs *AuthServiceMockValidateParamPtrs
expectationOrigins AuthServiceMockValidateExpectationOrigins
results *AuthServiceMockValidateResults
returnOrigin string
Counter uint64
}
// AuthServiceMockValidateParams contains parameters of the AuthService.Validate
type AuthServiceMockValidateParams struct {
ctx context.Context
accessToken string
}
// AuthServiceMockValidateParamPtrs contains pointers to parameters of the AuthService.Validate
type AuthServiceMockValidateParamPtrs struct {
ctx *context.Context
accessToken *string
}
// AuthServiceMockValidateResults contains results of the AuthService.Validate
type AuthServiceMockValidateResults struct {
i1 int
err error
}
// AuthServiceMockValidateOrigins contains origins of expectations of the AuthService.Validate
type AuthServiceMockValidateExpectationOrigins 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 (mmValidate *mAuthServiceMockValidate) Optional() *mAuthServiceMockValidate {
mmValidate.optional = true
return mmValidate
}
// Expect sets up expected params for AuthService.Validate
func (mmValidate *mAuthServiceMockValidate) Expect(ctx context.Context, accessToken string) *mAuthServiceMockValidate {
if mmValidate.mock.funcValidate != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set")
}
if mmValidate.defaultExpectation == nil {
mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{}
}
if mmValidate.defaultExpectation.paramPtrs != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by ExpectParams functions")
}
mmValidate.defaultExpectation.params = &AuthServiceMockValidateParams{ctx, accessToken}
mmValidate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmValidate.expectations {
if minimock.Equal(e.params, mmValidate.defaultExpectation.params) {
mmValidate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmValidate.defaultExpectation.params)
}
}
return mmValidate
}
// ExpectCtxParam1 sets up expected param ctx for AuthService.Validate
func (mmValidate *mAuthServiceMockValidate) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockValidate {
if mmValidate.mock.funcValidate != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set")
}
if mmValidate.defaultExpectation == nil {
mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{}
}
if mmValidate.defaultExpectation.params != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Expect")
}
if mmValidate.defaultExpectation.paramPtrs == nil {
mmValidate.defaultExpectation.paramPtrs = &AuthServiceMockValidateParamPtrs{}
}
mmValidate.defaultExpectation.paramPtrs.ctx = &ctx
mmValidate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmValidate
}
// ExpectAccessTokenParam2 sets up expected param accessToken for AuthService.Validate
func (mmValidate *mAuthServiceMockValidate) ExpectAccessTokenParam2(accessToken string) *mAuthServiceMockValidate {
if mmValidate.mock.funcValidate != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set")
}
if mmValidate.defaultExpectation == nil {
mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{}
}
if mmValidate.defaultExpectation.params != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Expect")
}
if mmValidate.defaultExpectation.paramPtrs == nil {
mmValidate.defaultExpectation.paramPtrs = &AuthServiceMockValidateParamPtrs{}
}
mmValidate.defaultExpectation.paramPtrs.accessToken = &accessToken
mmValidate.defaultExpectation.expectationOrigins.originAccessToken = minimock.CallerInfo(1)
return mmValidate
}
// Inspect accepts an inspector function that has same arguments as the AuthService.Validate
func (mmValidate *mAuthServiceMockValidate) Inspect(f func(ctx context.Context, accessToken string)) *mAuthServiceMockValidate {
if mmValidate.mock.inspectFuncValidate != nil {
mmValidate.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Validate")
}
mmValidate.mock.inspectFuncValidate = f
return mmValidate
}
// Return sets up results that will be returned by AuthService.Validate
func (mmValidate *mAuthServiceMockValidate) Return(i1 int, err error) *AuthServiceMock {
if mmValidate.mock.funcValidate != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set")
}
if mmValidate.defaultExpectation == nil {
mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{mock: mmValidate.mock}
}
mmValidate.defaultExpectation.results = &AuthServiceMockValidateResults{i1, err}
mmValidate.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmValidate.mock
}
// Set uses given function f to mock the AuthService.Validate method
func (mmValidate *mAuthServiceMockValidate) Set(f func(ctx context.Context, accessToken string) (i1 int, err error)) *AuthServiceMock {
if mmValidate.defaultExpectation != nil {
mmValidate.mock.t.Fatalf("Default expectation is already set for the AuthService.Validate method")
}
if len(mmValidate.expectations) > 0 {
mmValidate.mock.t.Fatalf("Some expectations are already set for the AuthService.Validate method")
}
mmValidate.mock.funcValidate = f
mmValidate.mock.funcValidateOrigin = minimock.CallerInfo(1)
return mmValidate.mock
}
// When sets expectation for the AuthService.Validate which will trigger the result defined by the following
// Then helper
func (mmValidate *mAuthServiceMockValidate) When(ctx context.Context, accessToken string) *AuthServiceMockValidateExpectation {
if mmValidate.mock.funcValidate != nil {
mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set")
}
expectation := &AuthServiceMockValidateExpectation{
mock: mmValidate.mock,
params: &AuthServiceMockValidateParams{ctx, accessToken},
expectationOrigins: AuthServiceMockValidateExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmValidate.expectations = append(mmValidate.expectations, expectation)
return expectation
}
// Then sets up AuthService.Validate return parameters for the expectation previously defined by the When method
func (e *AuthServiceMockValidateExpectation) Then(i1 int, err error) *AuthServiceMock {
e.results = &AuthServiceMockValidateResults{i1, err}
return e.mock
}
// Times sets number of times AuthService.Validate should be invoked
func (mmValidate *mAuthServiceMockValidate) Times(n uint64) *mAuthServiceMockValidate {
if n == 0 {
mmValidate.mock.t.Fatalf("Times of AuthServiceMock.Validate mock can not be zero")
}
mm_atomic.StoreUint64(&mmValidate.expectedInvocations, n)
mmValidate.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmValidate
}
func (mmValidate *mAuthServiceMockValidate) invocationsDone() bool {
if len(mmValidate.expectations) == 0 && mmValidate.defaultExpectation == nil && mmValidate.mock.funcValidate == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmValidate.mock.afterValidateCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmValidate.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// Validate implements mm_service.AuthService
func (mmValidate *AuthServiceMock) Validate(ctx context.Context, accessToken string) (i1 int, err error) {
mm_atomic.AddUint64(&mmValidate.beforeValidateCounter, 1)
defer mm_atomic.AddUint64(&mmValidate.afterValidateCounter, 1)
mmValidate.t.Helper()
if mmValidate.inspectFuncValidate != nil {
mmValidate.inspectFuncValidate(ctx, accessToken)
}
mm_params := AuthServiceMockValidateParams{ctx, accessToken}
// Record call args
mmValidate.ValidateMock.mutex.Lock()
mmValidate.ValidateMock.callArgs = append(mmValidate.ValidateMock.callArgs, &mm_params)
mmValidate.ValidateMock.mutex.Unlock()
for _, e := range mmValidate.ValidateMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.i1, e.results.err
}
}
if mmValidate.ValidateMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmValidate.ValidateMock.defaultExpectation.Counter, 1)
mm_want := mmValidate.ValidateMock.defaultExpectation.params
mm_want_ptrs := mmValidate.ValidateMock.defaultExpectation.paramPtrs
mm_got := AuthServiceMockValidateParams{ctx, accessToken}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmValidate.t.Errorf("AuthServiceMock.Validate got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmValidate.ValidateMock.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) {
mmValidate.t.Errorf("AuthServiceMock.Validate got unexpected parameter accessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmValidate.ValidateMock.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) {
mmValidate.t.Errorf("AuthServiceMock.Validate got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmValidate.ValidateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmValidate.ValidateMock.defaultExpectation.results
if mm_results == nil {
mmValidate.t.Fatal("No results are set for the AuthServiceMock.Validate")
}
return (*mm_results).i1, (*mm_results).err
}
if mmValidate.funcValidate != nil {
return mmValidate.funcValidate(ctx, accessToken)
}
mmValidate.t.Fatalf("Unexpected call to AuthServiceMock.Validate. %v %v", ctx, accessToken)
return
}
// ValidateAfterCounter returns a count of finished AuthServiceMock.Validate invocations
func (mmValidate *AuthServiceMock) ValidateAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmValidate.afterValidateCounter)
}
// ValidateBeforeCounter returns a count of AuthServiceMock.Validate invocations
func (mmValidate *AuthServiceMock) ValidateBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmValidate.beforeValidateCounter)
}
// Calls returns a list of arguments used in each call to AuthServiceMock.Validate.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmValidate *mAuthServiceMockValidate) Calls() []*AuthServiceMockValidateParams {
mmValidate.mutex.RLock()
argCopy := make([]*AuthServiceMockValidateParams, len(mmValidate.callArgs))
copy(argCopy, mmValidate.callArgs)
mmValidate.mutex.RUnlock()
return argCopy
}
// MinimockValidateDone returns true if the count of the Validate invocations corresponds
// the number of defined expectations
func (m *AuthServiceMock) MinimockValidateDone() bool {
if m.ValidateMock.optional {
// Optional methods provide '0 or more' call count restriction.
return true
}
for _, e := range m.ValidateMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
return m.ValidateMock.invocationsDone()
}
// MinimockValidateInspect logs each unmet expectation
func (m *AuthServiceMock) MinimockValidateInspect() {
for _, e := range m.ValidateMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
}
}
afterValidateCounter := mm_atomic.LoadUint64(&m.afterValidateCounter)
// if default expectation was set then invocations count should be greater than zero
if m.ValidateMock.defaultExpectation != nil && afterValidateCounter < 1 {
if m.ValidateMock.defaultExpectation.params == nil {
m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s", m.ValidateMock.defaultExpectation.returnOrigin)
} else {
m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s with params: %#v", m.ValidateMock.defaultExpectation.expectationOrigins.origin, *m.ValidateMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcValidate != nil && afterValidateCounter < 1 {
m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s", m.funcValidateOrigin)
}
if !m.ValidateMock.invocationsDone() && afterValidateCounter > 0 {
m.t.Errorf("Expected %d calls to AuthServiceMock.Validate at\n%s but found %d calls",
mm_atomic.LoadUint64(&m.ValidateMock.expectedInvocations), m.ValidateMock.expectedInvocationsOrigin, afterValidateCounter)
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *AuthServiceMock) MinimockFinish() {
m.finishOnce.Do(func() {
if !m.minimockDone() {
m.MinimockLoginInspect()
m.MinimockLogoutInspect()
m.MinimockRefreshInspect()
m.MinimockValidateInspect()
}
})
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *AuthServiceMock) MinimockWait(timeout mm_time.Duration) {
timeoutCh := mm_time.After(timeout)
for {
if m.minimockDone() {
return
}
select {
case <-timeoutCh:
m.MinimockFinish()
return
case <-mm_time.After(10 * mm_time.Millisecond):
}
}
}
func (m *AuthServiceMock) minimockDone() bool {
done := true
return done &&
m.MinimockLoginDone() &&
m.MinimockLogoutDone() &&
m.MinimockRefreshDone() &&
m.MinimockValidateDone()
}