This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/service.AuthService -o auth_service_mock.go -n AuthServiceMock -p 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"
|
||||
@@ -25,9 +25,9 @@ type AuthServiceMock struct {
|
||||
beforeLoginCounter uint64
|
||||
LoginMock mAuthServiceMockLogin
|
||||
|
||||
funcLogout func(ctx context.Context, refreshToken string) (err error)
|
||||
funcLogout func(ctx context.Context, accessToken string) (err error)
|
||||
funcLogoutOrigin string
|
||||
inspectFuncLogout func(ctx context.Context, refreshToken string)
|
||||
inspectFuncLogout func(ctx context.Context, accessToken string)
|
||||
afterLogoutCounter uint64
|
||||
beforeLogoutCounter uint64
|
||||
LogoutMock mAuthServiceMockLogout
|
||||
@@ -535,14 +535,14 @@ type AuthServiceMockLogoutExpectation struct {
|
||||
|
||||
// AuthServiceMockLogoutParams contains parameters of the AuthService.Logout
|
||||
type AuthServiceMockLogoutParams struct {
|
||||
ctx context.Context
|
||||
refreshToken string
|
||||
ctx context.Context
|
||||
accessToken string
|
||||
}
|
||||
|
||||
// AuthServiceMockLogoutParamPtrs contains pointers to parameters of the AuthService.Logout
|
||||
type AuthServiceMockLogoutParamPtrs struct {
|
||||
ctx *context.Context
|
||||
refreshToken *string
|
||||
ctx *context.Context
|
||||
accessToken *string
|
||||
}
|
||||
|
||||
// AuthServiceMockLogoutResults contains results of the AuthService.Logout
|
||||
@@ -552,9 +552,9 @@ type AuthServiceMockLogoutResults struct {
|
||||
|
||||
// AuthServiceMockLogoutOrigins contains origins of expectations of the AuthService.Logout
|
||||
type AuthServiceMockLogoutExpectationOrigins struct {
|
||||
origin string
|
||||
originCtx string
|
||||
originRefreshToken string
|
||||
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
|
||||
@@ -568,7 +568,7 @@ func (mmLogout *mAuthServiceMockLogout) Optional() *mAuthServiceMockLogout {
|
||||
}
|
||||
|
||||
// Expect sets up expected params for AuthService.Logout
|
||||
func (mmLogout *mAuthServiceMockLogout) Expect(ctx context.Context, refreshToken string) *mAuthServiceMockLogout {
|
||||
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")
|
||||
}
|
||||
@@ -581,7 +581,7 @@ func (mmLogout *mAuthServiceMockLogout) Expect(ctx context.Context, refreshToken
|
||||
mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by ExpectParams functions")
|
||||
}
|
||||
|
||||
mmLogout.defaultExpectation.params = &AuthServiceMockLogoutParams{ctx, refreshToken}
|
||||
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) {
|
||||
@@ -615,8 +615,8 @@ func (mmLogout *mAuthServiceMockLogout) ExpectCtxParam1(ctx context.Context) *mA
|
||||
return mmLogout
|
||||
}
|
||||
|
||||
// ExpectRefreshTokenParam2 sets up expected param refreshToken for AuthService.Logout
|
||||
func (mmLogout *mAuthServiceMockLogout) ExpectRefreshTokenParam2(refreshToken string) *mAuthServiceMockLogout {
|
||||
// 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")
|
||||
}
|
||||
@@ -632,14 +632,14 @@ func (mmLogout *mAuthServiceMockLogout) ExpectRefreshTokenParam2(refreshToken st
|
||||
if mmLogout.defaultExpectation.paramPtrs == nil {
|
||||
mmLogout.defaultExpectation.paramPtrs = &AuthServiceMockLogoutParamPtrs{}
|
||||
}
|
||||
mmLogout.defaultExpectation.paramPtrs.refreshToken = &refreshToken
|
||||
mmLogout.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1)
|
||||
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, refreshToken string)) *mAuthServiceMockLogout {
|
||||
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")
|
||||
}
|
||||
@@ -664,7 +664,7 @@ func (mmLogout *mAuthServiceMockLogout) Return(err error) *AuthServiceMock {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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")
|
||||
}
|
||||
@@ -680,14 +680,14 @@ func (mmLogout *mAuthServiceMockLogout) Set(f func(ctx context.Context, refreshT
|
||||
|
||||
// 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 {
|
||||
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, refreshToken},
|
||||
params: &AuthServiceMockLogoutParams{ctx, accessToken},
|
||||
expectationOrigins: AuthServiceMockLogoutExpectationOrigins{origin: minimock.CallerInfo(1)},
|
||||
}
|
||||
mmLogout.expectations = append(mmLogout.expectations, expectation)
|
||||
@@ -722,17 +722,17 @@ func (mmLogout *mAuthServiceMockLogout) invocationsDone() bool {
|
||||
}
|
||||
|
||||
// Logout implements mm_service.AuthService
|
||||
func (mmLogout *AuthServiceMock) Logout(ctx context.Context, refreshToken string) (err error) {
|
||||
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, refreshToken)
|
||||
mmLogout.inspectFuncLogout(ctx, accessToken)
|
||||
}
|
||||
|
||||
mm_params := AuthServiceMockLogoutParams{ctx, refreshToken}
|
||||
mm_params := AuthServiceMockLogoutParams{ctx, accessToken}
|
||||
|
||||
// Record call args
|
||||
mmLogout.LogoutMock.mutex.Lock()
|
||||
@@ -751,7 +751,7 @@ func (mmLogout *AuthServiceMock) Logout(ctx context.Context, refreshToken string
|
||||
mm_want := mmLogout.LogoutMock.defaultExpectation.params
|
||||
mm_want_ptrs := mmLogout.LogoutMock.defaultExpectation.paramPtrs
|
||||
|
||||
mm_got := AuthServiceMockLogoutParams{ctx, refreshToken}
|
||||
mm_got := AuthServiceMockLogoutParams{ctx, accessToken}
|
||||
|
||||
if mm_want_ptrs != nil {
|
||||
|
||||
@@ -760,9 +760,9 @@ func (mmLogout *AuthServiceMock) Logout(ctx context.Context, refreshToken string
|
||||
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))
|
||||
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) {
|
||||
@@ -777,9 +777,9 @@ func (mmLogout *AuthServiceMock) Logout(ctx context.Context, refreshToken string
|
||||
return (*mm_results).err
|
||||
}
|
||||
if mmLogout.funcLogout != nil {
|
||||
return mmLogout.funcLogout(ctx, refreshToken)
|
||||
return mmLogout.funcLogout(ctx, accessToken)
|
||||
}
|
||||
mmLogout.t.Fatalf("Unexpected call to AuthServiceMock.Logout. %v %v", ctx, refreshToken)
|
||||
mmLogout.t.Fatalf("Unexpected call to AuthServiceMock.Logout. %v %v", ctx, accessToken)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/repository.InviteRepository -o invite_repository_mock.go -n InviteRepositoryMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/repository.InviteRepository -o invite_repository_mock.go -n InviteRepositoryMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"smart-search-back/internal/model"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
// InviteRepositoryMock implements mm_repository.InviteRepository
|
||||
@@ -26,6 +27,13 @@ type InviteRepositoryMock struct {
|
||||
beforeCreateCounter uint64
|
||||
CreateMock mInviteRepositoryMockCreate
|
||||
|
||||
funcCreateTx func(ctx context.Context, tx pgx.Tx, invite *model.InviteCode) (err error)
|
||||
funcCreateTxOrigin string
|
||||
inspectFuncCreateTx func(ctx context.Context, tx pgx.Tx, invite *model.InviteCode)
|
||||
afterCreateTxCounter uint64
|
||||
beforeCreateTxCounter uint64
|
||||
CreateTxMock mInviteRepositoryMockCreateTx
|
||||
|
||||
funcDeactivateExpired func(ctx context.Context) (i1 int, err error)
|
||||
funcDeactivateExpiredOrigin string
|
||||
inspectFuncDeactivateExpired func(ctx context.Context)
|
||||
@@ -66,6 +74,9 @@ func NewInviteRepositoryMock(t minimock.Tester) *InviteRepositoryMock {
|
||||
m.CreateMock = mInviteRepositoryMockCreate{mock: m}
|
||||
m.CreateMock.callArgs = []*InviteRepositoryMockCreateParams{}
|
||||
|
||||
m.CreateTxMock = mInviteRepositoryMockCreateTx{mock: m}
|
||||
m.CreateTxMock.callArgs = []*InviteRepositoryMockCreateTxParams{}
|
||||
|
||||
m.DeactivateExpiredMock = mInviteRepositoryMockDeactivateExpired{mock: m}
|
||||
m.DeactivateExpiredMock.callArgs = []*InviteRepositoryMockDeactivateExpiredParams{}
|
||||
|
||||
@@ -425,6 +436,379 @@ func (m *InviteRepositoryMock) MinimockCreateInspect() {
|
||||
}
|
||||
}
|
||||
|
||||
type mInviteRepositoryMockCreateTx struct {
|
||||
optional bool
|
||||
mock *InviteRepositoryMock
|
||||
defaultExpectation *InviteRepositoryMockCreateTxExpectation
|
||||
expectations []*InviteRepositoryMockCreateTxExpectation
|
||||
|
||||
callArgs []*InviteRepositoryMockCreateTxParams
|
||||
mutex sync.RWMutex
|
||||
|
||||
expectedInvocations uint64
|
||||
expectedInvocationsOrigin string
|
||||
}
|
||||
|
||||
// InviteRepositoryMockCreateTxExpectation specifies expectation struct of the InviteRepository.CreateTx
|
||||
type InviteRepositoryMockCreateTxExpectation struct {
|
||||
mock *InviteRepositoryMock
|
||||
params *InviteRepositoryMockCreateTxParams
|
||||
paramPtrs *InviteRepositoryMockCreateTxParamPtrs
|
||||
expectationOrigins InviteRepositoryMockCreateTxExpectationOrigins
|
||||
results *InviteRepositoryMockCreateTxResults
|
||||
returnOrigin string
|
||||
Counter uint64
|
||||
}
|
||||
|
||||
// InviteRepositoryMockCreateTxParams contains parameters of the InviteRepository.CreateTx
|
||||
type InviteRepositoryMockCreateTxParams struct {
|
||||
ctx context.Context
|
||||
tx pgx.Tx
|
||||
invite *model.InviteCode
|
||||
}
|
||||
|
||||
// InviteRepositoryMockCreateTxParamPtrs contains pointers to parameters of the InviteRepository.CreateTx
|
||||
type InviteRepositoryMockCreateTxParamPtrs struct {
|
||||
ctx *context.Context
|
||||
tx *pgx.Tx
|
||||
invite **model.InviteCode
|
||||
}
|
||||
|
||||
// InviteRepositoryMockCreateTxResults contains results of the InviteRepository.CreateTx
|
||||
type InviteRepositoryMockCreateTxResults struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// InviteRepositoryMockCreateTxOrigins contains origins of expectations of the InviteRepository.CreateTx
|
||||
type InviteRepositoryMockCreateTxExpectationOrigins struct {
|
||||
origin string
|
||||
originCtx string
|
||||
originTx string
|
||||
originInvite 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 (mmCreateTx *mInviteRepositoryMockCreateTx) Optional() *mInviteRepositoryMockCreateTx {
|
||||
mmCreateTx.optional = true
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// Expect sets up expected params for InviteRepository.CreateTx
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) Expect(ctx context.Context, tx pgx.Tx, invite *model.InviteCode) *mInviteRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &InviteRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by ExpectParams functions")
|
||||
}
|
||||
|
||||
mmCreateTx.defaultExpectation.params = &InviteRepositoryMockCreateTxParams{ctx, tx, invite}
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
||||
for _, e := range mmCreateTx.expectations {
|
||||
if minimock.Equal(e.params, mmCreateTx.defaultExpectation.params) {
|
||||
mmCreateTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateTx.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// ExpectCtxParam1 sets up expected param ctx for InviteRepository.CreateTx
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) ExpectCtxParam1(ctx context.Context) *mInviteRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &InviteRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.params != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs == nil {
|
||||
mmCreateTx.defaultExpectation.paramPtrs = &InviteRepositoryMockCreateTxParamPtrs{}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.paramPtrs.ctx = &ctx
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// ExpectTxParam2 sets up expected param tx for InviteRepository.CreateTx
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) ExpectTxParam2(tx pgx.Tx) *mInviteRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &InviteRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.params != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs == nil {
|
||||
mmCreateTx.defaultExpectation.paramPtrs = &InviteRepositoryMockCreateTxParamPtrs{}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.paramPtrs.tx = &tx
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.originTx = minimock.CallerInfo(1)
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// ExpectInviteParam3 sets up expected param invite for InviteRepository.CreateTx
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) ExpectInviteParam3(invite *model.InviteCode) *mInviteRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &InviteRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.params != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs == nil {
|
||||
mmCreateTx.defaultExpectation.paramPtrs = &InviteRepositoryMockCreateTxParamPtrs{}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.paramPtrs.invite = &invite
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.originInvite = minimock.CallerInfo(1)
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// Inspect accepts an inspector function that has same arguments as the InviteRepository.CreateTx
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) Inspect(f func(ctx context.Context, tx pgx.Tx, invite *model.InviteCode)) *mInviteRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.inspectFuncCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("Inspect function is already set for InviteRepositoryMock.CreateTx")
|
||||
}
|
||||
|
||||
mmCreateTx.mock.inspectFuncCreateTx = f
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// Return sets up results that will be returned by InviteRepository.CreateTx
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) Return(err error) *InviteRepositoryMock {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &InviteRepositoryMockCreateTxExpectation{mock: mmCreateTx.mock}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.results = &InviteRepositoryMockCreateTxResults{err}
|
||||
mmCreateTx.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
||||
return mmCreateTx.mock
|
||||
}
|
||||
|
||||
// Set uses given function f to mock the InviteRepository.CreateTx method
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) Set(f func(ctx context.Context, tx pgx.Tx, invite *model.InviteCode) (err error)) *InviteRepositoryMock {
|
||||
if mmCreateTx.defaultExpectation != nil {
|
||||
mmCreateTx.mock.t.Fatalf("Default expectation is already set for the InviteRepository.CreateTx method")
|
||||
}
|
||||
|
||||
if len(mmCreateTx.expectations) > 0 {
|
||||
mmCreateTx.mock.t.Fatalf("Some expectations are already set for the InviteRepository.CreateTx method")
|
||||
}
|
||||
|
||||
mmCreateTx.mock.funcCreateTx = f
|
||||
mmCreateTx.mock.funcCreateTxOrigin = minimock.CallerInfo(1)
|
||||
return mmCreateTx.mock
|
||||
}
|
||||
|
||||
// When sets expectation for the InviteRepository.CreateTx which will trigger the result defined by the following
|
||||
// Then helper
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) When(ctx context.Context, tx pgx.Tx, invite *model.InviteCode) *InviteRepositoryMockCreateTxExpectation {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("InviteRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
expectation := &InviteRepositoryMockCreateTxExpectation{
|
||||
mock: mmCreateTx.mock,
|
||||
params: &InviteRepositoryMockCreateTxParams{ctx, tx, invite},
|
||||
expectationOrigins: InviteRepositoryMockCreateTxExpectationOrigins{origin: minimock.CallerInfo(1)},
|
||||
}
|
||||
mmCreateTx.expectations = append(mmCreateTx.expectations, expectation)
|
||||
return expectation
|
||||
}
|
||||
|
||||
// Then sets up InviteRepository.CreateTx return parameters for the expectation previously defined by the When method
|
||||
func (e *InviteRepositoryMockCreateTxExpectation) Then(err error) *InviteRepositoryMock {
|
||||
e.results = &InviteRepositoryMockCreateTxResults{err}
|
||||
return e.mock
|
||||
}
|
||||
|
||||
// Times sets number of times InviteRepository.CreateTx should be invoked
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) Times(n uint64) *mInviteRepositoryMockCreateTx {
|
||||
if n == 0 {
|
||||
mmCreateTx.mock.t.Fatalf("Times of InviteRepositoryMock.CreateTx mock can not be zero")
|
||||
}
|
||||
mm_atomic.StoreUint64(&mmCreateTx.expectedInvocations, n)
|
||||
mmCreateTx.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) invocationsDone() bool {
|
||||
if len(mmCreateTx.expectations) == 0 && mmCreateTx.defaultExpectation == nil && mmCreateTx.mock.funcCreateTx == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
totalInvocations := mm_atomic.LoadUint64(&mmCreateTx.mock.afterCreateTxCounter)
|
||||
expectedInvocations := mm_atomic.LoadUint64(&mmCreateTx.expectedInvocations)
|
||||
|
||||
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
||||
}
|
||||
|
||||
// CreateTx implements mm_repository.InviteRepository
|
||||
func (mmCreateTx *InviteRepositoryMock) CreateTx(ctx context.Context, tx pgx.Tx, invite *model.InviteCode) (err error) {
|
||||
mm_atomic.AddUint64(&mmCreateTx.beforeCreateTxCounter, 1)
|
||||
defer mm_atomic.AddUint64(&mmCreateTx.afterCreateTxCounter, 1)
|
||||
|
||||
mmCreateTx.t.Helper()
|
||||
|
||||
if mmCreateTx.inspectFuncCreateTx != nil {
|
||||
mmCreateTx.inspectFuncCreateTx(ctx, tx, invite)
|
||||
}
|
||||
|
||||
mm_params := InviteRepositoryMockCreateTxParams{ctx, tx, invite}
|
||||
|
||||
// Record call args
|
||||
mmCreateTx.CreateTxMock.mutex.Lock()
|
||||
mmCreateTx.CreateTxMock.callArgs = append(mmCreateTx.CreateTxMock.callArgs, &mm_params)
|
||||
mmCreateTx.CreateTxMock.mutex.Unlock()
|
||||
|
||||
for _, e := range mmCreateTx.CreateTxMock.expectations {
|
||||
if minimock.Equal(*e.params, mm_params) {
|
||||
mm_atomic.AddUint64(&e.Counter, 1)
|
||||
return e.results.err
|
||||
}
|
||||
}
|
||||
|
||||
if mmCreateTx.CreateTxMock.defaultExpectation != nil {
|
||||
mm_atomic.AddUint64(&mmCreateTx.CreateTxMock.defaultExpectation.Counter, 1)
|
||||
mm_want := mmCreateTx.CreateTxMock.defaultExpectation.params
|
||||
mm_want_ptrs := mmCreateTx.CreateTxMock.defaultExpectation.paramPtrs
|
||||
|
||||
mm_got := InviteRepositoryMockCreateTxParams{ctx, tx, invite}
|
||||
|
||||
if mm_want_ptrs != nil {
|
||||
|
||||
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
||||
mmCreateTx.t.Errorf("InviteRepositoryMock.CreateTx got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
|
||||
mmCreateTx.t.Errorf("InviteRepositoryMock.CreateTx got unexpected parameter tx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.originTx, *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.invite != nil && !minimock.Equal(*mm_want_ptrs.invite, mm_got.invite) {
|
||||
mmCreateTx.t.Errorf("InviteRepositoryMock.CreateTx got unexpected parameter invite, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.originInvite, *mm_want_ptrs.invite, mm_got.invite, minimock.Diff(*mm_want_ptrs.invite, mm_got.invite))
|
||||
}
|
||||
|
||||
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
||||
mmCreateTx.t.Errorf("InviteRepositoryMock.CreateTx got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
||||
}
|
||||
|
||||
mm_results := mmCreateTx.CreateTxMock.defaultExpectation.results
|
||||
if mm_results == nil {
|
||||
mmCreateTx.t.Fatal("No results are set for the InviteRepositoryMock.CreateTx")
|
||||
}
|
||||
return (*mm_results).err
|
||||
}
|
||||
if mmCreateTx.funcCreateTx != nil {
|
||||
return mmCreateTx.funcCreateTx(ctx, tx, invite)
|
||||
}
|
||||
mmCreateTx.t.Fatalf("Unexpected call to InviteRepositoryMock.CreateTx. %v %v %v", ctx, tx, invite)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateTxAfterCounter returns a count of finished InviteRepositoryMock.CreateTx invocations
|
||||
func (mmCreateTx *InviteRepositoryMock) CreateTxAfterCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmCreateTx.afterCreateTxCounter)
|
||||
}
|
||||
|
||||
// CreateTxBeforeCounter returns a count of InviteRepositoryMock.CreateTx invocations
|
||||
func (mmCreateTx *InviteRepositoryMock) CreateTxBeforeCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmCreateTx.beforeCreateTxCounter)
|
||||
}
|
||||
|
||||
// Calls returns a list of arguments used in each call to InviteRepositoryMock.CreateTx.
|
||||
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
||||
func (mmCreateTx *mInviteRepositoryMockCreateTx) Calls() []*InviteRepositoryMockCreateTxParams {
|
||||
mmCreateTx.mutex.RLock()
|
||||
|
||||
argCopy := make([]*InviteRepositoryMockCreateTxParams, len(mmCreateTx.callArgs))
|
||||
copy(argCopy, mmCreateTx.callArgs)
|
||||
|
||||
mmCreateTx.mutex.RUnlock()
|
||||
|
||||
return argCopy
|
||||
}
|
||||
|
||||
// MinimockCreateTxDone returns true if the count of the CreateTx invocations corresponds
|
||||
// the number of defined expectations
|
||||
func (m *InviteRepositoryMock) MinimockCreateTxDone() bool {
|
||||
if m.CreateTxMock.optional {
|
||||
// Optional methods provide '0 or more' call count restriction.
|
||||
return true
|
||||
}
|
||||
|
||||
for _, e := range m.CreateTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return m.CreateTxMock.invocationsDone()
|
||||
}
|
||||
|
||||
// MinimockCreateTxInspect logs each unmet expectation
|
||||
func (m *InviteRepositoryMock) MinimockCreateTxInspect() {
|
||||
for _, e := range m.CreateTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
m.t.Errorf("Expected call to InviteRepositoryMock.CreateTx at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
||||
}
|
||||
}
|
||||
|
||||
afterCreateTxCounter := mm_atomic.LoadUint64(&m.afterCreateTxCounter)
|
||||
// if default expectation was set then invocations count should be greater than zero
|
||||
if m.CreateTxMock.defaultExpectation != nil && afterCreateTxCounter < 1 {
|
||||
if m.CreateTxMock.defaultExpectation.params == nil {
|
||||
m.t.Errorf("Expected call to InviteRepositoryMock.CreateTx at\n%s", m.CreateTxMock.defaultExpectation.returnOrigin)
|
||||
} else {
|
||||
m.t.Errorf("Expected call to InviteRepositoryMock.CreateTx at\n%s with params: %#v", m.CreateTxMock.defaultExpectation.expectationOrigins.origin, *m.CreateTxMock.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
// if func was set then invocations count should be greater than zero
|
||||
if m.funcCreateTx != nil && afterCreateTxCounter < 1 {
|
||||
m.t.Errorf("Expected call to InviteRepositoryMock.CreateTx at\n%s", m.funcCreateTxOrigin)
|
||||
}
|
||||
|
||||
if !m.CreateTxMock.invocationsDone() && afterCreateTxCounter > 0 {
|
||||
m.t.Errorf("Expected %d calls to InviteRepositoryMock.CreateTx at\n%s but found %d calls",
|
||||
mm_atomic.LoadUint64(&m.CreateTxMock.expectedInvocations), m.CreateTxMock.expectedInvocationsOrigin, afterCreateTxCounter)
|
||||
}
|
||||
}
|
||||
|
||||
type mInviteRepositoryMockDeactivateExpired struct {
|
||||
optional bool
|
||||
mock *InviteRepositoryMock
|
||||
@@ -1771,6 +2155,8 @@ func (m *InviteRepositoryMock) MinimockFinish() {
|
||||
if !m.minimockDone() {
|
||||
m.MinimockCreateInspect()
|
||||
|
||||
m.MinimockCreateTxInspect()
|
||||
|
||||
m.MinimockDeactivateExpiredInspect()
|
||||
|
||||
m.MinimockFindByCodeInspect()
|
||||
@@ -1802,6 +2188,7 @@ func (m *InviteRepositoryMock) minimockDone() bool {
|
||||
done := true
|
||||
return done &&
|
||||
m.MinimockCreateDone() &&
|
||||
m.MinimockCreateTxDone() &&
|
||||
m.MinimockDeactivateExpiredDone() &&
|
||||
m.MinimockFindByCodeDone() &&
|
||||
m.MinimockGetUserInvitesDone() &&
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/service.InviteService -o invite_service_mock.go -n InviteServiceMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/service.InviteService -o invite_service_mock.go -n InviteServiceMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"smart-search-back/internal/model"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/repository.RequestRepository -o request_repository_mock.go -n RequestRepositoryMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/repository.RequestRepository -o request_repository_mock.go -n RequestRepositoryMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"smart-search-back/internal/model"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
// RequestRepositoryMock implements mm_repository.RequestRepository
|
||||
@@ -68,6 +69,13 @@ type RequestRepositoryMock struct {
|
||||
afterUpdateWithTZCounter uint64
|
||||
beforeUpdateWithTZCounter uint64
|
||||
UpdateWithTZMock mRequestRepositoryMockUpdateWithTZ
|
||||
|
||||
funcUpdateWithTZTx func(ctx context.Context, tx pgx.Tx, id uuid.UUID, tz string, generated bool) (err error)
|
||||
funcUpdateWithTZTxOrigin string
|
||||
inspectFuncUpdateWithTZTx func(ctx context.Context, tx pgx.Tx, id uuid.UUID, tz string, generated bool)
|
||||
afterUpdateWithTZTxCounter uint64
|
||||
beforeUpdateWithTZTxCounter uint64
|
||||
UpdateWithTZTxMock mRequestRepositoryMockUpdateWithTZTx
|
||||
}
|
||||
|
||||
// NewRequestRepositoryMock returns a mock for mm_repository.RequestRepository
|
||||
@@ -99,6 +107,9 @@ func NewRequestRepositoryMock(t minimock.Tester) *RequestRepositoryMock {
|
||||
m.UpdateWithTZMock = mRequestRepositoryMockUpdateWithTZ{mock: m}
|
||||
m.UpdateWithTZMock.callArgs = []*RequestRepositoryMockUpdateWithTZParams{}
|
||||
|
||||
m.UpdateWithTZTxMock = mRequestRepositoryMockUpdateWithTZTx{mock: m}
|
||||
m.UpdateWithTZTxMock.callArgs = []*RequestRepositoryMockUpdateWithTZTxParams{}
|
||||
|
||||
t.Cleanup(m.MinimockFinish)
|
||||
|
||||
return m
|
||||
@@ -2597,6 +2608,441 @@ func (m *RequestRepositoryMock) MinimockUpdateWithTZInspect() {
|
||||
}
|
||||
}
|
||||
|
||||
type mRequestRepositoryMockUpdateWithTZTx struct {
|
||||
optional bool
|
||||
mock *RequestRepositoryMock
|
||||
defaultExpectation *RequestRepositoryMockUpdateWithTZTxExpectation
|
||||
expectations []*RequestRepositoryMockUpdateWithTZTxExpectation
|
||||
|
||||
callArgs []*RequestRepositoryMockUpdateWithTZTxParams
|
||||
mutex sync.RWMutex
|
||||
|
||||
expectedInvocations uint64
|
||||
expectedInvocationsOrigin string
|
||||
}
|
||||
|
||||
// RequestRepositoryMockUpdateWithTZTxExpectation specifies expectation struct of the RequestRepository.UpdateWithTZTx
|
||||
type RequestRepositoryMockUpdateWithTZTxExpectation struct {
|
||||
mock *RequestRepositoryMock
|
||||
params *RequestRepositoryMockUpdateWithTZTxParams
|
||||
paramPtrs *RequestRepositoryMockUpdateWithTZTxParamPtrs
|
||||
expectationOrigins RequestRepositoryMockUpdateWithTZTxExpectationOrigins
|
||||
results *RequestRepositoryMockUpdateWithTZTxResults
|
||||
returnOrigin string
|
||||
Counter uint64
|
||||
}
|
||||
|
||||
// RequestRepositoryMockUpdateWithTZTxParams contains parameters of the RequestRepository.UpdateWithTZTx
|
||||
type RequestRepositoryMockUpdateWithTZTxParams struct {
|
||||
ctx context.Context
|
||||
tx pgx.Tx
|
||||
id uuid.UUID
|
||||
tz string
|
||||
generated bool
|
||||
}
|
||||
|
||||
// RequestRepositoryMockUpdateWithTZTxParamPtrs contains pointers to parameters of the RequestRepository.UpdateWithTZTx
|
||||
type RequestRepositoryMockUpdateWithTZTxParamPtrs struct {
|
||||
ctx *context.Context
|
||||
tx *pgx.Tx
|
||||
id *uuid.UUID
|
||||
tz *string
|
||||
generated *bool
|
||||
}
|
||||
|
||||
// RequestRepositoryMockUpdateWithTZTxResults contains results of the RequestRepository.UpdateWithTZTx
|
||||
type RequestRepositoryMockUpdateWithTZTxResults struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// RequestRepositoryMockUpdateWithTZTxOrigins contains origins of expectations of the RequestRepository.UpdateWithTZTx
|
||||
type RequestRepositoryMockUpdateWithTZTxExpectationOrigins struct {
|
||||
origin string
|
||||
originCtx string
|
||||
originTx string
|
||||
originId string
|
||||
originTz string
|
||||
originGenerated 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 (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) Optional() *mRequestRepositoryMockUpdateWithTZTx {
|
||||
mmUpdateWithTZTx.optional = true
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// Expect sets up expected params for RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) Expect(ctx context.Context, tx pgx.Tx, id uuid.UUID, tz string, generated bool) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation = &RequestRepositoryMockUpdateWithTZTxExpectation{}
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.paramPtrs != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by ExpectParams functions")
|
||||
}
|
||||
|
||||
mmUpdateWithTZTx.defaultExpectation.params = &RequestRepositoryMockUpdateWithTZTxParams{ctx, tx, id, tz, generated}
|
||||
mmUpdateWithTZTx.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
||||
for _, e := range mmUpdateWithTZTx.expectations {
|
||||
if minimock.Equal(e.params, mmUpdateWithTZTx.defaultExpectation.params) {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateWithTZTx.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// ExpectCtxParam1 sets up expected param ctx for RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation = &RequestRepositoryMockUpdateWithTZTxExpectation{}
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.params != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.paramPtrs == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZTxParamPtrs{}
|
||||
}
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs.ctx = &ctx
|
||||
mmUpdateWithTZTx.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
||||
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// ExpectTxParam2 sets up expected param tx for RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) ExpectTxParam2(tx pgx.Tx) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation = &RequestRepositoryMockUpdateWithTZTxExpectation{}
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.params != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.paramPtrs == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZTxParamPtrs{}
|
||||
}
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs.tx = &tx
|
||||
mmUpdateWithTZTx.defaultExpectation.expectationOrigins.originTx = minimock.CallerInfo(1)
|
||||
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// ExpectIdParam3 sets up expected param id for RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) ExpectIdParam3(id uuid.UUID) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation = &RequestRepositoryMockUpdateWithTZTxExpectation{}
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.params != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.paramPtrs == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZTxParamPtrs{}
|
||||
}
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs.id = &id
|
||||
mmUpdateWithTZTx.defaultExpectation.expectationOrigins.originId = minimock.CallerInfo(1)
|
||||
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// ExpectTzParam4 sets up expected param tz for RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) ExpectTzParam4(tz string) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation = &RequestRepositoryMockUpdateWithTZTxExpectation{}
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.params != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.paramPtrs == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZTxParamPtrs{}
|
||||
}
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs.tz = &tz
|
||||
mmUpdateWithTZTx.defaultExpectation.expectationOrigins.originTz = minimock.CallerInfo(1)
|
||||
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// ExpectGeneratedParam5 sets up expected param generated for RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) ExpectGeneratedParam5(generated bool) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation = &RequestRepositoryMockUpdateWithTZTxExpectation{}
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.params != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation.paramPtrs == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZTxParamPtrs{}
|
||||
}
|
||||
mmUpdateWithTZTx.defaultExpectation.paramPtrs.generated = &generated
|
||||
mmUpdateWithTZTx.defaultExpectation.expectationOrigins.originGenerated = minimock.CallerInfo(1)
|
||||
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// Inspect accepts an inspector function that has same arguments as the RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) Inspect(f func(ctx context.Context, tx pgx.Tx, id uuid.UUID, tz string, generated bool)) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if mmUpdateWithTZTx.mock.inspectFuncUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.UpdateWithTZTx")
|
||||
}
|
||||
|
||||
mmUpdateWithTZTx.mock.inspectFuncUpdateWithTZTx = f
|
||||
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
// Return sets up results that will be returned by RequestRepository.UpdateWithTZTx
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) Return(err error) *RequestRepositoryMock {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.defaultExpectation == nil {
|
||||
mmUpdateWithTZTx.defaultExpectation = &RequestRepositoryMockUpdateWithTZTxExpectation{mock: mmUpdateWithTZTx.mock}
|
||||
}
|
||||
mmUpdateWithTZTx.defaultExpectation.results = &RequestRepositoryMockUpdateWithTZTxResults{err}
|
||||
mmUpdateWithTZTx.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
||||
return mmUpdateWithTZTx.mock
|
||||
}
|
||||
|
||||
// Set uses given function f to mock the RequestRepository.UpdateWithTZTx method
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) Set(f func(ctx context.Context, tx pgx.Tx, id uuid.UUID, tz string, generated bool) (err error)) *RequestRepositoryMock {
|
||||
if mmUpdateWithTZTx.defaultExpectation != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("Default expectation is already set for the RequestRepository.UpdateWithTZTx method")
|
||||
}
|
||||
|
||||
if len(mmUpdateWithTZTx.expectations) > 0 {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("Some expectations are already set for the RequestRepository.UpdateWithTZTx method")
|
||||
}
|
||||
|
||||
mmUpdateWithTZTx.mock.funcUpdateWithTZTx = f
|
||||
mmUpdateWithTZTx.mock.funcUpdateWithTZTxOrigin = minimock.CallerInfo(1)
|
||||
return mmUpdateWithTZTx.mock
|
||||
}
|
||||
|
||||
// When sets expectation for the RequestRepository.UpdateWithTZTx which will trigger the result defined by the following
|
||||
// Then helper
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) When(ctx context.Context, tx pgx.Tx, id uuid.UUID, tz string, generated bool) *RequestRepositoryMockUpdateWithTZTxExpectation {
|
||||
if mmUpdateWithTZTx.mock.funcUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZTx mock is already set by Set")
|
||||
}
|
||||
|
||||
expectation := &RequestRepositoryMockUpdateWithTZTxExpectation{
|
||||
mock: mmUpdateWithTZTx.mock,
|
||||
params: &RequestRepositoryMockUpdateWithTZTxParams{ctx, tx, id, tz, generated},
|
||||
expectationOrigins: RequestRepositoryMockUpdateWithTZTxExpectationOrigins{origin: minimock.CallerInfo(1)},
|
||||
}
|
||||
mmUpdateWithTZTx.expectations = append(mmUpdateWithTZTx.expectations, expectation)
|
||||
return expectation
|
||||
}
|
||||
|
||||
// Then sets up RequestRepository.UpdateWithTZTx return parameters for the expectation previously defined by the When method
|
||||
func (e *RequestRepositoryMockUpdateWithTZTxExpectation) Then(err error) *RequestRepositoryMock {
|
||||
e.results = &RequestRepositoryMockUpdateWithTZTxResults{err}
|
||||
return e.mock
|
||||
}
|
||||
|
||||
// Times sets number of times RequestRepository.UpdateWithTZTx should be invoked
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) Times(n uint64) *mRequestRepositoryMockUpdateWithTZTx {
|
||||
if n == 0 {
|
||||
mmUpdateWithTZTx.mock.t.Fatalf("Times of RequestRepositoryMock.UpdateWithTZTx mock can not be zero")
|
||||
}
|
||||
mm_atomic.StoreUint64(&mmUpdateWithTZTx.expectedInvocations, n)
|
||||
mmUpdateWithTZTx.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
||||
return mmUpdateWithTZTx
|
||||
}
|
||||
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) invocationsDone() bool {
|
||||
if len(mmUpdateWithTZTx.expectations) == 0 && mmUpdateWithTZTx.defaultExpectation == nil && mmUpdateWithTZTx.mock.funcUpdateWithTZTx == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
totalInvocations := mm_atomic.LoadUint64(&mmUpdateWithTZTx.mock.afterUpdateWithTZTxCounter)
|
||||
expectedInvocations := mm_atomic.LoadUint64(&mmUpdateWithTZTx.expectedInvocations)
|
||||
|
||||
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
||||
}
|
||||
|
||||
// UpdateWithTZTx implements mm_repository.RequestRepository
|
||||
func (mmUpdateWithTZTx *RequestRepositoryMock) UpdateWithTZTx(ctx context.Context, tx pgx.Tx, id uuid.UUID, tz string, generated bool) (err error) {
|
||||
mm_atomic.AddUint64(&mmUpdateWithTZTx.beforeUpdateWithTZTxCounter, 1)
|
||||
defer mm_atomic.AddUint64(&mmUpdateWithTZTx.afterUpdateWithTZTxCounter, 1)
|
||||
|
||||
mmUpdateWithTZTx.t.Helper()
|
||||
|
||||
if mmUpdateWithTZTx.inspectFuncUpdateWithTZTx != nil {
|
||||
mmUpdateWithTZTx.inspectFuncUpdateWithTZTx(ctx, tx, id, tz, generated)
|
||||
}
|
||||
|
||||
mm_params := RequestRepositoryMockUpdateWithTZTxParams{ctx, tx, id, tz, generated}
|
||||
|
||||
// Record call args
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.mutex.Lock()
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.callArgs = append(mmUpdateWithTZTx.UpdateWithTZTxMock.callArgs, &mm_params)
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.mutex.Unlock()
|
||||
|
||||
for _, e := range mmUpdateWithTZTx.UpdateWithTZTxMock.expectations {
|
||||
if minimock.Equal(*e.params, mm_params) {
|
||||
mm_atomic.AddUint64(&e.Counter, 1)
|
||||
return e.results.err
|
||||
}
|
||||
}
|
||||
|
||||
if mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation != nil {
|
||||
mm_atomic.AddUint64(&mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.Counter, 1)
|
||||
mm_want := mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.params
|
||||
mm_want_ptrs := mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.paramPtrs
|
||||
|
||||
mm_got := RequestRepositoryMockUpdateWithTZTxParams{ctx, tx, id, tz, generated}
|
||||
|
||||
if mm_want_ptrs != nil {
|
||||
|
||||
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
||||
mmUpdateWithTZTx.t.Errorf("RequestRepositoryMock.UpdateWithTZTx got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
|
||||
mmUpdateWithTZTx.t.Errorf("RequestRepositoryMock.UpdateWithTZTx got unexpected parameter tx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.expectationOrigins.originTx, *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
|
||||
mmUpdateWithTZTx.t.Errorf("RequestRepositoryMock.UpdateWithTZTx got unexpected parameter id, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.expectationOrigins.originId, *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.tz != nil && !minimock.Equal(*mm_want_ptrs.tz, mm_got.tz) {
|
||||
mmUpdateWithTZTx.t.Errorf("RequestRepositoryMock.UpdateWithTZTx got unexpected parameter tz, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.expectationOrigins.originTz, *mm_want_ptrs.tz, mm_got.tz, minimock.Diff(*mm_want_ptrs.tz, mm_got.tz))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.generated != nil && !minimock.Equal(*mm_want_ptrs.generated, mm_got.generated) {
|
||||
mmUpdateWithTZTx.t.Errorf("RequestRepositoryMock.UpdateWithTZTx got unexpected parameter generated, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.expectationOrigins.originGenerated, *mm_want_ptrs.generated, mm_got.generated, minimock.Diff(*mm_want_ptrs.generated, mm_got.generated))
|
||||
}
|
||||
|
||||
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
||||
mmUpdateWithTZTx.t.Errorf("RequestRepositoryMock.UpdateWithTZTx got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
||||
}
|
||||
|
||||
mm_results := mmUpdateWithTZTx.UpdateWithTZTxMock.defaultExpectation.results
|
||||
if mm_results == nil {
|
||||
mmUpdateWithTZTx.t.Fatal("No results are set for the RequestRepositoryMock.UpdateWithTZTx")
|
||||
}
|
||||
return (*mm_results).err
|
||||
}
|
||||
if mmUpdateWithTZTx.funcUpdateWithTZTx != nil {
|
||||
return mmUpdateWithTZTx.funcUpdateWithTZTx(ctx, tx, id, tz, generated)
|
||||
}
|
||||
mmUpdateWithTZTx.t.Fatalf("Unexpected call to RequestRepositoryMock.UpdateWithTZTx. %v %v %v %v %v", ctx, tx, id, tz, generated)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateWithTZTxAfterCounter returns a count of finished RequestRepositoryMock.UpdateWithTZTx invocations
|
||||
func (mmUpdateWithTZTx *RequestRepositoryMock) UpdateWithTZTxAfterCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmUpdateWithTZTx.afterUpdateWithTZTxCounter)
|
||||
}
|
||||
|
||||
// UpdateWithTZTxBeforeCounter returns a count of RequestRepositoryMock.UpdateWithTZTx invocations
|
||||
func (mmUpdateWithTZTx *RequestRepositoryMock) UpdateWithTZTxBeforeCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmUpdateWithTZTx.beforeUpdateWithTZTxCounter)
|
||||
}
|
||||
|
||||
// Calls returns a list of arguments used in each call to RequestRepositoryMock.UpdateWithTZTx.
|
||||
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
||||
func (mmUpdateWithTZTx *mRequestRepositoryMockUpdateWithTZTx) Calls() []*RequestRepositoryMockUpdateWithTZTxParams {
|
||||
mmUpdateWithTZTx.mutex.RLock()
|
||||
|
||||
argCopy := make([]*RequestRepositoryMockUpdateWithTZTxParams, len(mmUpdateWithTZTx.callArgs))
|
||||
copy(argCopy, mmUpdateWithTZTx.callArgs)
|
||||
|
||||
mmUpdateWithTZTx.mutex.RUnlock()
|
||||
|
||||
return argCopy
|
||||
}
|
||||
|
||||
// MinimockUpdateWithTZTxDone returns true if the count of the UpdateWithTZTx invocations corresponds
|
||||
// the number of defined expectations
|
||||
func (m *RequestRepositoryMock) MinimockUpdateWithTZTxDone() bool {
|
||||
if m.UpdateWithTZTxMock.optional {
|
||||
// Optional methods provide '0 or more' call count restriction.
|
||||
return true
|
||||
}
|
||||
|
||||
for _, e := range m.UpdateWithTZTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return m.UpdateWithTZTxMock.invocationsDone()
|
||||
}
|
||||
|
||||
// MinimockUpdateWithTZTxInspect logs each unmet expectation
|
||||
func (m *RequestRepositoryMock) MinimockUpdateWithTZTxInspect() {
|
||||
for _, e := range m.UpdateWithTZTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZTx at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
||||
}
|
||||
}
|
||||
|
||||
afterUpdateWithTZTxCounter := mm_atomic.LoadUint64(&m.afterUpdateWithTZTxCounter)
|
||||
// if default expectation was set then invocations count should be greater than zero
|
||||
if m.UpdateWithTZTxMock.defaultExpectation != nil && afterUpdateWithTZTxCounter < 1 {
|
||||
if m.UpdateWithTZTxMock.defaultExpectation.params == nil {
|
||||
m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZTx at\n%s", m.UpdateWithTZTxMock.defaultExpectation.returnOrigin)
|
||||
} else {
|
||||
m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZTx at\n%s with params: %#v", m.UpdateWithTZTxMock.defaultExpectation.expectationOrigins.origin, *m.UpdateWithTZTxMock.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
// if func was set then invocations count should be greater than zero
|
||||
if m.funcUpdateWithTZTx != nil && afterUpdateWithTZTxCounter < 1 {
|
||||
m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZTx at\n%s", m.funcUpdateWithTZTxOrigin)
|
||||
}
|
||||
|
||||
if !m.UpdateWithTZTxMock.invocationsDone() && afterUpdateWithTZTxCounter > 0 {
|
||||
m.t.Errorf("Expected %d calls to RequestRepositoryMock.UpdateWithTZTx at\n%s but found %d calls",
|
||||
mm_atomic.LoadUint64(&m.UpdateWithTZTxMock.expectedInvocations), m.UpdateWithTZTxMock.expectedInvocationsOrigin, afterUpdateWithTZTxCounter)
|
||||
}
|
||||
}
|
||||
|
||||
// MinimockFinish checks that all mocked methods have been called the expected number of times
|
||||
func (m *RequestRepositoryMock) MinimockFinish() {
|
||||
m.finishOnce.Do(func() {
|
||||
@@ -2614,6 +3060,8 @@ func (m *RequestRepositoryMock) MinimockFinish() {
|
||||
m.MinimockUpdateFinalTZInspect()
|
||||
|
||||
m.MinimockUpdateWithTZInspect()
|
||||
|
||||
m.MinimockUpdateWithTZTxInspect()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -2643,5 +3091,6 @@ func (m *RequestRepositoryMock) minimockDone() bool {
|
||||
m.MinimockGetDetailByIDDone() &&
|
||||
m.MinimockGetUserStatisticsDone() &&
|
||||
m.MinimockUpdateFinalTZDone() &&
|
||||
m.MinimockUpdateWithTZDone()
|
||||
m.MinimockUpdateWithTZDone() &&
|
||||
m.MinimockUpdateWithTZTxDone()
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/service.RequestService -o request_service_mock.go -n RequestServiceMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/service.RequestService -o request_service_mock.go -n RequestServiceMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"smart-search-back/internal/model"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/repository.SessionRepository -o session_repository_mock.go -n SessionRepositoryMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/repository.SessionRepository -o session_repository_mock.go -n SessionRepositoryMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"smart-search-back/internal/model"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
)
|
||||
|
||||
@@ -40,6 +40,13 @@ type SessionRepositoryMock struct {
|
||||
beforeFindByRefreshTokenCounter uint64
|
||||
FindByRefreshTokenMock mSessionRepositoryMockFindByRefreshToken
|
||||
|
||||
funcIsAccessTokenValid func(ctx context.Context, accessToken string) (b1 bool, err error)
|
||||
funcIsAccessTokenValidOrigin string
|
||||
inspectFuncIsAccessTokenValid func(ctx context.Context, accessToken string)
|
||||
afterIsAccessTokenValidCounter uint64
|
||||
beforeIsAccessTokenValidCounter uint64
|
||||
IsAccessTokenValidMock mSessionRepositoryMockIsAccessTokenValid
|
||||
|
||||
funcRevoke func(ctx context.Context, refreshToken string) (err error)
|
||||
funcRevokeOrigin string
|
||||
inspectFuncRevoke func(ctx context.Context, refreshToken string)
|
||||
@@ -47,6 +54,13 @@ type SessionRepositoryMock struct {
|
||||
beforeRevokeCounter uint64
|
||||
RevokeMock mSessionRepositoryMockRevoke
|
||||
|
||||
funcRevokeByAccessToken func(ctx context.Context, accessToken string) (err error)
|
||||
funcRevokeByAccessTokenOrigin string
|
||||
inspectFuncRevokeByAccessToken func(ctx context.Context, accessToken string)
|
||||
afterRevokeByAccessTokenCounter uint64
|
||||
beforeRevokeByAccessTokenCounter uint64
|
||||
RevokeByAccessTokenMock mSessionRepositoryMockRevokeByAccessToken
|
||||
|
||||
funcUpdateAccessToken func(ctx context.Context, refreshToken string, newAccessToken string) (err error)
|
||||
funcUpdateAccessTokenOrigin string
|
||||
inspectFuncUpdateAccessToken func(ctx context.Context, refreshToken string, newAccessToken string)
|
||||
@@ -72,9 +86,15 @@ func NewSessionRepositoryMock(t minimock.Tester) *SessionRepositoryMock {
|
||||
m.FindByRefreshTokenMock = mSessionRepositoryMockFindByRefreshToken{mock: m}
|
||||
m.FindByRefreshTokenMock.callArgs = []*SessionRepositoryMockFindByRefreshTokenParams{}
|
||||
|
||||
m.IsAccessTokenValidMock = mSessionRepositoryMockIsAccessTokenValid{mock: m}
|
||||
m.IsAccessTokenValidMock.callArgs = []*SessionRepositoryMockIsAccessTokenValidParams{}
|
||||
|
||||
m.RevokeMock = mSessionRepositoryMockRevoke{mock: m}
|
||||
m.RevokeMock.callArgs = []*SessionRepositoryMockRevokeParams{}
|
||||
|
||||
m.RevokeByAccessTokenMock = mSessionRepositoryMockRevokeByAccessToken{mock: m}
|
||||
m.RevokeByAccessTokenMock.callArgs = []*SessionRepositoryMockRevokeByAccessTokenParams{}
|
||||
|
||||
m.UpdateAccessTokenMock = mSessionRepositoryMockUpdateAccessToken{mock: m}
|
||||
m.UpdateAccessTokenMock.callArgs = []*SessionRepositoryMockUpdateAccessTokenParams{}
|
||||
|
||||
@@ -1080,6 +1100,349 @@ func (m *SessionRepositoryMock) MinimockFindByRefreshTokenInspect() {
|
||||
}
|
||||
}
|
||||
|
||||
type mSessionRepositoryMockIsAccessTokenValid struct {
|
||||
optional bool
|
||||
mock *SessionRepositoryMock
|
||||
defaultExpectation *SessionRepositoryMockIsAccessTokenValidExpectation
|
||||
expectations []*SessionRepositoryMockIsAccessTokenValidExpectation
|
||||
|
||||
callArgs []*SessionRepositoryMockIsAccessTokenValidParams
|
||||
mutex sync.RWMutex
|
||||
|
||||
expectedInvocations uint64
|
||||
expectedInvocationsOrigin string
|
||||
}
|
||||
|
||||
// SessionRepositoryMockIsAccessTokenValidExpectation specifies expectation struct of the SessionRepository.IsAccessTokenValid
|
||||
type SessionRepositoryMockIsAccessTokenValidExpectation struct {
|
||||
mock *SessionRepositoryMock
|
||||
params *SessionRepositoryMockIsAccessTokenValidParams
|
||||
paramPtrs *SessionRepositoryMockIsAccessTokenValidParamPtrs
|
||||
expectationOrigins SessionRepositoryMockIsAccessTokenValidExpectationOrigins
|
||||
results *SessionRepositoryMockIsAccessTokenValidResults
|
||||
returnOrigin string
|
||||
Counter uint64
|
||||
}
|
||||
|
||||
// SessionRepositoryMockIsAccessTokenValidParams contains parameters of the SessionRepository.IsAccessTokenValid
|
||||
type SessionRepositoryMockIsAccessTokenValidParams struct {
|
||||
ctx context.Context
|
||||
accessToken string
|
||||
}
|
||||
|
||||
// SessionRepositoryMockIsAccessTokenValidParamPtrs contains pointers to parameters of the SessionRepository.IsAccessTokenValid
|
||||
type SessionRepositoryMockIsAccessTokenValidParamPtrs struct {
|
||||
ctx *context.Context
|
||||
accessToken *string
|
||||
}
|
||||
|
||||
// SessionRepositoryMockIsAccessTokenValidResults contains results of the SessionRepository.IsAccessTokenValid
|
||||
type SessionRepositoryMockIsAccessTokenValidResults struct {
|
||||
b1 bool
|
||||
err error
|
||||
}
|
||||
|
||||
// SessionRepositoryMockIsAccessTokenValidOrigins contains origins of expectations of the SessionRepository.IsAccessTokenValid
|
||||
type SessionRepositoryMockIsAccessTokenValidExpectationOrigins struct {
|
||||
origin string
|
||||
originCtx string
|
||||
originAccessToken string
|
||||
}
|
||||
|
||||
// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
|
||||
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
|
||||
// Optional() makes method check to work in '0 or more' mode.
|
||||
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
|
||||
// catch the problems when the expected method call is totally skipped during test run.
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Optional() *mSessionRepositoryMockIsAccessTokenValid {
|
||||
mmIsAccessTokenValid.optional = true
|
||||
return mmIsAccessTokenValid
|
||||
}
|
||||
|
||||
// Expect sets up expected params for SessionRepository.IsAccessTokenValid
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Expect(ctx context.Context, accessToken string) *mSessionRepositoryMockIsAccessTokenValid {
|
||||
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation == nil {
|
||||
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{}
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation.paramPtrs != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by ExpectParams functions")
|
||||
}
|
||||
|
||||
mmIsAccessTokenValid.defaultExpectation.params = &SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken}
|
||||
mmIsAccessTokenValid.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
||||
for _, e := range mmIsAccessTokenValid.expectations {
|
||||
if minimock.Equal(e.params, mmIsAccessTokenValid.defaultExpectation.params) {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsAccessTokenValid.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
|
||||
return mmIsAccessTokenValid
|
||||
}
|
||||
|
||||
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.IsAccessTokenValid
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockIsAccessTokenValid {
|
||||
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation == nil {
|
||||
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{}
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation.params != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation.paramPtrs == nil {
|
||||
mmIsAccessTokenValid.defaultExpectation.paramPtrs = &SessionRepositoryMockIsAccessTokenValidParamPtrs{}
|
||||
}
|
||||
mmIsAccessTokenValid.defaultExpectation.paramPtrs.ctx = &ctx
|
||||
mmIsAccessTokenValid.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
||||
|
||||
return mmIsAccessTokenValid
|
||||
}
|
||||
|
||||
// ExpectAccessTokenParam2 sets up expected param accessToken for SessionRepository.IsAccessTokenValid
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) ExpectAccessTokenParam2(accessToken string) *mSessionRepositoryMockIsAccessTokenValid {
|
||||
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation == nil {
|
||||
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{}
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation.params != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation.paramPtrs == nil {
|
||||
mmIsAccessTokenValid.defaultExpectation.paramPtrs = &SessionRepositoryMockIsAccessTokenValidParamPtrs{}
|
||||
}
|
||||
mmIsAccessTokenValid.defaultExpectation.paramPtrs.accessToken = &accessToken
|
||||
mmIsAccessTokenValid.defaultExpectation.expectationOrigins.originAccessToken = minimock.CallerInfo(1)
|
||||
|
||||
return mmIsAccessTokenValid
|
||||
}
|
||||
|
||||
// Inspect accepts an inspector function that has same arguments as the SessionRepository.IsAccessTokenValid
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Inspect(f func(ctx context.Context, accessToken string)) *mSessionRepositoryMockIsAccessTokenValid {
|
||||
if mmIsAccessTokenValid.mock.inspectFuncIsAccessTokenValid != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.IsAccessTokenValid")
|
||||
}
|
||||
|
||||
mmIsAccessTokenValid.mock.inspectFuncIsAccessTokenValid = f
|
||||
|
||||
return mmIsAccessTokenValid
|
||||
}
|
||||
|
||||
// Return sets up results that will be returned by SessionRepository.IsAccessTokenValid
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Return(b1 bool, err error) *SessionRepositoryMock {
|
||||
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.defaultExpectation == nil {
|
||||
mmIsAccessTokenValid.defaultExpectation = &SessionRepositoryMockIsAccessTokenValidExpectation{mock: mmIsAccessTokenValid.mock}
|
||||
}
|
||||
mmIsAccessTokenValid.defaultExpectation.results = &SessionRepositoryMockIsAccessTokenValidResults{b1, err}
|
||||
mmIsAccessTokenValid.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
||||
return mmIsAccessTokenValid.mock
|
||||
}
|
||||
|
||||
// Set uses given function f to mock the SessionRepository.IsAccessTokenValid method
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Set(f func(ctx context.Context, accessToken string) (b1 bool, err error)) *SessionRepositoryMock {
|
||||
if mmIsAccessTokenValid.defaultExpectation != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("Default expectation is already set for the SessionRepository.IsAccessTokenValid method")
|
||||
}
|
||||
|
||||
if len(mmIsAccessTokenValid.expectations) > 0 {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("Some expectations are already set for the SessionRepository.IsAccessTokenValid method")
|
||||
}
|
||||
|
||||
mmIsAccessTokenValid.mock.funcIsAccessTokenValid = f
|
||||
mmIsAccessTokenValid.mock.funcIsAccessTokenValidOrigin = minimock.CallerInfo(1)
|
||||
return mmIsAccessTokenValid.mock
|
||||
}
|
||||
|
||||
// When sets expectation for the SessionRepository.IsAccessTokenValid which will trigger the result defined by the following
|
||||
// Then helper
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) When(ctx context.Context, accessToken string) *SessionRepositoryMockIsAccessTokenValidExpectation {
|
||||
if mmIsAccessTokenValid.mock.funcIsAccessTokenValid != nil {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("SessionRepositoryMock.IsAccessTokenValid mock is already set by Set")
|
||||
}
|
||||
|
||||
expectation := &SessionRepositoryMockIsAccessTokenValidExpectation{
|
||||
mock: mmIsAccessTokenValid.mock,
|
||||
params: &SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken},
|
||||
expectationOrigins: SessionRepositoryMockIsAccessTokenValidExpectationOrigins{origin: minimock.CallerInfo(1)},
|
||||
}
|
||||
mmIsAccessTokenValid.expectations = append(mmIsAccessTokenValid.expectations, expectation)
|
||||
return expectation
|
||||
}
|
||||
|
||||
// Then sets up SessionRepository.IsAccessTokenValid return parameters for the expectation previously defined by the When method
|
||||
func (e *SessionRepositoryMockIsAccessTokenValidExpectation) Then(b1 bool, err error) *SessionRepositoryMock {
|
||||
e.results = &SessionRepositoryMockIsAccessTokenValidResults{b1, err}
|
||||
return e.mock
|
||||
}
|
||||
|
||||
// Times sets number of times SessionRepository.IsAccessTokenValid should be invoked
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Times(n uint64) *mSessionRepositoryMockIsAccessTokenValid {
|
||||
if n == 0 {
|
||||
mmIsAccessTokenValid.mock.t.Fatalf("Times of SessionRepositoryMock.IsAccessTokenValid mock can not be zero")
|
||||
}
|
||||
mm_atomic.StoreUint64(&mmIsAccessTokenValid.expectedInvocations, n)
|
||||
mmIsAccessTokenValid.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
||||
return mmIsAccessTokenValid
|
||||
}
|
||||
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) invocationsDone() bool {
|
||||
if len(mmIsAccessTokenValid.expectations) == 0 && mmIsAccessTokenValid.defaultExpectation == nil && mmIsAccessTokenValid.mock.funcIsAccessTokenValid == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
totalInvocations := mm_atomic.LoadUint64(&mmIsAccessTokenValid.mock.afterIsAccessTokenValidCounter)
|
||||
expectedInvocations := mm_atomic.LoadUint64(&mmIsAccessTokenValid.expectedInvocations)
|
||||
|
||||
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
||||
}
|
||||
|
||||
// IsAccessTokenValid implements mm_repository.SessionRepository
|
||||
func (mmIsAccessTokenValid *SessionRepositoryMock) IsAccessTokenValid(ctx context.Context, accessToken string) (b1 bool, err error) {
|
||||
mm_atomic.AddUint64(&mmIsAccessTokenValid.beforeIsAccessTokenValidCounter, 1)
|
||||
defer mm_atomic.AddUint64(&mmIsAccessTokenValid.afterIsAccessTokenValidCounter, 1)
|
||||
|
||||
mmIsAccessTokenValid.t.Helper()
|
||||
|
||||
if mmIsAccessTokenValid.inspectFuncIsAccessTokenValid != nil {
|
||||
mmIsAccessTokenValid.inspectFuncIsAccessTokenValid(ctx, accessToken)
|
||||
}
|
||||
|
||||
mm_params := SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken}
|
||||
|
||||
// Record call args
|
||||
mmIsAccessTokenValid.IsAccessTokenValidMock.mutex.Lock()
|
||||
mmIsAccessTokenValid.IsAccessTokenValidMock.callArgs = append(mmIsAccessTokenValid.IsAccessTokenValidMock.callArgs, &mm_params)
|
||||
mmIsAccessTokenValid.IsAccessTokenValidMock.mutex.Unlock()
|
||||
|
||||
for _, e := range mmIsAccessTokenValid.IsAccessTokenValidMock.expectations {
|
||||
if minimock.Equal(*e.params, mm_params) {
|
||||
mm_atomic.AddUint64(&e.Counter, 1)
|
||||
return e.results.b1, e.results.err
|
||||
}
|
||||
}
|
||||
|
||||
if mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation != nil {
|
||||
mm_atomic.AddUint64(&mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.Counter, 1)
|
||||
mm_want := mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.params
|
||||
mm_want_ptrs := mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.paramPtrs
|
||||
|
||||
mm_got := SessionRepositoryMockIsAccessTokenValidParams{ctx, accessToken}
|
||||
|
||||
if mm_want_ptrs != nil {
|
||||
|
||||
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
||||
mmIsAccessTokenValid.t.Errorf("SessionRepositoryMock.IsAccessTokenValid got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.accessToken != nil && !minimock.Equal(*mm_want_ptrs.accessToken, mm_got.accessToken) {
|
||||
mmIsAccessTokenValid.t.Errorf("SessionRepositoryMock.IsAccessTokenValid got unexpected parameter accessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.originAccessToken, *mm_want_ptrs.accessToken, mm_got.accessToken, minimock.Diff(*mm_want_ptrs.accessToken, mm_got.accessToken))
|
||||
}
|
||||
|
||||
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
||||
mmIsAccessTokenValid.t.Errorf("SessionRepositoryMock.IsAccessTokenValid got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
||||
}
|
||||
|
||||
mm_results := mmIsAccessTokenValid.IsAccessTokenValidMock.defaultExpectation.results
|
||||
if mm_results == nil {
|
||||
mmIsAccessTokenValid.t.Fatal("No results are set for the SessionRepositoryMock.IsAccessTokenValid")
|
||||
}
|
||||
return (*mm_results).b1, (*mm_results).err
|
||||
}
|
||||
if mmIsAccessTokenValid.funcIsAccessTokenValid != nil {
|
||||
return mmIsAccessTokenValid.funcIsAccessTokenValid(ctx, accessToken)
|
||||
}
|
||||
mmIsAccessTokenValid.t.Fatalf("Unexpected call to SessionRepositoryMock.IsAccessTokenValid. %v %v", ctx, accessToken)
|
||||
return
|
||||
}
|
||||
|
||||
// IsAccessTokenValidAfterCounter returns a count of finished SessionRepositoryMock.IsAccessTokenValid invocations
|
||||
func (mmIsAccessTokenValid *SessionRepositoryMock) IsAccessTokenValidAfterCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmIsAccessTokenValid.afterIsAccessTokenValidCounter)
|
||||
}
|
||||
|
||||
// IsAccessTokenValidBeforeCounter returns a count of SessionRepositoryMock.IsAccessTokenValid invocations
|
||||
func (mmIsAccessTokenValid *SessionRepositoryMock) IsAccessTokenValidBeforeCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmIsAccessTokenValid.beforeIsAccessTokenValidCounter)
|
||||
}
|
||||
|
||||
// Calls returns a list of arguments used in each call to SessionRepositoryMock.IsAccessTokenValid.
|
||||
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
||||
func (mmIsAccessTokenValid *mSessionRepositoryMockIsAccessTokenValid) Calls() []*SessionRepositoryMockIsAccessTokenValidParams {
|
||||
mmIsAccessTokenValid.mutex.RLock()
|
||||
|
||||
argCopy := make([]*SessionRepositoryMockIsAccessTokenValidParams, len(mmIsAccessTokenValid.callArgs))
|
||||
copy(argCopy, mmIsAccessTokenValid.callArgs)
|
||||
|
||||
mmIsAccessTokenValid.mutex.RUnlock()
|
||||
|
||||
return argCopy
|
||||
}
|
||||
|
||||
// MinimockIsAccessTokenValidDone returns true if the count of the IsAccessTokenValid invocations corresponds
|
||||
// the number of defined expectations
|
||||
func (m *SessionRepositoryMock) MinimockIsAccessTokenValidDone() bool {
|
||||
if m.IsAccessTokenValidMock.optional {
|
||||
// Optional methods provide '0 or more' call count restriction.
|
||||
return true
|
||||
}
|
||||
|
||||
for _, e := range m.IsAccessTokenValidMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return m.IsAccessTokenValidMock.invocationsDone()
|
||||
}
|
||||
|
||||
// MinimockIsAccessTokenValidInspect logs each unmet expectation
|
||||
func (m *SessionRepositoryMock) MinimockIsAccessTokenValidInspect() {
|
||||
for _, e := range m.IsAccessTokenValidMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
||||
}
|
||||
}
|
||||
|
||||
afterIsAccessTokenValidCounter := mm_atomic.LoadUint64(&m.afterIsAccessTokenValidCounter)
|
||||
// if default expectation was set then invocations count should be greater than zero
|
||||
if m.IsAccessTokenValidMock.defaultExpectation != nil && afterIsAccessTokenValidCounter < 1 {
|
||||
if m.IsAccessTokenValidMock.defaultExpectation.params == nil {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s", m.IsAccessTokenValidMock.defaultExpectation.returnOrigin)
|
||||
} else {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s with params: %#v", m.IsAccessTokenValidMock.defaultExpectation.expectationOrigins.origin, *m.IsAccessTokenValidMock.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
// if func was set then invocations count should be greater than zero
|
||||
if m.funcIsAccessTokenValid != nil && afterIsAccessTokenValidCounter < 1 {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.IsAccessTokenValid at\n%s", m.funcIsAccessTokenValidOrigin)
|
||||
}
|
||||
|
||||
if !m.IsAccessTokenValidMock.invocationsDone() && afterIsAccessTokenValidCounter > 0 {
|
||||
m.t.Errorf("Expected %d calls to SessionRepositoryMock.IsAccessTokenValid at\n%s but found %d calls",
|
||||
mm_atomic.LoadUint64(&m.IsAccessTokenValidMock.expectedInvocations), m.IsAccessTokenValidMock.expectedInvocationsOrigin, afterIsAccessTokenValidCounter)
|
||||
}
|
||||
}
|
||||
|
||||
type mSessionRepositoryMockRevoke struct {
|
||||
optional bool
|
||||
mock *SessionRepositoryMock
|
||||
@@ -1422,6 +1785,348 @@ func (m *SessionRepositoryMock) MinimockRevokeInspect() {
|
||||
}
|
||||
}
|
||||
|
||||
type mSessionRepositoryMockRevokeByAccessToken struct {
|
||||
optional bool
|
||||
mock *SessionRepositoryMock
|
||||
defaultExpectation *SessionRepositoryMockRevokeByAccessTokenExpectation
|
||||
expectations []*SessionRepositoryMockRevokeByAccessTokenExpectation
|
||||
|
||||
callArgs []*SessionRepositoryMockRevokeByAccessTokenParams
|
||||
mutex sync.RWMutex
|
||||
|
||||
expectedInvocations uint64
|
||||
expectedInvocationsOrigin string
|
||||
}
|
||||
|
||||
// SessionRepositoryMockRevokeByAccessTokenExpectation specifies expectation struct of the SessionRepository.RevokeByAccessToken
|
||||
type SessionRepositoryMockRevokeByAccessTokenExpectation struct {
|
||||
mock *SessionRepositoryMock
|
||||
params *SessionRepositoryMockRevokeByAccessTokenParams
|
||||
paramPtrs *SessionRepositoryMockRevokeByAccessTokenParamPtrs
|
||||
expectationOrigins SessionRepositoryMockRevokeByAccessTokenExpectationOrigins
|
||||
results *SessionRepositoryMockRevokeByAccessTokenResults
|
||||
returnOrigin string
|
||||
Counter uint64
|
||||
}
|
||||
|
||||
// SessionRepositoryMockRevokeByAccessTokenParams contains parameters of the SessionRepository.RevokeByAccessToken
|
||||
type SessionRepositoryMockRevokeByAccessTokenParams struct {
|
||||
ctx context.Context
|
||||
accessToken string
|
||||
}
|
||||
|
||||
// SessionRepositoryMockRevokeByAccessTokenParamPtrs contains pointers to parameters of the SessionRepository.RevokeByAccessToken
|
||||
type SessionRepositoryMockRevokeByAccessTokenParamPtrs struct {
|
||||
ctx *context.Context
|
||||
accessToken *string
|
||||
}
|
||||
|
||||
// SessionRepositoryMockRevokeByAccessTokenResults contains results of the SessionRepository.RevokeByAccessToken
|
||||
type SessionRepositoryMockRevokeByAccessTokenResults struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// SessionRepositoryMockRevokeByAccessTokenOrigins contains origins of expectations of the SessionRepository.RevokeByAccessToken
|
||||
type SessionRepositoryMockRevokeByAccessTokenExpectationOrigins struct {
|
||||
origin string
|
||||
originCtx string
|
||||
originAccessToken string
|
||||
}
|
||||
|
||||
// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
|
||||
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
|
||||
// Optional() makes method check to work in '0 or more' mode.
|
||||
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
|
||||
// catch the problems when the expected method call is totally skipped during test run.
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Optional() *mSessionRepositoryMockRevokeByAccessToken {
|
||||
mmRevokeByAccessToken.optional = true
|
||||
return mmRevokeByAccessToken
|
||||
}
|
||||
|
||||
// Expect sets up expected params for SessionRepository.RevokeByAccessToken
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Expect(ctx context.Context, accessToken string) *mSessionRepositoryMockRevokeByAccessToken {
|
||||
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation == nil {
|
||||
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{}
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation.paramPtrs != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by ExpectParams functions")
|
||||
}
|
||||
|
||||
mmRevokeByAccessToken.defaultExpectation.params = &SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken}
|
||||
mmRevokeByAccessToken.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
||||
for _, e := range mmRevokeByAccessToken.expectations {
|
||||
if minimock.Equal(e.params, mmRevokeByAccessToken.defaultExpectation.params) {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRevokeByAccessToken.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
|
||||
return mmRevokeByAccessToken
|
||||
}
|
||||
|
||||
// ExpectCtxParam1 sets up expected param ctx for SessionRepository.RevokeByAccessToken
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockRevokeByAccessToken {
|
||||
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation == nil {
|
||||
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{}
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation.params != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation.paramPtrs == nil {
|
||||
mmRevokeByAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeByAccessTokenParamPtrs{}
|
||||
}
|
||||
mmRevokeByAccessToken.defaultExpectation.paramPtrs.ctx = &ctx
|
||||
mmRevokeByAccessToken.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
||||
|
||||
return mmRevokeByAccessToken
|
||||
}
|
||||
|
||||
// ExpectAccessTokenParam2 sets up expected param accessToken for SessionRepository.RevokeByAccessToken
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) ExpectAccessTokenParam2(accessToken string) *mSessionRepositoryMockRevokeByAccessToken {
|
||||
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation == nil {
|
||||
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{}
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation.params != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation.paramPtrs == nil {
|
||||
mmRevokeByAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeByAccessTokenParamPtrs{}
|
||||
}
|
||||
mmRevokeByAccessToken.defaultExpectation.paramPtrs.accessToken = &accessToken
|
||||
mmRevokeByAccessToken.defaultExpectation.expectationOrigins.originAccessToken = minimock.CallerInfo(1)
|
||||
|
||||
return mmRevokeByAccessToken
|
||||
}
|
||||
|
||||
// Inspect accepts an inspector function that has same arguments as the SessionRepository.RevokeByAccessToken
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Inspect(f func(ctx context.Context, accessToken string)) *mSessionRepositoryMockRevokeByAccessToken {
|
||||
if mmRevokeByAccessToken.mock.inspectFuncRevokeByAccessToken != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.RevokeByAccessToken")
|
||||
}
|
||||
|
||||
mmRevokeByAccessToken.mock.inspectFuncRevokeByAccessToken = f
|
||||
|
||||
return mmRevokeByAccessToken
|
||||
}
|
||||
|
||||
// Return sets up results that will be returned by SessionRepository.RevokeByAccessToken
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Return(err error) *SessionRepositoryMock {
|
||||
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.defaultExpectation == nil {
|
||||
mmRevokeByAccessToken.defaultExpectation = &SessionRepositoryMockRevokeByAccessTokenExpectation{mock: mmRevokeByAccessToken.mock}
|
||||
}
|
||||
mmRevokeByAccessToken.defaultExpectation.results = &SessionRepositoryMockRevokeByAccessTokenResults{err}
|
||||
mmRevokeByAccessToken.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
||||
return mmRevokeByAccessToken.mock
|
||||
}
|
||||
|
||||
// Set uses given function f to mock the SessionRepository.RevokeByAccessToken method
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Set(f func(ctx context.Context, accessToken string) (err error)) *SessionRepositoryMock {
|
||||
if mmRevokeByAccessToken.defaultExpectation != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("Default expectation is already set for the SessionRepository.RevokeByAccessToken method")
|
||||
}
|
||||
|
||||
if len(mmRevokeByAccessToken.expectations) > 0 {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("Some expectations are already set for the SessionRepository.RevokeByAccessToken method")
|
||||
}
|
||||
|
||||
mmRevokeByAccessToken.mock.funcRevokeByAccessToken = f
|
||||
mmRevokeByAccessToken.mock.funcRevokeByAccessTokenOrigin = minimock.CallerInfo(1)
|
||||
return mmRevokeByAccessToken.mock
|
||||
}
|
||||
|
||||
// When sets expectation for the SessionRepository.RevokeByAccessToken which will trigger the result defined by the following
|
||||
// Then helper
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) When(ctx context.Context, accessToken string) *SessionRepositoryMockRevokeByAccessTokenExpectation {
|
||||
if mmRevokeByAccessToken.mock.funcRevokeByAccessToken != nil {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("SessionRepositoryMock.RevokeByAccessToken mock is already set by Set")
|
||||
}
|
||||
|
||||
expectation := &SessionRepositoryMockRevokeByAccessTokenExpectation{
|
||||
mock: mmRevokeByAccessToken.mock,
|
||||
params: &SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken},
|
||||
expectationOrigins: SessionRepositoryMockRevokeByAccessTokenExpectationOrigins{origin: minimock.CallerInfo(1)},
|
||||
}
|
||||
mmRevokeByAccessToken.expectations = append(mmRevokeByAccessToken.expectations, expectation)
|
||||
return expectation
|
||||
}
|
||||
|
||||
// Then sets up SessionRepository.RevokeByAccessToken return parameters for the expectation previously defined by the When method
|
||||
func (e *SessionRepositoryMockRevokeByAccessTokenExpectation) Then(err error) *SessionRepositoryMock {
|
||||
e.results = &SessionRepositoryMockRevokeByAccessTokenResults{err}
|
||||
return e.mock
|
||||
}
|
||||
|
||||
// Times sets number of times SessionRepository.RevokeByAccessToken should be invoked
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Times(n uint64) *mSessionRepositoryMockRevokeByAccessToken {
|
||||
if n == 0 {
|
||||
mmRevokeByAccessToken.mock.t.Fatalf("Times of SessionRepositoryMock.RevokeByAccessToken mock can not be zero")
|
||||
}
|
||||
mm_atomic.StoreUint64(&mmRevokeByAccessToken.expectedInvocations, n)
|
||||
mmRevokeByAccessToken.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
||||
return mmRevokeByAccessToken
|
||||
}
|
||||
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) invocationsDone() bool {
|
||||
if len(mmRevokeByAccessToken.expectations) == 0 && mmRevokeByAccessToken.defaultExpectation == nil && mmRevokeByAccessToken.mock.funcRevokeByAccessToken == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
totalInvocations := mm_atomic.LoadUint64(&mmRevokeByAccessToken.mock.afterRevokeByAccessTokenCounter)
|
||||
expectedInvocations := mm_atomic.LoadUint64(&mmRevokeByAccessToken.expectedInvocations)
|
||||
|
||||
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
||||
}
|
||||
|
||||
// RevokeByAccessToken implements mm_repository.SessionRepository
|
||||
func (mmRevokeByAccessToken *SessionRepositoryMock) RevokeByAccessToken(ctx context.Context, accessToken string) (err error) {
|
||||
mm_atomic.AddUint64(&mmRevokeByAccessToken.beforeRevokeByAccessTokenCounter, 1)
|
||||
defer mm_atomic.AddUint64(&mmRevokeByAccessToken.afterRevokeByAccessTokenCounter, 1)
|
||||
|
||||
mmRevokeByAccessToken.t.Helper()
|
||||
|
||||
if mmRevokeByAccessToken.inspectFuncRevokeByAccessToken != nil {
|
||||
mmRevokeByAccessToken.inspectFuncRevokeByAccessToken(ctx, accessToken)
|
||||
}
|
||||
|
||||
mm_params := SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken}
|
||||
|
||||
// Record call args
|
||||
mmRevokeByAccessToken.RevokeByAccessTokenMock.mutex.Lock()
|
||||
mmRevokeByAccessToken.RevokeByAccessTokenMock.callArgs = append(mmRevokeByAccessToken.RevokeByAccessTokenMock.callArgs, &mm_params)
|
||||
mmRevokeByAccessToken.RevokeByAccessTokenMock.mutex.Unlock()
|
||||
|
||||
for _, e := range mmRevokeByAccessToken.RevokeByAccessTokenMock.expectations {
|
||||
if minimock.Equal(*e.params, mm_params) {
|
||||
mm_atomic.AddUint64(&e.Counter, 1)
|
||||
return e.results.err
|
||||
}
|
||||
}
|
||||
|
||||
if mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation != nil {
|
||||
mm_atomic.AddUint64(&mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.Counter, 1)
|
||||
mm_want := mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.params
|
||||
mm_want_ptrs := mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.paramPtrs
|
||||
|
||||
mm_got := SessionRepositoryMockRevokeByAccessTokenParams{ctx, accessToken}
|
||||
|
||||
if mm_want_ptrs != nil {
|
||||
|
||||
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
||||
mmRevokeByAccessToken.t.Errorf("SessionRepositoryMock.RevokeByAccessToken got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.accessToken != nil && !minimock.Equal(*mm_want_ptrs.accessToken, mm_got.accessToken) {
|
||||
mmRevokeByAccessToken.t.Errorf("SessionRepositoryMock.RevokeByAccessToken got unexpected parameter accessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.originAccessToken, *mm_want_ptrs.accessToken, mm_got.accessToken, minimock.Diff(*mm_want_ptrs.accessToken, mm_got.accessToken))
|
||||
}
|
||||
|
||||
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
||||
mmRevokeByAccessToken.t.Errorf("SessionRepositoryMock.RevokeByAccessToken got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
||||
}
|
||||
|
||||
mm_results := mmRevokeByAccessToken.RevokeByAccessTokenMock.defaultExpectation.results
|
||||
if mm_results == nil {
|
||||
mmRevokeByAccessToken.t.Fatal("No results are set for the SessionRepositoryMock.RevokeByAccessToken")
|
||||
}
|
||||
return (*mm_results).err
|
||||
}
|
||||
if mmRevokeByAccessToken.funcRevokeByAccessToken != nil {
|
||||
return mmRevokeByAccessToken.funcRevokeByAccessToken(ctx, accessToken)
|
||||
}
|
||||
mmRevokeByAccessToken.t.Fatalf("Unexpected call to SessionRepositoryMock.RevokeByAccessToken. %v %v", ctx, accessToken)
|
||||
return
|
||||
}
|
||||
|
||||
// RevokeByAccessTokenAfterCounter returns a count of finished SessionRepositoryMock.RevokeByAccessToken invocations
|
||||
func (mmRevokeByAccessToken *SessionRepositoryMock) RevokeByAccessTokenAfterCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmRevokeByAccessToken.afterRevokeByAccessTokenCounter)
|
||||
}
|
||||
|
||||
// RevokeByAccessTokenBeforeCounter returns a count of SessionRepositoryMock.RevokeByAccessToken invocations
|
||||
func (mmRevokeByAccessToken *SessionRepositoryMock) RevokeByAccessTokenBeforeCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmRevokeByAccessToken.beforeRevokeByAccessTokenCounter)
|
||||
}
|
||||
|
||||
// Calls returns a list of arguments used in each call to SessionRepositoryMock.RevokeByAccessToken.
|
||||
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
||||
func (mmRevokeByAccessToken *mSessionRepositoryMockRevokeByAccessToken) Calls() []*SessionRepositoryMockRevokeByAccessTokenParams {
|
||||
mmRevokeByAccessToken.mutex.RLock()
|
||||
|
||||
argCopy := make([]*SessionRepositoryMockRevokeByAccessTokenParams, len(mmRevokeByAccessToken.callArgs))
|
||||
copy(argCopy, mmRevokeByAccessToken.callArgs)
|
||||
|
||||
mmRevokeByAccessToken.mutex.RUnlock()
|
||||
|
||||
return argCopy
|
||||
}
|
||||
|
||||
// MinimockRevokeByAccessTokenDone returns true if the count of the RevokeByAccessToken invocations corresponds
|
||||
// the number of defined expectations
|
||||
func (m *SessionRepositoryMock) MinimockRevokeByAccessTokenDone() bool {
|
||||
if m.RevokeByAccessTokenMock.optional {
|
||||
// Optional methods provide '0 or more' call count restriction.
|
||||
return true
|
||||
}
|
||||
|
||||
for _, e := range m.RevokeByAccessTokenMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return m.RevokeByAccessTokenMock.invocationsDone()
|
||||
}
|
||||
|
||||
// MinimockRevokeByAccessTokenInspect logs each unmet expectation
|
||||
func (m *SessionRepositoryMock) MinimockRevokeByAccessTokenInspect() {
|
||||
for _, e := range m.RevokeByAccessTokenMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
||||
}
|
||||
}
|
||||
|
||||
afterRevokeByAccessTokenCounter := mm_atomic.LoadUint64(&m.afterRevokeByAccessTokenCounter)
|
||||
// if default expectation was set then invocations count should be greater than zero
|
||||
if m.RevokeByAccessTokenMock.defaultExpectation != nil && afterRevokeByAccessTokenCounter < 1 {
|
||||
if m.RevokeByAccessTokenMock.defaultExpectation.params == nil {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s", m.RevokeByAccessTokenMock.defaultExpectation.returnOrigin)
|
||||
} else {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s with params: %#v", m.RevokeByAccessTokenMock.defaultExpectation.expectationOrigins.origin, *m.RevokeByAccessTokenMock.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
// if func was set then invocations count should be greater than zero
|
||||
if m.funcRevokeByAccessToken != nil && afterRevokeByAccessTokenCounter < 1 {
|
||||
m.t.Errorf("Expected call to SessionRepositoryMock.RevokeByAccessToken at\n%s", m.funcRevokeByAccessTokenOrigin)
|
||||
}
|
||||
|
||||
if !m.RevokeByAccessTokenMock.invocationsDone() && afterRevokeByAccessTokenCounter > 0 {
|
||||
m.t.Errorf("Expected %d calls to SessionRepositoryMock.RevokeByAccessToken at\n%s but found %d calls",
|
||||
mm_atomic.LoadUint64(&m.RevokeByAccessTokenMock.expectedInvocations), m.RevokeByAccessTokenMock.expectedInvocationsOrigin, afterRevokeByAccessTokenCounter)
|
||||
}
|
||||
}
|
||||
|
||||
type mSessionRepositoryMockUpdateAccessToken struct {
|
||||
optional bool
|
||||
mock *SessionRepositoryMock
|
||||
@@ -1805,8 +2510,12 @@ func (m *SessionRepositoryMock) MinimockFinish() {
|
||||
|
||||
m.MinimockFindByRefreshTokenInspect()
|
||||
|
||||
m.MinimockIsAccessTokenValidInspect()
|
||||
|
||||
m.MinimockRevokeInspect()
|
||||
|
||||
m.MinimockRevokeByAccessTokenInspect()
|
||||
|
||||
m.MinimockUpdateAccessTokenInspect()
|
||||
}
|
||||
})
|
||||
@@ -1834,6 +2543,8 @@ func (m *SessionRepositoryMock) minimockDone() bool {
|
||||
m.MinimockCreateDone() &&
|
||||
m.MinimockDeleteExpiredDone() &&
|
||||
m.MinimockFindByRefreshTokenDone() &&
|
||||
m.MinimockIsAccessTokenValidDone() &&
|
||||
m.MinimockRevokeDone() &&
|
||||
m.MinimockRevokeByAccessTokenDone() &&
|
||||
m.MinimockUpdateAccessTokenDone()
|
||||
}
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/repository.SupplierRepository -o supplier_repository_mock.go -n SupplierRepositoryMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/repository.SupplierRepository -o supplier_repository_mock.go -n SupplierRepositoryMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"smart-search-back/internal/model"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
// SupplierRepositoryMock implements mm_repository.SupplierRepository
|
||||
@@ -27,6 +28,13 @@ type SupplierRepositoryMock struct {
|
||||
beforeBulkInsertCounter uint64
|
||||
BulkInsertMock mSupplierRepositoryMockBulkInsert
|
||||
|
||||
funcBulkInsertTx func(ctx context.Context, tx pgx.Tx, requestID uuid.UUID, suppliers []*model.Supplier) (err error)
|
||||
funcBulkInsertTxOrigin string
|
||||
inspectFuncBulkInsertTx func(ctx context.Context, tx pgx.Tx, requestID uuid.UUID, suppliers []*model.Supplier)
|
||||
afterBulkInsertTxCounter uint64
|
||||
beforeBulkInsertTxCounter uint64
|
||||
BulkInsertTxMock mSupplierRepositoryMockBulkInsertTx
|
||||
|
||||
funcDeleteByRequestID func(ctx context.Context, requestID uuid.UUID) (err error)
|
||||
funcDeleteByRequestIDOrigin string
|
||||
inspectFuncDeleteByRequestID func(ctx context.Context, requestID uuid.UUID)
|
||||
@@ -53,6 +61,9 @@ func NewSupplierRepositoryMock(t minimock.Tester) *SupplierRepositoryMock {
|
||||
m.BulkInsertMock = mSupplierRepositoryMockBulkInsert{mock: m}
|
||||
m.BulkInsertMock.callArgs = []*SupplierRepositoryMockBulkInsertParams{}
|
||||
|
||||
m.BulkInsertTxMock = mSupplierRepositoryMockBulkInsertTx{mock: m}
|
||||
m.BulkInsertTxMock.callArgs = []*SupplierRepositoryMockBulkInsertTxParams{}
|
||||
|
||||
m.DeleteByRequestIDMock = mSupplierRepositoryMockDeleteByRequestID{mock: m}
|
||||
m.DeleteByRequestIDMock.callArgs = []*SupplierRepositoryMockDeleteByRequestIDParams{}
|
||||
|
||||
@@ -437,6 +448,410 @@ func (m *SupplierRepositoryMock) MinimockBulkInsertInspect() {
|
||||
}
|
||||
}
|
||||
|
||||
type mSupplierRepositoryMockBulkInsertTx struct {
|
||||
optional bool
|
||||
mock *SupplierRepositoryMock
|
||||
defaultExpectation *SupplierRepositoryMockBulkInsertTxExpectation
|
||||
expectations []*SupplierRepositoryMockBulkInsertTxExpectation
|
||||
|
||||
callArgs []*SupplierRepositoryMockBulkInsertTxParams
|
||||
mutex sync.RWMutex
|
||||
|
||||
expectedInvocations uint64
|
||||
expectedInvocationsOrigin string
|
||||
}
|
||||
|
||||
// SupplierRepositoryMockBulkInsertTxExpectation specifies expectation struct of the SupplierRepository.BulkInsertTx
|
||||
type SupplierRepositoryMockBulkInsertTxExpectation struct {
|
||||
mock *SupplierRepositoryMock
|
||||
params *SupplierRepositoryMockBulkInsertTxParams
|
||||
paramPtrs *SupplierRepositoryMockBulkInsertTxParamPtrs
|
||||
expectationOrigins SupplierRepositoryMockBulkInsertTxExpectationOrigins
|
||||
results *SupplierRepositoryMockBulkInsertTxResults
|
||||
returnOrigin string
|
||||
Counter uint64
|
||||
}
|
||||
|
||||
// SupplierRepositoryMockBulkInsertTxParams contains parameters of the SupplierRepository.BulkInsertTx
|
||||
type SupplierRepositoryMockBulkInsertTxParams struct {
|
||||
ctx context.Context
|
||||
tx pgx.Tx
|
||||
requestID uuid.UUID
|
||||
suppliers []*model.Supplier
|
||||
}
|
||||
|
||||
// SupplierRepositoryMockBulkInsertTxParamPtrs contains pointers to parameters of the SupplierRepository.BulkInsertTx
|
||||
type SupplierRepositoryMockBulkInsertTxParamPtrs struct {
|
||||
ctx *context.Context
|
||||
tx *pgx.Tx
|
||||
requestID *uuid.UUID
|
||||
suppliers *[]*model.Supplier
|
||||
}
|
||||
|
||||
// SupplierRepositoryMockBulkInsertTxResults contains results of the SupplierRepository.BulkInsertTx
|
||||
type SupplierRepositoryMockBulkInsertTxResults struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// SupplierRepositoryMockBulkInsertTxOrigins contains origins of expectations of the SupplierRepository.BulkInsertTx
|
||||
type SupplierRepositoryMockBulkInsertTxExpectationOrigins struct {
|
||||
origin string
|
||||
originCtx string
|
||||
originTx string
|
||||
originRequestID string
|
||||
originSuppliers 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 (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) Optional() *mSupplierRepositoryMockBulkInsertTx {
|
||||
mmBulkInsertTx.optional = true
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
// Expect sets up expected params for SupplierRepository.BulkInsertTx
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) Expect(ctx context.Context, tx pgx.Tx, requestID uuid.UUID, suppliers []*model.Supplier) *mSupplierRepositoryMockBulkInsertTx {
|
||||
if mmBulkInsertTx.mock.funcBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation == nil {
|
||||
mmBulkInsertTx.defaultExpectation = &SupplierRepositoryMockBulkInsertTxExpectation{}
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.paramPtrs != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by ExpectParams functions")
|
||||
}
|
||||
|
||||
mmBulkInsertTx.defaultExpectation.params = &SupplierRepositoryMockBulkInsertTxParams{ctx, tx, requestID, suppliers}
|
||||
mmBulkInsertTx.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
||||
for _, e := range mmBulkInsertTx.expectations {
|
||||
if minimock.Equal(e.params, mmBulkInsertTx.defaultExpectation.params) {
|
||||
mmBulkInsertTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmBulkInsertTx.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
// ExpectCtxParam1 sets up expected param ctx for SupplierRepository.BulkInsertTx
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) ExpectCtxParam1(ctx context.Context) *mSupplierRepositoryMockBulkInsertTx {
|
||||
if mmBulkInsertTx.mock.funcBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation == nil {
|
||||
mmBulkInsertTx.defaultExpectation = &SupplierRepositoryMockBulkInsertTxExpectation{}
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.params != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.paramPtrs == nil {
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs = &SupplierRepositoryMockBulkInsertTxParamPtrs{}
|
||||
}
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs.ctx = &ctx
|
||||
mmBulkInsertTx.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
||||
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
// ExpectTxParam2 sets up expected param tx for SupplierRepository.BulkInsertTx
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) ExpectTxParam2(tx pgx.Tx) *mSupplierRepositoryMockBulkInsertTx {
|
||||
if mmBulkInsertTx.mock.funcBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation == nil {
|
||||
mmBulkInsertTx.defaultExpectation = &SupplierRepositoryMockBulkInsertTxExpectation{}
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.params != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.paramPtrs == nil {
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs = &SupplierRepositoryMockBulkInsertTxParamPtrs{}
|
||||
}
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs.tx = &tx
|
||||
mmBulkInsertTx.defaultExpectation.expectationOrigins.originTx = minimock.CallerInfo(1)
|
||||
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
// ExpectRequestIDParam3 sets up expected param requestID for SupplierRepository.BulkInsertTx
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) ExpectRequestIDParam3(requestID uuid.UUID) *mSupplierRepositoryMockBulkInsertTx {
|
||||
if mmBulkInsertTx.mock.funcBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation == nil {
|
||||
mmBulkInsertTx.defaultExpectation = &SupplierRepositoryMockBulkInsertTxExpectation{}
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.params != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.paramPtrs == nil {
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs = &SupplierRepositoryMockBulkInsertTxParamPtrs{}
|
||||
}
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs.requestID = &requestID
|
||||
mmBulkInsertTx.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1)
|
||||
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
// ExpectSuppliersParam4 sets up expected param suppliers for SupplierRepository.BulkInsertTx
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) ExpectSuppliersParam4(suppliers []*model.Supplier) *mSupplierRepositoryMockBulkInsertTx {
|
||||
if mmBulkInsertTx.mock.funcBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation == nil {
|
||||
mmBulkInsertTx.defaultExpectation = &SupplierRepositoryMockBulkInsertTxExpectation{}
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.params != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation.paramPtrs == nil {
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs = &SupplierRepositoryMockBulkInsertTxParamPtrs{}
|
||||
}
|
||||
mmBulkInsertTx.defaultExpectation.paramPtrs.suppliers = &suppliers
|
||||
mmBulkInsertTx.defaultExpectation.expectationOrigins.originSuppliers = minimock.CallerInfo(1)
|
||||
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
// Inspect accepts an inspector function that has same arguments as the SupplierRepository.BulkInsertTx
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) Inspect(f func(ctx context.Context, tx pgx.Tx, requestID uuid.UUID, suppliers []*model.Supplier)) *mSupplierRepositoryMockBulkInsertTx {
|
||||
if mmBulkInsertTx.mock.inspectFuncBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("Inspect function is already set for SupplierRepositoryMock.BulkInsertTx")
|
||||
}
|
||||
|
||||
mmBulkInsertTx.mock.inspectFuncBulkInsertTx = f
|
||||
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
// Return sets up results that will be returned by SupplierRepository.BulkInsertTx
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) Return(err error) *SupplierRepositoryMock {
|
||||
if mmBulkInsertTx.mock.funcBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.defaultExpectation == nil {
|
||||
mmBulkInsertTx.defaultExpectation = &SupplierRepositoryMockBulkInsertTxExpectation{mock: mmBulkInsertTx.mock}
|
||||
}
|
||||
mmBulkInsertTx.defaultExpectation.results = &SupplierRepositoryMockBulkInsertTxResults{err}
|
||||
mmBulkInsertTx.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
||||
return mmBulkInsertTx.mock
|
||||
}
|
||||
|
||||
// Set uses given function f to mock the SupplierRepository.BulkInsertTx method
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) Set(f func(ctx context.Context, tx pgx.Tx, requestID uuid.UUID, suppliers []*model.Supplier) (err error)) *SupplierRepositoryMock {
|
||||
if mmBulkInsertTx.defaultExpectation != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("Default expectation is already set for the SupplierRepository.BulkInsertTx method")
|
||||
}
|
||||
|
||||
if len(mmBulkInsertTx.expectations) > 0 {
|
||||
mmBulkInsertTx.mock.t.Fatalf("Some expectations are already set for the SupplierRepository.BulkInsertTx method")
|
||||
}
|
||||
|
||||
mmBulkInsertTx.mock.funcBulkInsertTx = f
|
||||
mmBulkInsertTx.mock.funcBulkInsertTxOrigin = minimock.CallerInfo(1)
|
||||
return mmBulkInsertTx.mock
|
||||
}
|
||||
|
||||
// When sets expectation for the SupplierRepository.BulkInsertTx which will trigger the result defined by the following
|
||||
// Then helper
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) When(ctx context.Context, tx pgx.Tx, requestID uuid.UUID, suppliers []*model.Supplier) *SupplierRepositoryMockBulkInsertTxExpectation {
|
||||
if mmBulkInsertTx.mock.funcBulkInsertTx != nil {
|
||||
mmBulkInsertTx.mock.t.Fatalf("SupplierRepositoryMock.BulkInsertTx mock is already set by Set")
|
||||
}
|
||||
|
||||
expectation := &SupplierRepositoryMockBulkInsertTxExpectation{
|
||||
mock: mmBulkInsertTx.mock,
|
||||
params: &SupplierRepositoryMockBulkInsertTxParams{ctx, tx, requestID, suppliers},
|
||||
expectationOrigins: SupplierRepositoryMockBulkInsertTxExpectationOrigins{origin: minimock.CallerInfo(1)},
|
||||
}
|
||||
mmBulkInsertTx.expectations = append(mmBulkInsertTx.expectations, expectation)
|
||||
return expectation
|
||||
}
|
||||
|
||||
// Then sets up SupplierRepository.BulkInsertTx return parameters for the expectation previously defined by the When method
|
||||
func (e *SupplierRepositoryMockBulkInsertTxExpectation) Then(err error) *SupplierRepositoryMock {
|
||||
e.results = &SupplierRepositoryMockBulkInsertTxResults{err}
|
||||
return e.mock
|
||||
}
|
||||
|
||||
// Times sets number of times SupplierRepository.BulkInsertTx should be invoked
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) Times(n uint64) *mSupplierRepositoryMockBulkInsertTx {
|
||||
if n == 0 {
|
||||
mmBulkInsertTx.mock.t.Fatalf("Times of SupplierRepositoryMock.BulkInsertTx mock can not be zero")
|
||||
}
|
||||
mm_atomic.StoreUint64(&mmBulkInsertTx.expectedInvocations, n)
|
||||
mmBulkInsertTx.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
||||
return mmBulkInsertTx
|
||||
}
|
||||
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) invocationsDone() bool {
|
||||
if len(mmBulkInsertTx.expectations) == 0 && mmBulkInsertTx.defaultExpectation == nil && mmBulkInsertTx.mock.funcBulkInsertTx == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
totalInvocations := mm_atomic.LoadUint64(&mmBulkInsertTx.mock.afterBulkInsertTxCounter)
|
||||
expectedInvocations := mm_atomic.LoadUint64(&mmBulkInsertTx.expectedInvocations)
|
||||
|
||||
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
||||
}
|
||||
|
||||
// BulkInsertTx implements mm_repository.SupplierRepository
|
||||
func (mmBulkInsertTx *SupplierRepositoryMock) BulkInsertTx(ctx context.Context, tx pgx.Tx, requestID uuid.UUID, suppliers []*model.Supplier) (err error) {
|
||||
mm_atomic.AddUint64(&mmBulkInsertTx.beforeBulkInsertTxCounter, 1)
|
||||
defer mm_atomic.AddUint64(&mmBulkInsertTx.afterBulkInsertTxCounter, 1)
|
||||
|
||||
mmBulkInsertTx.t.Helper()
|
||||
|
||||
if mmBulkInsertTx.inspectFuncBulkInsertTx != nil {
|
||||
mmBulkInsertTx.inspectFuncBulkInsertTx(ctx, tx, requestID, suppliers)
|
||||
}
|
||||
|
||||
mm_params := SupplierRepositoryMockBulkInsertTxParams{ctx, tx, requestID, suppliers}
|
||||
|
||||
// Record call args
|
||||
mmBulkInsertTx.BulkInsertTxMock.mutex.Lock()
|
||||
mmBulkInsertTx.BulkInsertTxMock.callArgs = append(mmBulkInsertTx.BulkInsertTxMock.callArgs, &mm_params)
|
||||
mmBulkInsertTx.BulkInsertTxMock.mutex.Unlock()
|
||||
|
||||
for _, e := range mmBulkInsertTx.BulkInsertTxMock.expectations {
|
||||
if minimock.Equal(*e.params, mm_params) {
|
||||
mm_atomic.AddUint64(&e.Counter, 1)
|
||||
return e.results.err
|
||||
}
|
||||
}
|
||||
|
||||
if mmBulkInsertTx.BulkInsertTxMock.defaultExpectation != nil {
|
||||
mm_atomic.AddUint64(&mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.Counter, 1)
|
||||
mm_want := mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.params
|
||||
mm_want_ptrs := mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.paramPtrs
|
||||
|
||||
mm_got := SupplierRepositoryMockBulkInsertTxParams{ctx, tx, requestID, suppliers}
|
||||
|
||||
if mm_want_ptrs != nil {
|
||||
|
||||
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
||||
mmBulkInsertTx.t.Errorf("SupplierRepositoryMock.BulkInsertTx got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
|
||||
mmBulkInsertTx.t.Errorf("SupplierRepositoryMock.BulkInsertTx got unexpected parameter tx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.expectationOrigins.originTx, *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) {
|
||||
mmBulkInsertTx.t.Errorf("SupplierRepositoryMock.BulkInsertTx got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.suppliers != nil && !minimock.Equal(*mm_want_ptrs.suppliers, mm_got.suppliers) {
|
||||
mmBulkInsertTx.t.Errorf("SupplierRepositoryMock.BulkInsertTx got unexpected parameter suppliers, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.expectationOrigins.originSuppliers, *mm_want_ptrs.suppliers, mm_got.suppliers, minimock.Diff(*mm_want_ptrs.suppliers, mm_got.suppliers))
|
||||
}
|
||||
|
||||
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
||||
mmBulkInsertTx.t.Errorf("SupplierRepositoryMock.BulkInsertTx got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
||||
}
|
||||
|
||||
mm_results := mmBulkInsertTx.BulkInsertTxMock.defaultExpectation.results
|
||||
if mm_results == nil {
|
||||
mmBulkInsertTx.t.Fatal("No results are set for the SupplierRepositoryMock.BulkInsertTx")
|
||||
}
|
||||
return (*mm_results).err
|
||||
}
|
||||
if mmBulkInsertTx.funcBulkInsertTx != nil {
|
||||
return mmBulkInsertTx.funcBulkInsertTx(ctx, tx, requestID, suppliers)
|
||||
}
|
||||
mmBulkInsertTx.t.Fatalf("Unexpected call to SupplierRepositoryMock.BulkInsertTx. %v %v %v %v", ctx, tx, requestID, suppliers)
|
||||
return
|
||||
}
|
||||
|
||||
// BulkInsertTxAfterCounter returns a count of finished SupplierRepositoryMock.BulkInsertTx invocations
|
||||
func (mmBulkInsertTx *SupplierRepositoryMock) BulkInsertTxAfterCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmBulkInsertTx.afterBulkInsertTxCounter)
|
||||
}
|
||||
|
||||
// BulkInsertTxBeforeCounter returns a count of SupplierRepositoryMock.BulkInsertTx invocations
|
||||
func (mmBulkInsertTx *SupplierRepositoryMock) BulkInsertTxBeforeCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmBulkInsertTx.beforeBulkInsertTxCounter)
|
||||
}
|
||||
|
||||
// Calls returns a list of arguments used in each call to SupplierRepositoryMock.BulkInsertTx.
|
||||
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
||||
func (mmBulkInsertTx *mSupplierRepositoryMockBulkInsertTx) Calls() []*SupplierRepositoryMockBulkInsertTxParams {
|
||||
mmBulkInsertTx.mutex.RLock()
|
||||
|
||||
argCopy := make([]*SupplierRepositoryMockBulkInsertTxParams, len(mmBulkInsertTx.callArgs))
|
||||
copy(argCopy, mmBulkInsertTx.callArgs)
|
||||
|
||||
mmBulkInsertTx.mutex.RUnlock()
|
||||
|
||||
return argCopy
|
||||
}
|
||||
|
||||
// MinimockBulkInsertTxDone returns true if the count of the BulkInsertTx invocations corresponds
|
||||
// the number of defined expectations
|
||||
func (m *SupplierRepositoryMock) MinimockBulkInsertTxDone() bool {
|
||||
if m.BulkInsertTxMock.optional {
|
||||
// Optional methods provide '0 or more' call count restriction.
|
||||
return true
|
||||
}
|
||||
|
||||
for _, e := range m.BulkInsertTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return m.BulkInsertTxMock.invocationsDone()
|
||||
}
|
||||
|
||||
// MinimockBulkInsertTxInspect logs each unmet expectation
|
||||
func (m *SupplierRepositoryMock) MinimockBulkInsertTxInspect() {
|
||||
for _, e := range m.BulkInsertTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsertTx at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
||||
}
|
||||
}
|
||||
|
||||
afterBulkInsertTxCounter := mm_atomic.LoadUint64(&m.afterBulkInsertTxCounter)
|
||||
// if default expectation was set then invocations count should be greater than zero
|
||||
if m.BulkInsertTxMock.defaultExpectation != nil && afterBulkInsertTxCounter < 1 {
|
||||
if m.BulkInsertTxMock.defaultExpectation.params == nil {
|
||||
m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsertTx at\n%s", m.BulkInsertTxMock.defaultExpectation.returnOrigin)
|
||||
} else {
|
||||
m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsertTx at\n%s with params: %#v", m.BulkInsertTxMock.defaultExpectation.expectationOrigins.origin, *m.BulkInsertTxMock.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
// if func was set then invocations count should be greater than zero
|
||||
if m.funcBulkInsertTx != nil && afterBulkInsertTxCounter < 1 {
|
||||
m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsertTx at\n%s", m.funcBulkInsertTxOrigin)
|
||||
}
|
||||
|
||||
if !m.BulkInsertTxMock.invocationsDone() && afterBulkInsertTxCounter > 0 {
|
||||
m.t.Errorf("Expected %d calls to SupplierRepositoryMock.BulkInsertTx at\n%s but found %d calls",
|
||||
mm_atomic.LoadUint64(&m.BulkInsertTxMock.expectedInvocations), m.BulkInsertTxMock.expectedInvocationsOrigin, afterBulkInsertTxCounter)
|
||||
}
|
||||
}
|
||||
|
||||
type mSupplierRepositoryMockDeleteByRequestID struct {
|
||||
optional bool
|
||||
mock *SupplierRepositoryMock
|
||||
@@ -1128,6 +1543,8 @@ func (m *SupplierRepositoryMock) MinimockFinish() {
|
||||
if !m.minimockDone() {
|
||||
m.MinimockBulkInsertInspect()
|
||||
|
||||
m.MinimockBulkInsertTxInspect()
|
||||
|
||||
m.MinimockDeleteByRequestIDInspect()
|
||||
|
||||
m.MinimockGetByRequestIDInspect()
|
||||
@@ -1155,6 +1572,7 @@ func (m *SupplierRepositoryMock) minimockDone() bool {
|
||||
done := true
|
||||
return done &&
|
||||
m.MinimockBulkInsertDone() &&
|
||||
m.MinimockBulkInsertTxDone() &&
|
||||
m.MinimockDeleteByRequestIDDone() &&
|
||||
m.MinimockGetByRequestIDDone()
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/service.SupplierService -o supplier_service_mock.go -n SupplierServiceMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/service.SupplierService -o supplier_service_mock.go -n SupplierServiceMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/repository.TokenUsageRepository -o token_usage_repository_mock.go -n TokenUsageRepositoryMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/repository.TokenUsageRepository -o token_usage_repository_mock.go -n TokenUsageRepositoryMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"smart-search-back/internal/model"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
// TokenUsageRepositoryMock implements mm_repository.TokenUsageRepository
|
||||
@@ -25,6 +26,13 @@ type TokenUsageRepositoryMock struct {
|
||||
afterCreateCounter uint64
|
||||
beforeCreateCounter uint64
|
||||
CreateMock mTokenUsageRepositoryMockCreate
|
||||
|
||||
funcCreateTx func(ctx context.Context, tx pgx.Tx, usage *model.TokenUsage) (err error)
|
||||
funcCreateTxOrigin string
|
||||
inspectFuncCreateTx func(ctx context.Context, tx pgx.Tx, usage *model.TokenUsage)
|
||||
afterCreateTxCounter uint64
|
||||
beforeCreateTxCounter uint64
|
||||
CreateTxMock mTokenUsageRepositoryMockCreateTx
|
||||
}
|
||||
|
||||
// NewTokenUsageRepositoryMock returns a mock for mm_repository.TokenUsageRepository
|
||||
@@ -38,6 +46,9 @@ func NewTokenUsageRepositoryMock(t minimock.Tester) *TokenUsageRepositoryMock {
|
||||
m.CreateMock = mTokenUsageRepositoryMockCreate{mock: m}
|
||||
m.CreateMock.callArgs = []*TokenUsageRepositoryMockCreateParams{}
|
||||
|
||||
m.CreateTxMock = mTokenUsageRepositoryMockCreateTx{mock: m}
|
||||
m.CreateTxMock.callArgs = []*TokenUsageRepositoryMockCreateTxParams{}
|
||||
|
||||
t.Cleanup(m.MinimockFinish)
|
||||
|
||||
return m
|
||||
@@ -385,11 +396,386 @@ func (m *TokenUsageRepositoryMock) MinimockCreateInspect() {
|
||||
}
|
||||
}
|
||||
|
||||
type mTokenUsageRepositoryMockCreateTx struct {
|
||||
optional bool
|
||||
mock *TokenUsageRepositoryMock
|
||||
defaultExpectation *TokenUsageRepositoryMockCreateTxExpectation
|
||||
expectations []*TokenUsageRepositoryMockCreateTxExpectation
|
||||
|
||||
callArgs []*TokenUsageRepositoryMockCreateTxParams
|
||||
mutex sync.RWMutex
|
||||
|
||||
expectedInvocations uint64
|
||||
expectedInvocationsOrigin string
|
||||
}
|
||||
|
||||
// TokenUsageRepositoryMockCreateTxExpectation specifies expectation struct of the TokenUsageRepository.CreateTx
|
||||
type TokenUsageRepositoryMockCreateTxExpectation struct {
|
||||
mock *TokenUsageRepositoryMock
|
||||
params *TokenUsageRepositoryMockCreateTxParams
|
||||
paramPtrs *TokenUsageRepositoryMockCreateTxParamPtrs
|
||||
expectationOrigins TokenUsageRepositoryMockCreateTxExpectationOrigins
|
||||
results *TokenUsageRepositoryMockCreateTxResults
|
||||
returnOrigin string
|
||||
Counter uint64
|
||||
}
|
||||
|
||||
// TokenUsageRepositoryMockCreateTxParams contains parameters of the TokenUsageRepository.CreateTx
|
||||
type TokenUsageRepositoryMockCreateTxParams struct {
|
||||
ctx context.Context
|
||||
tx pgx.Tx
|
||||
usage *model.TokenUsage
|
||||
}
|
||||
|
||||
// TokenUsageRepositoryMockCreateTxParamPtrs contains pointers to parameters of the TokenUsageRepository.CreateTx
|
||||
type TokenUsageRepositoryMockCreateTxParamPtrs struct {
|
||||
ctx *context.Context
|
||||
tx *pgx.Tx
|
||||
usage **model.TokenUsage
|
||||
}
|
||||
|
||||
// TokenUsageRepositoryMockCreateTxResults contains results of the TokenUsageRepository.CreateTx
|
||||
type TokenUsageRepositoryMockCreateTxResults struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// TokenUsageRepositoryMockCreateTxOrigins contains origins of expectations of the TokenUsageRepository.CreateTx
|
||||
type TokenUsageRepositoryMockCreateTxExpectationOrigins struct {
|
||||
origin string
|
||||
originCtx string
|
||||
originTx string
|
||||
originUsage 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 (mmCreateTx *mTokenUsageRepositoryMockCreateTx) Optional() *mTokenUsageRepositoryMockCreateTx {
|
||||
mmCreateTx.optional = true
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// Expect sets up expected params for TokenUsageRepository.CreateTx
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) Expect(ctx context.Context, tx pgx.Tx, usage *model.TokenUsage) *mTokenUsageRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &TokenUsageRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by ExpectParams functions")
|
||||
}
|
||||
|
||||
mmCreateTx.defaultExpectation.params = &TokenUsageRepositoryMockCreateTxParams{ctx, tx, usage}
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
||||
for _, e := range mmCreateTx.expectations {
|
||||
if minimock.Equal(e.params, mmCreateTx.defaultExpectation.params) {
|
||||
mmCreateTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateTx.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// ExpectCtxParam1 sets up expected param ctx for TokenUsageRepository.CreateTx
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) ExpectCtxParam1(ctx context.Context) *mTokenUsageRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &TokenUsageRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.params != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs == nil {
|
||||
mmCreateTx.defaultExpectation.paramPtrs = &TokenUsageRepositoryMockCreateTxParamPtrs{}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.paramPtrs.ctx = &ctx
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// ExpectTxParam2 sets up expected param tx for TokenUsageRepository.CreateTx
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) ExpectTxParam2(tx pgx.Tx) *mTokenUsageRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &TokenUsageRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.params != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs == nil {
|
||||
mmCreateTx.defaultExpectation.paramPtrs = &TokenUsageRepositoryMockCreateTxParamPtrs{}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.paramPtrs.tx = &tx
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.originTx = minimock.CallerInfo(1)
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// ExpectUsageParam3 sets up expected param usage for TokenUsageRepository.CreateTx
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) ExpectUsageParam3(usage *model.TokenUsage) *mTokenUsageRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &TokenUsageRepositoryMockCreateTxExpectation{}
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.params != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Expect")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation.paramPtrs == nil {
|
||||
mmCreateTx.defaultExpectation.paramPtrs = &TokenUsageRepositoryMockCreateTxParamPtrs{}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.paramPtrs.usage = &usage
|
||||
mmCreateTx.defaultExpectation.expectationOrigins.originUsage = minimock.CallerInfo(1)
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// Inspect accepts an inspector function that has same arguments as the TokenUsageRepository.CreateTx
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) Inspect(f func(ctx context.Context, tx pgx.Tx, usage *model.TokenUsage)) *mTokenUsageRepositoryMockCreateTx {
|
||||
if mmCreateTx.mock.inspectFuncCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("Inspect function is already set for TokenUsageRepositoryMock.CreateTx")
|
||||
}
|
||||
|
||||
mmCreateTx.mock.inspectFuncCreateTx = f
|
||||
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
// Return sets up results that will be returned by TokenUsageRepository.CreateTx
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) Return(err error) *TokenUsageRepositoryMock {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
if mmCreateTx.defaultExpectation == nil {
|
||||
mmCreateTx.defaultExpectation = &TokenUsageRepositoryMockCreateTxExpectation{mock: mmCreateTx.mock}
|
||||
}
|
||||
mmCreateTx.defaultExpectation.results = &TokenUsageRepositoryMockCreateTxResults{err}
|
||||
mmCreateTx.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
||||
return mmCreateTx.mock
|
||||
}
|
||||
|
||||
// Set uses given function f to mock the TokenUsageRepository.CreateTx method
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) Set(f func(ctx context.Context, tx pgx.Tx, usage *model.TokenUsage) (err error)) *TokenUsageRepositoryMock {
|
||||
if mmCreateTx.defaultExpectation != nil {
|
||||
mmCreateTx.mock.t.Fatalf("Default expectation is already set for the TokenUsageRepository.CreateTx method")
|
||||
}
|
||||
|
||||
if len(mmCreateTx.expectations) > 0 {
|
||||
mmCreateTx.mock.t.Fatalf("Some expectations are already set for the TokenUsageRepository.CreateTx method")
|
||||
}
|
||||
|
||||
mmCreateTx.mock.funcCreateTx = f
|
||||
mmCreateTx.mock.funcCreateTxOrigin = minimock.CallerInfo(1)
|
||||
return mmCreateTx.mock
|
||||
}
|
||||
|
||||
// When sets expectation for the TokenUsageRepository.CreateTx which will trigger the result defined by the following
|
||||
// Then helper
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) When(ctx context.Context, tx pgx.Tx, usage *model.TokenUsage) *TokenUsageRepositoryMockCreateTxExpectation {
|
||||
if mmCreateTx.mock.funcCreateTx != nil {
|
||||
mmCreateTx.mock.t.Fatalf("TokenUsageRepositoryMock.CreateTx mock is already set by Set")
|
||||
}
|
||||
|
||||
expectation := &TokenUsageRepositoryMockCreateTxExpectation{
|
||||
mock: mmCreateTx.mock,
|
||||
params: &TokenUsageRepositoryMockCreateTxParams{ctx, tx, usage},
|
||||
expectationOrigins: TokenUsageRepositoryMockCreateTxExpectationOrigins{origin: minimock.CallerInfo(1)},
|
||||
}
|
||||
mmCreateTx.expectations = append(mmCreateTx.expectations, expectation)
|
||||
return expectation
|
||||
}
|
||||
|
||||
// Then sets up TokenUsageRepository.CreateTx return parameters for the expectation previously defined by the When method
|
||||
func (e *TokenUsageRepositoryMockCreateTxExpectation) Then(err error) *TokenUsageRepositoryMock {
|
||||
e.results = &TokenUsageRepositoryMockCreateTxResults{err}
|
||||
return e.mock
|
||||
}
|
||||
|
||||
// Times sets number of times TokenUsageRepository.CreateTx should be invoked
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) Times(n uint64) *mTokenUsageRepositoryMockCreateTx {
|
||||
if n == 0 {
|
||||
mmCreateTx.mock.t.Fatalf("Times of TokenUsageRepositoryMock.CreateTx mock can not be zero")
|
||||
}
|
||||
mm_atomic.StoreUint64(&mmCreateTx.expectedInvocations, n)
|
||||
mmCreateTx.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
||||
return mmCreateTx
|
||||
}
|
||||
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) invocationsDone() bool {
|
||||
if len(mmCreateTx.expectations) == 0 && mmCreateTx.defaultExpectation == nil && mmCreateTx.mock.funcCreateTx == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
totalInvocations := mm_atomic.LoadUint64(&mmCreateTx.mock.afterCreateTxCounter)
|
||||
expectedInvocations := mm_atomic.LoadUint64(&mmCreateTx.expectedInvocations)
|
||||
|
||||
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
||||
}
|
||||
|
||||
// CreateTx implements mm_repository.TokenUsageRepository
|
||||
func (mmCreateTx *TokenUsageRepositoryMock) CreateTx(ctx context.Context, tx pgx.Tx, usage *model.TokenUsage) (err error) {
|
||||
mm_atomic.AddUint64(&mmCreateTx.beforeCreateTxCounter, 1)
|
||||
defer mm_atomic.AddUint64(&mmCreateTx.afterCreateTxCounter, 1)
|
||||
|
||||
mmCreateTx.t.Helper()
|
||||
|
||||
if mmCreateTx.inspectFuncCreateTx != nil {
|
||||
mmCreateTx.inspectFuncCreateTx(ctx, tx, usage)
|
||||
}
|
||||
|
||||
mm_params := TokenUsageRepositoryMockCreateTxParams{ctx, tx, usage}
|
||||
|
||||
// Record call args
|
||||
mmCreateTx.CreateTxMock.mutex.Lock()
|
||||
mmCreateTx.CreateTxMock.callArgs = append(mmCreateTx.CreateTxMock.callArgs, &mm_params)
|
||||
mmCreateTx.CreateTxMock.mutex.Unlock()
|
||||
|
||||
for _, e := range mmCreateTx.CreateTxMock.expectations {
|
||||
if minimock.Equal(*e.params, mm_params) {
|
||||
mm_atomic.AddUint64(&e.Counter, 1)
|
||||
return e.results.err
|
||||
}
|
||||
}
|
||||
|
||||
if mmCreateTx.CreateTxMock.defaultExpectation != nil {
|
||||
mm_atomic.AddUint64(&mmCreateTx.CreateTxMock.defaultExpectation.Counter, 1)
|
||||
mm_want := mmCreateTx.CreateTxMock.defaultExpectation.params
|
||||
mm_want_ptrs := mmCreateTx.CreateTxMock.defaultExpectation.paramPtrs
|
||||
|
||||
mm_got := TokenUsageRepositoryMockCreateTxParams{ctx, tx, usage}
|
||||
|
||||
if mm_want_ptrs != nil {
|
||||
|
||||
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
||||
mmCreateTx.t.Errorf("TokenUsageRepositoryMock.CreateTx got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.tx != nil && !minimock.Equal(*mm_want_ptrs.tx, mm_got.tx) {
|
||||
mmCreateTx.t.Errorf("TokenUsageRepositoryMock.CreateTx got unexpected parameter tx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.originTx, *mm_want_ptrs.tx, mm_got.tx, minimock.Diff(*mm_want_ptrs.tx, mm_got.tx))
|
||||
}
|
||||
|
||||
if mm_want_ptrs.usage != nil && !minimock.Equal(*mm_want_ptrs.usage, mm_got.usage) {
|
||||
mmCreateTx.t.Errorf("TokenUsageRepositoryMock.CreateTx got unexpected parameter usage, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.originUsage, *mm_want_ptrs.usage, mm_got.usage, minimock.Diff(*mm_want_ptrs.usage, mm_got.usage))
|
||||
}
|
||||
|
||||
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
||||
mmCreateTx.t.Errorf("TokenUsageRepositoryMock.CreateTx got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
||||
mmCreateTx.CreateTxMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
||||
}
|
||||
|
||||
mm_results := mmCreateTx.CreateTxMock.defaultExpectation.results
|
||||
if mm_results == nil {
|
||||
mmCreateTx.t.Fatal("No results are set for the TokenUsageRepositoryMock.CreateTx")
|
||||
}
|
||||
return (*mm_results).err
|
||||
}
|
||||
if mmCreateTx.funcCreateTx != nil {
|
||||
return mmCreateTx.funcCreateTx(ctx, tx, usage)
|
||||
}
|
||||
mmCreateTx.t.Fatalf("Unexpected call to TokenUsageRepositoryMock.CreateTx. %v %v %v", ctx, tx, usage)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateTxAfterCounter returns a count of finished TokenUsageRepositoryMock.CreateTx invocations
|
||||
func (mmCreateTx *TokenUsageRepositoryMock) CreateTxAfterCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmCreateTx.afterCreateTxCounter)
|
||||
}
|
||||
|
||||
// CreateTxBeforeCounter returns a count of TokenUsageRepositoryMock.CreateTx invocations
|
||||
func (mmCreateTx *TokenUsageRepositoryMock) CreateTxBeforeCounter() uint64 {
|
||||
return mm_atomic.LoadUint64(&mmCreateTx.beforeCreateTxCounter)
|
||||
}
|
||||
|
||||
// Calls returns a list of arguments used in each call to TokenUsageRepositoryMock.CreateTx.
|
||||
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
||||
func (mmCreateTx *mTokenUsageRepositoryMockCreateTx) Calls() []*TokenUsageRepositoryMockCreateTxParams {
|
||||
mmCreateTx.mutex.RLock()
|
||||
|
||||
argCopy := make([]*TokenUsageRepositoryMockCreateTxParams, len(mmCreateTx.callArgs))
|
||||
copy(argCopy, mmCreateTx.callArgs)
|
||||
|
||||
mmCreateTx.mutex.RUnlock()
|
||||
|
||||
return argCopy
|
||||
}
|
||||
|
||||
// MinimockCreateTxDone returns true if the count of the CreateTx invocations corresponds
|
||||
// the number of defined expectations
|
||||
func (m *TokenUsageRepositoryMock) MinimockCreateTxDone() bool {
|
||||
if m.CreateTxMock.optional {
|
||||
// Optional methods provide '0 or more' call count restriction.
|
||||
return true
|
||||
}
|
||||
|
||||
for _, e := range m.CreateTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return m.CreateTxMock.invocationsDone()
|
||||
}
|
||||
|
||||
// MinimockCreateTxInspect logs each unmet expectation
|
||||
func (m *TokenUsageRepositoryMock) MinimockCreateTxInspect() {
|
||||
for _, e := range m.CreateTxMock.expectations {
|
||||
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
||||
m.t.Errorf("Expected call to TokenUsageRepositoryMock.CreateTx at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
||||
}
|
||||
}
|
||||
|
||||
afterCreateTxCounter := mm_atomic.LoadUint64(&m.afterCreateTxCounter)
|
||||
// if default expectation was set then invocations count should be greater than zero
|
||||
if m.CreateTxMock.defaultExpectation != nil && afterCreateTxCounter < 1 {
|
||||
if m.CreateTxMock.defaultExpectation.params == nil {
|
||||
m.t.Errorf("Expected call to TokenUsageRepositoryMock.CreateTx at\n%s", m.CreateTxMock.defaultExpectation.returnOrigin)
|
||||
} else {
|
||||
m.t.Errorf("Expected call to TokenUsageRepositoryMock.CreateTx at\n%s with params: %#v", m.CreateTxMock.defaultExpectation.expectationOrigins.origin, *m.CreateTxMock.defaultExpectation.params)
|
||||
}
|
||||
}
|
||||
// if func was set then invocations count should be greater than zero
|
||||
if m.funcCreateTx != nil && afterCreateTxCounter < 1 {
|
||||
m.t.Errorf("Expected call to TokenUsageRepositoryMock.CreateTx at\n%s", m.funcCreateTxOrigin)
|
||||
}
|
||||
|
||||
if !m.CreateTxMock.invocationsDone() && afterCreateTxCounter > 0 {
|
||||
m.t.Errorf("Expected %d calls to TokenUsageRepositoryMock.CreateTx at\n%s but found %d calls",
|
||||
mm_atomic.LoadUint64(&m.CreateTxMock.expectedInvocations), m.CreateTxMock.expectedInvocationsOrigin, afterCreateTxCounter)
|
||||
}
|
||||
}
|
||||
|
||||
// MinimockFinish checks that all mocked methods have been called the expected number of times
|
||||
func (m *TokenUsageRepositoryMock) MinimockFinish() {
|
||||
m.finishOnce.Do(func() {
|
||||
if !m.minimockDone() {
|
||||
m.MinimockCreateInspect()
|
||||
|
||||
m.MinimockCreateTxInspect()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -413,5 +799,6 @@ func (m *TokenUsageRepositoryMock) MinimockWait(timeout mm_time.Duration) {
|
||||
func (m *TokenUsageRepositoryMock) minimockDone() bool {
|
||||
done := true
|
||||
return done &&
|
||||
m.MinimockCreateDone()
|
||||
m.MinimockCreateDone() &&
|
||||
m.MinimockCreateTxDone()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,15 +2,15 @@
|
||||
|
||||
package mocks
|
||||
|
||||
//go:generate minimock -i smart-search-back/internal/service.UserService -o user_service_mock.go -n UserServiceMock -p mocks
|
||||
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/service.UserService -o user_service_mock.go -n UserServiceMock -p mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
mm_service "smart-search-back/internal/service"
|
||||
"sync"
|
||||
mm_atomic "sync/atomic"
|
||||
mm_time "time"
|
||||
|
||||
mm_service "git.techease.ru/Smart-search/smart-search-back/internal/service"
|
||||
"github.com/gojuno/minimock/v3"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user