All checks were successful
Deploy Smart Search Backend Test / deploy (push) Successful in 1m24s
2122 lines
84 KiB
Go
2122 lines
84 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/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, accessToken string) (err error)
|
|
funcLogoutOrigin string
|
|
inspectFuncLogout func(ctx context.Context, accessToken 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
|
|
|
|
funcRegister func(ctx context.Context, email string, password string, name string, phone string, inviteCode int64, ip string, userAgent string) (accessToken string, refreshToken string, err error)
|
|
funcRegisterOrigin string
|
|
inspectFuncRegister func(ctx context.Context, email string, password string, name string, phone string, inviteCode int64, ip string, userAgent string)
|
|
afterRegisterCounter uint64
|
|
beforeRegisterCounter uint64
|
|
RegisterMock mAuthServiceMockRegister
|
|
|
|
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.RegisterMock = mAuthServiceMockRegister{mock: m}
|
|
m.RegisterMock.callArgs = []*AuthServiceMockRegisterParams{}
|
|
|
|
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
|
|
accessToken string
|
|
}
|
|
|
|
// AuthServiceMockLogoutParamPtrs contains pointers to parameters of the AuthService.Logout
|
|
type AuthServiceMockLogoutParamPtrs struct {
|
|
ctx *context.Context
|
|
accessToken *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
|
|
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 (mmLogout *mAuthServiceMockLogout) Optional() *mAuthServiceMockLogout {
|
|
mmLogout.optional = true
|
|
return mmLogout
|
|
}
|
|
|
|
// Expect sets up expected params for AuthService.Logout
|
|
func (mmLogout *mAuthServiceMockLogout) Expect(ctx context.Context, accessToken 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, accessToken}
|
|
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
|
|
}
|
|
|
|
// ExpectAccessTokenParam2 sets up expected param accessToken for AuthService.Logout
|
|
func (mmLogout *mAuthServiceMockLogout) ExpectAccessTokenParam2(accessToken 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.accessToken = &accessToken
|
|
mmLogout.defaultExpectation.expectationOrigins.originAccessToken = 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, accessToken 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, accessToken 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, accessToken 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, accessToken},
|
|
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, accessToken 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, accessToken)
|
|
}
|
|
|
|
mm_params := AuthServiceMockLogoutParams{ctx, accessToken}
|
|
|
|
// 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, accessToken}
|
|
|
|
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.accessToken != nil && !minimock.Equal(*mm_want_ptrs.accessToken, mm_got.accessToken) {
|
|
mmLogout.t.Errorf("AuthServiceMock.Logout got unexpected parameter accessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmLogout.LogoutMock.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) {
|
|
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, accessToken)
|
|
}
|
|
mmLogout.t.Fatalf("Unexpected call to AuthServiceMock.Logout. %v %v", ctx, accessToken)
|
|
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 mAuthServiceMockRegister struct {
|
|
optional bool
|
|
mock *AuthServiceMock
|
|
defaultExpectation *AuthServiceMockRegisterExpectation
|
|
expectations []*AuthServiceMockRegisterExpectation
|
|
|
|
callArgs []*AuthServiceMockRegisterParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// AuthServiceMockRegisterExpectation specifies expectation struct of the AuthService.Register
|
|
type AuthServiceMockRegisterExpectation struct {
|
|
mock *AuthServiceMock
|
|
params *AuthServiceMockRegisterParams
|
|
paramPtrs *AuthServiceMockRegisterParamPtrs
|
|
expectationOrigins AuthServiceMockRegisterExpectationOrigins
|
|
results *AuthServiceMockRegisterResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// AuthServiceMockRegisterParams contains parameters of the AuthService.Register
|
|
type AuthServiceMockRegisterParams struct {
|
|
ctx context.Context
|
|
email string
|
|
password string
|
|
name string
|
|
phone string
|
|
inviteCode int64
|
|
ip string
|
|
userAgent string
|
|
}
|
|
|
|
// AuthServiceMockRegisterParamPtrs contains pointers to parameters of the AuthService.Register
|
|
type AuthServiceMockRegisterParamPtrs struct {
|
|
ctx *context.Context
|
|
email *string
|
|
password *string
|
|
name *string
|
|
phone *string
|
|
inviteCode *int64
|
|
ip *string
|
|
userAgent *string
|
|
}
|
|
|
|
// AuthServiceMockRegisterResults contains results of the AuthService.Register
|
|
type AuthServiceMockRegisterResults struct {
|
|
accessToken string
|
|
refreshToken string
|
|
err error
|
|
}
|
|
|
|
// AuthServiceMockRegisterOrigins contains origins of expectations of the AuthService.Register
|
|
type AuthServiceMockRegisterExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originEmail string
|
|
originPassword string
|
|
originName string
|
|
originPhone string
|
|
originInviteCode 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 (mmRegister *mAuthServiceMockRegister) Optional() *mAuthServiceMockRegister {
|
|
mmRegister.optional = true
|
|
return mmRegister
|
|
}
|
|
|
|
// Expect sets up expected params for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) Expect(ctx context.Context, email string, password string, name string, phone string, inviteCode int64, ip string, userAgent string) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmRegister.defaultExpectation.params = &AuthServiceMockRegisterParams{ctx, email, password, name, phone, inviteCode, ip, userAgent}
|
|
mmRegister.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmRegister.expectations {
|
|
if minimock.Equal(e.params, mmRegister.defaultExpectation.params) {
|
|
mmRegister.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRegister.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmRegister.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectEmailParam2 sets up expected param email for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectEmailParam2(email string) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.email = &email
|
|
mmRegister.defaultExpectation.expectationOrigins.originEmail = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectPasswordParam3 sets up expected param password for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectPasswordParam3(password string) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.password = &password
|
|
mmRegister.defaultExpectation.expectationOrigins.originPassword = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectNameParam4 sets up expected param name for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectNameParam4(name string) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.name = &name
|
|
mmRegister.defaultExpectation.expectationOrigins.originName = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectPhoneParam5 sets up expected param phone for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectPhoneParam5(phone string) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.phone = &phone
|
|
mmRegister.defaultExpectation.expectationOrigins.originPhone = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectInviteCodeParam6 sets up expected param inviteCode for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectInviteCodeParam6(inviteCode int64) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.inviteCode = &inviteCode
|
|
mmRegister.defaultExpectation.expectationOrigins.originInviteCode = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectIpParam7 sets up expected param ip for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectIpParam7(ip string) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.ip = &ip
|
|
mmRegister.defaultExpectation.expectationOrigins.originIp = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// ExpectUserAgentParam8 sets up expected param userAgent for AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) ExpectUserAgentParam8(userAgent string) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{}
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.params != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Expect")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation.paramPtrs == nil {
|
|
mmRegister.defaultExpectation.paramPtrs = &AuthServiceMockRegisterParamPtrs{}
|
|
}
|
|
mmRegister.defaultExpectation.paramPtrs.userAgent = &userAgent
|
|
mmRegister.defaultExpectation.expectationOrigins.originUserAgent = minimock.CallerInfo(1)
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) Inspect(f func(ctx context.Context, email string, password string, name string, phone string, inviteCode int64, ip string, userAgent string)) *mAuthServiceMockRegister {
|
|
if mmRegister.mock.inspectFuncRegister != nil {
|
|
mmRegister.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Register")
|
|
}
|
|
|
|
mmRegister.mock.inspectFuncRegister = f
|
|
|
|
return mmRegister
|
|
}
|
|
|
|
// Return sets up results that will be returned by AuthService.Register
|
|
func (mmRegister *mAuthServiceMockRegister) Return(accessToken string, refreshToken string, err error) *AuthServiceMock {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
if mmRegister.defaultExpectation == nil {
|
|
mmRegister.defaultExpectation = &AuthServiceMockRegisterExpectation{mock: mmRegister.mock}
|
|
}
|
|
mmRegister.defaultExpectation.results = &AuthServiceMockRegisterResults{accessToken, refreshToken, err}
|
|
mmRegister.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmRegister.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the AuthService.Register method
|
|
func (mmRegister *mAuthServiceMockRegister) Set(f func(ctx context.Context, email string, password string, name string, phone string, inviteCode int64, ip string, userAgent string) (accessToken string, refreshToken string, err error)) *AuthServiceMock {
|
|
if mmRegister.defaultExpectation != nil {
|
|
mmRegister.mock.t.Fatalf("Default expectation is already set for the AuthService.Register method")
|
|
}
|
|
|
|
if len(mmRegister.expectations) > 0 {
|
|
mmRegister.mock.t.Fatalf("Some expectations are already set for the AuthService.Register method")
|
|
}
|
|
|
|
mmRegister.mock.funcRegister = f
|
|
mmRegister.mock.funcRegisterOrigin = minimock.CallerInfo(1)
|
|
return mmRegister.mock
|
|
}
|
|
|
|
// When sets expectation for the AuthService.Register which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmRegister *mAuthServiceMockRegister) When(ctx context.Context, email string, password string, name string, phone string, inviteCode int64, ip string, userAgent string) *AuthServiceMockRegisterExpectation {
|
|
if mmRegister.mock.funcRegister != nil {
|
|
mmRegister.mock.t.Fatalf("AuthServiceMock.Register mock is already set by Set")
|
|
}
|
|
|
|
expectation := &AuthServiceMockRegisterExpectation{
|
|
mock: mmRegister.mock,
|
|
params: &AuthServiceMockRegisterParams{ctx, email, password, name, phone, inviteCode, ip, userAgent},
|
|
expectationOrigins: AuthServiceMockRegisterExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmRegister.expectations = append(mmRegister.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up AuthService.Register return parameters for the expectation previously defined by the When method
|
|
func (e *AuthServiceMockRegisterExpectation) Then(accessToken string, refreshToken string, err error) *AuthServiceMock {
|
|
e.results = &AuthServiceMockRegisterResults{accessToken, refreshToken, err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times AuthService.Register should be invoked
|
|
func (mmRegister *mAuthServiceMockRegister) Times(n uint64) *mAuthServiceMockRegister {
|
|
if n == 0 {
|
|
mmRegister.mock.t.Fatalf("Times of AuthServiceMock.Register mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmRegister.expectedInvocations, n)
|
|
mmRegister.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmRegister
|
|
}
|
|
|
|
func (mmRegister *mAuthServiceMockRegister) invocationsDone() bool {
|
|
if len(mmRegister.expectations) == 0 && mmRegister.defaultExpectation == nil && mmRegister.mock.funcRegister == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmRegister.mock.afterRegisterCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmRegister.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// Register implements mm_service.AuthService
|
|
func (mmRegister *AuthServiceMock) Register(ctx context.Context, email string, password string, name string, phone string, inviteCode int64, ip string, userAgent string) (accessToken string, refreshToken string, err error) {
|
|
mm_atomic.AddUint64(&mmRegister.beforeRegisterCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmRegister.afterRegisterCounter, 1)
|
|
|
|
mmRegister.t.Helper()
|
|
|
|
if mmRegister.inspectFuncRegister != nil {
|
|
mmRegister.inspectFuncRegister(ctx, email, password, name, phone, inviteCode, ip, userAgent)
|
|
}
|
|
|
|
mm_params := AuthServiceMockRegisterParams{ctx, email, password, name, phone, inviteCode, ip, userAgent}
|
|
|
|
// Record call args
|
|
mmRegister.RegisterMock.mutex.Lock()
|
|
mmRegister.RegisterMock.callArgs = append(mmRegister.RegisterMock.callArgs, &mm_params)
|
|
mmRegister.RegisterMock.mutex.Unlock()
|
|
|
|
for _, e := range mmRegister.RegisterMock.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 mmRegister.RegisterMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmRegister.RegisterMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmRegister.RegisterMock.defaultExpectation.params
|
|
mm_want_ptrs := mmRegister.RegisterMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := AuthServiceMockRegisterParams{ctx, email, password, name, phone, inviteCode, ip, userAgent}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.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) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter email, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.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) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter password, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.defaultExpectation.expectationOrigins.originPassword, *mm_want_ptrs.password, mm_got.password, minimock.Diff(*mm_want_ptrs.password, mm_got.password))
|
|
}
|
|
|
|
if mm_want_ptrs.name != nil && !minimock.Equal(*mm_want_ptrs.name, mm_got.name) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter name, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.defaultExpectation.expectationOrigins.originName, *mm_want_ptrs.name, mm_got.name, minimock.Diff(*mm_want_ptrs.name, mm_got.name))
|
|
}
|
|
|
|
if mm_want_ptrs.phone != nil && !minimock.Equal(*mm_want_ptrs.phone, mm_got.phone) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter phone, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.defaultExpectation.expectationOrigins.originPhone, *mm_want_ptrs.phone, mm_got.phone, minimock.Diff(*mm_want_ptrs.phone, mm_got.phone))
|
|
}
|
|
|
|
if mm_want_ptrs.inviteCode != nil && !minimock.Equal(*mm_want_ptrs.inviteCode, mm_got.inviteCode) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter inviteCode, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.defaultExpectation.expectationOrigins.originInviteCode, *mm_want_ptrs.inviteCode, mm_got.inviteCode, minimock.Diff(*mm_want_ptrs.inviteCode, mm_got.inviteCode))
|
|
}
|
|
|
|
if mm_want_ptrs.ip != nil && !minimock.Equal(*mm_want_ptrs.ip, mm_got.ip) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter ip, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.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) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameter userAgent, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.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) {
|
|
mmRegister.t.Errorf("AuthServiceMock.Register got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmRegister.RegisterMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmRegister.RegisterMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmRegister.t.Fatal("No results are set for the AuthServiceMock.Register")
|
|
}
|
|
return (*mm_results).accessToken, (*mm_results).refreshToken, (*mm_results).err
|
|
}
|
|
if mmRegister.funcRegister != nil {
|
|
return mmRegister.funcRegister(ctx, email, password, name, phone, inviteCode, ip, userAgent)
|
|
}
|
|
mmRegister.t.Fatalf("Unexpected call to AuthServiceMock.Register. %v %v %v %v %v %v %v %v", ctx, email, password, name, phone, inviteCode, ip, userAgent)
|
|
return
|
|
}
|
|
|
|
// RegisterAfterCounter returns a count of finished AuthServiceMock.Register invocations
|
|
func (mmRegister *AuthServiceMock) RegisterAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmRegister.afterRegisterCounter)
|
|
}
|
|
|
|
// RegisterBeforeCounter returns a count of AuthServiceMock.Register invocations
|
|
func (mmRegister *AuthServiceMock) RegisterBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmRegister.beforeRegisterCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to AuthServiceMock.Register.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmRegister *mAuthServiceMockRegister) Calls() []*AuthServiceMockRegisterParams {
|
|
mmRegister.mutex.RLock()
|
|
|
|
argCopy := make([]*AuthServiceMockRegisterParams, len(mmRegister.callArgs))
|
|
copy(argCopy, mmRegister.callArgs)
|
|
|
|
mmRegister.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockRegisterDone returns true if the count of the Register invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *AuthServiceMock) MinimockRegisterDone() bool {
|
|
if m.RegisterMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.RegisterMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.RegisterMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockRegisterInspect logs each unmet expectation
|
|
func (m *AuthServiceMock) MinimockRegisterInspect() {
|
|
for _, e := range m.RegisterMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to AuthServiceMock.Register at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterRegisterCounter := mm_atomic.LoadUint64(&m.afterRegisterCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.RegisterMock.defaultExpectation != nil && afterRegisterCounter < 1 {
|
|
if m.RegisterMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to AuthServiceMock.Register at\n%s", m.RegisterMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to AuthServiceMock.Register at\n%s with params: %#v", m.RegisterMock.defaultExpectation.expectationOrigins.origin, *m.RegisterMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcRegister != nil && afterRegisterCounter < 1 {
|
|
m.t.Errorf("Expected call to AuthServiceMock.Register at\n%s", m.funcRegisterOrigin)
|
|
}
|
|
|
|
if !m.RegisterMock.invocationsDone() && afterRegisterCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to AuthServiceMock.Register at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.RegisterMock.expectedInvocations), m.RegisterMock.expectedInvocationsOrigin, afterRegisterCounter)
|
|
}
|
|
}
|
|
|
|
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.MinimockRegisterInspect()
|
|
|
|
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.MinimockRegisterDone() &&
|
|
m.MinimockValidateDone()
|
|
}
|