837 lines
33 KiB
Go
837 lines
33 KiB
Go
// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT.
|
|
|
|
package mocks
|
|
|
|
//go:generate minimock -i git.techease.ru/Smart-search/smart-search-back/internal/service.InviteService -o invite_service_mock.go -n InviteServiceMock -p mocks
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
mm_atomic "sync/atomic"
|
|
mm_time "time"
|
|
|
|
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
|
"github.com/gojuno/minimock/v3"
|
|
)
|
|
|
|
// InviteServiceMock implements mm_service.InviteService
|
|
type InviteServiceMock struct {
|
|
t minimock.Tester
|
|
finishOnce sync.Once
|
|
|
|
funcGenerate func(ctx context.Context, userID int, maxUses int, ttlDays int) (ip1 *model.InviteCode, err error)
|
|
funcGenerateOrigin string
|
|
inspectFuncGenerate func(ctx context.Context, userID int, maxUses int, ttlDays int)
|
|
afterGenerateCounter uint64
|
|
beforeGenerateCounter uint64
|
|
GenerateMock mInviteServiceMockGenerate
|
|
|
|
funcGetInfo func(ctx context.Context, userID int) (ip1 *model.InviteCode, err error)
|
|
funcGetInfoOrigin string
|
|
inspectFuncGetInfo func(ctx context.Context, userID int)
|
|
afterGetInfoCounter uint64
|
|
beforeGetInfoCounter uint64
|
|
GetInfoMock mInviteServiceMockGetInfo
|
|
}
|
|
|
|
// NewInviteServiceMock returns a mock for mm_service.InviteService
|
|
func NewInviteServiceMock(t minimock.Tester) *InviteServiceMock {
|
|
m := &InviteServiceMock{t: t}
|
|
|
|
if controller, ok := t.(minimock.MockController); ok {
|
|
controller.RegisterMocker(m)
|
|
}
|
|
|
|
m.GenerateMock = mInviteServiceMockGenerate{mock: m}
|
|
m.GenerateMock.callArgs = []*InviteServiceMockGenerateParams{}
|
|
|
|
m.GetInfoMock = mInviteServiceMockGetInfo{mock: m}
|
|
m.GetInfoMock.callArgs = []*InviteServiceMockGetInfoParams{}
|
|
|
|
t.Cleanup(m.MinimockFinish)
|
|
|
|
return m
|
|
}
|
|
|
|
type mInviteServiceMockGenerate struct {
|
|
optional bool
|
|
mock *InviteServiceMock
|
|
defaultExpectation *InviteServiceMockGenerateExpectation
|
|
expectations []*InviteServiceMockGenerateExpectation
|
|
|
|
callArgs []*InviteServiceMockGenerateParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// InviteServiceMockGenerateExpectation specifies expectation struct of the InviteService.Generate
|
|
type InviteServiceMockGenerateExpectation struct {
|
|
mock *InviteServiceMock
|
|
params *InviteServiceMockGenerateParams
|
|
paramPtrs *InviteServiceMockGenerateParamPtrs
|
|
expectationOrigins InviteServiceMockGenerateExpectationOrigins
|
|
results *InviteServiceMockGenerateResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// InviteServiceMockGenerateParams contains parameters of the InviteService.Generate
|
|
type InviteServiceMockGenerateParams struct {
|
|
ctx context.Context
|
|
userID int
|
|
maxUses int
|
|
ttlDays int
|
|
}
|
|
|
|
// InviteServiceMockGenerateParamPtrs contains pointers to parameters of the InviteService.Generate
|
|
type InviteServiceMockGenerateParamPtrs struct {
|
|
ctx *context.Context
|
|
userID *int
|
|
maxUses *int
|
|
ttlDays *int
|
|
}
|
|
|
|
// InviteServiceMockGenerateResults contains results of the InviteService.Generate
|
|
type InviteServiceMockGenerateResults struct {
|
|
ip1 *model.InviteCode
|
|
err error
|
|
}
|
|
|
|
// InviteServiceMockGenerateOrigins contains origins of expectations of the InviteService.Generate
|
|
type InviteServiceMockGenerateExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originUserID string
|
|
originMaxUses string
|
|
originTtlDays 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 (mmGenerate *mInviteServiceMockGenerate) Optional() *mInviteServiceMockGenerate {
|
|
mmGenerate.optional = true
|
|
return mmGenerate
|
|
}
|
|
|
|
// Expect sets up expected params for InviteService.Generate
|
|
func (mmGenerate *mInviteServiceMockGenerate) Expect(ctx context.Context, userID int, maxUses int, ttlDays int) *mInviteServiceMockGenerate {
|
|
if mmGenerate.mock.funcGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation == nil {
|
|
mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{}
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.paramPtrs != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmGenerate.defaultExpectation.params = &InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays}
|
|
mmGenerate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmGenerate.expectations {
|
|
if minimock.Equal(e.params, mmGenerate.defaultExpectation.params) {
|
|
mmGenerate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGenerate.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmGenerate
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for InviteService.Generate
|
|
func (mmGenerate *mInviteServiceMockGenerate) ExpectCtxParam1(ctx context.Context) *mInviteServiceMockGenerate {
|
|
if mmGenerate.mock.funcGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation == nil {
|
|
mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{}
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.params != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.paramPtrs == nil {
|
|
mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{}
|
|
}
|
|
mmGenerate.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmGenerate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmGenerate
|
|
}
|
|
|
|
// ExpectUserIDParam2 sets up expected param userID for InviteService.Generate
|
|
func (mmGenerate *mInviteServiceMockGenerate) ExpectUserIDParam2(userID int) *mInviteServiceMockGenerate {
|
|
if mmGenerate.mock.funcGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation == nil {
|
|
mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{}
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.params != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.paramPtrs == nil {
|
|
mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{}
|
|
}
|
|
mmGenerate.defaultExpectation.paramPtrs.userID = &userID
|
|
mmGenerate.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1)
|
|
|
|
return mmGenerate
|
|
}
|
|
|
|
// ExpectMaxUsesParam3 sets up expected param maxUses for InviteService.Generate
|
|
func (mmGenerate *mInviteServiceMockGenerate) ExpectMaxUsesParam3(maxUses int) *mInviteServiceMockGenerate {
|
|
if mmGenerate.mock.funcGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation == nil {
|
|
mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{}
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.params != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.paramPtrs == nil {
|
|
mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{}
|
|
}
|
|
mmGenerate.defaultExpectation.paramPtrs.maxUses = &maxUses
|
|
mmGenerate.defaultExpectation.expectationOrigins.originMaxUses = minimock.CallerInfo(1)
|
|
|
|
return mmGenerate
|
|
}
|
|
|
|
// ExpectTtlDaysParam4 sets up expected param ttlDays for InviteService.Generate
|
|
func (mmGenerate *mInviteServiceMockGenerate) ExpectTtlDaysParam4(ttlDays int) *mInviteServiceMockGenerate {
|
|
if mmGenerate.mock.funcGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation == nil {
|
|
mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{}
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.params != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation.paramPtrs == nil {
|
|
mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{}
|
|
}
|
|
mmGenerate.defaultExpectation.paramPtrs.ttlDays = &ttlDays
|
|
mmGenerate.defaultExpectation.expectationOrigins.originTtlDays = minimock.CallerInfo(1)
|
|
|
|
return mmGenerate
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the InviteService.Generate
|
|
func (mmGenerate *mInviteServiceMockGenerate) Inspect(f func(ctx context.Context, userID int, maxUses int, ttlDays int)) *mInviteServiceMockGenerate {
|
|
if mmGenerate.mock.inspectFuncGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("Inspect function is already set for InviteServiceMock.Generate")
|
|
}
|
|
|
|
mmGenerate.mock.inspectFuncGenerate = f
|
|
|
|
return mmGenerate
|
|
}
|
|
|
|
// Return sets up results that will be returned by InviteService.Generate
|
|
func (mmGenerate *mInviteServiceMockGenerate) Return(ip1 *model.InviteCode, err error) *InviteServiceMock {
|
|
if mmGenerate.mock.funcGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set")
|
|
}
|
|
|
|
if mmGenerate.defaultExpectation == nil {
|
|
mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{mock: mmGenerate.mock}
|
|
}
|
|
mmGenerate.defaultExpectation.results = &InviteServiceMockGenerateResults{ip1, err}
|
|
mmGenerate.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmGenerate.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the InviteService.Generate method
|
|
func (mmGenerate *mInviteServiceMockGenerate) Set(f func(ctx context.Context, userID int, maxUses int, ttlDays int) (ip1 *model.InviteCode, err error)) *InviteServiceMock {
|
|
if mmGenerate.defaultExpectation != nil {
|
|
mmGenerate.mock.t.Fatalf("Default expectation is already set for the InviteService.Generate method")
|
|
}
|
|
|
|
if len(mmGenerate.expectations) > 0 {
|
|
mmGenerate.mock.t.Fatalf("Some expectations are already set for the InviteService.Generate method")
|
|
}
|
|
|
|
mmGenerate.mock.funcGenerate = f
|
|
mmGenerate.mock.funcGenerateOrigin = minimock.CallerInfo(1)
|
|
return mmGenerate.mock
|
|
}
|
|
|
|
// When sets expectation for the InviteService.Generate which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmGenerate *mInviteServiceMockGenerate) When(ctx context.Context, userID int, maxUses int, ttlDays int) *InviteServiceMockGenerateExpectation {
|
|
if mmGenerate.mock.funcGenerate != nil {
|
|
mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set")
|
|
}
|
|
|
|
expectation := &InviteServiceMockGenerateExpectation{
|
|
mock: mmGenerate.mock,
|
|
params: &InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays},
|
|
expectationOrigins: InviteServiceMockGenerateExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmGenerate.expectations = append(mmGenerate.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up InviteService.Generate return parameters for the expectation previously defined by the When method
|
|
func (e *InviteServiceMockGenerateExpectation) Then(ip1 *model.InviteCode, err error) *InviteServiceMock {
|
|
e.results = &InviteServiceMockGenerateResults{ip1, err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times InviteService.Generate should be invoked
|
|
func (mmGenerate *mInviteServiceMockGenerate) Times(n uint64) *mInviteServiceMockGenerate {
|
|
if n == 0 {
|
|
mmGenerate.mock.t.Fatalf("Times of InviteServiceMock.Generate mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmGenerate.expectedInvocations, n)
|
|
mmGenerate.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmGenerate
|
|
}
|
|
|
|
func (mmGenerate *mInviteServiceMockGenerate) invocationsDone() bool {
|
|
if len(mmGenerate.expectations) == 0 && mmGenerate.defaultExpectation == nil && mmGenerate.mock.funcGenerate == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmGenerate.mock.afterGenerateCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmGenerate.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// Generate implements mm_service.InviteService
|
|
func (mmGenerate *InviteServiceMock) Generate(ctx context.Context, userID int, maxUses int, ttlDays int) (ip1 *model.InviteCode, err error) {
|
|
mm_atomic.AddUint64(&mmGenerate.beforeGenerateCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmGenerate.afterGenerateCounter, 1)
|
|
|
|
mmGenerate.t.Helper()
|
|
|
|
if mmGenerate.inspectFuncGenerate != nil {
|
|
mmGenerate.inspectFuncGenerate(ctx, userID, maxUses, ttlDays)
|
|
}
|
|
|
|
mm_params := InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays}
|
|
|
|
// Record call args
|
|
mmGenerate.GenerateMock.mutex.Lock()
|
|
mmGenerate.GenerateMock.callArgs = append(mmGenerate.GenerateMock.callArgs, &mm_params)
|
|
mmGenerate.GenerateMock.mutex.Unlock()
|
|
|
|
for _, e := range mmGenerate.GenerateMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.ip1, e.results.err
|
|
}
|
|
}
|
|
|
|
if mmGenerate.GenerateMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmGenerate.GenerateMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmGenerate.GenerateMock.defaultExpectation.params
|
|
mm_want_ptrs := mmGenerate.GenerateMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) {
|
|
mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID))
|
|
}
|
|
|
|
if mm_want_ptrs.maxUses != nil && !minimock.Equal(*mm_want_ptrs.maxUses, mm_got.maxUses) {
|
|
mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter maxUses, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originMaxUses, *mm_want_ptrs.maxUses, mm_got.maxUses, minimock.Diff(*mm_want_ptrs.maxUses, mm_got.maxUses))
|
|
}
|
|
|
|
if mm_want_ptrs.ttlDays != nil && !minimock.Equal(*mm_want_ptrs.ttlDays, mm_got.ttlDays) {
|
|
mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter ttlDays, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originTtlDays, *mm_want_ptrs.ttlDays, mm_got.ttlDays, minimock.Diff(*mm_want_ptrs.ttlDays, mm_got.ttlDays))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmGenerate.GenerateMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmGenerate.t.Fatal("No results are set for the InviteServiceMock.Generate")
|
|
}
|
|
return (*mm_results).ip1, (*mm_results).err
|
|
}
|
|
if mmGenerate.funcGenerate != nil {
|
|
return mmGenerate.funcGenerate(ctx, userID, maxUses, ttlDays)
|
|
}
|
|
mmGenerate.t.Fatalf("Unexpected call to InviteServiceMock.Generate. %v %v %v %v", ctx, userID, maxUses, ttlDays)
|
|
return
|
|
}
|
|
|
|
// GenerateAfterCounter returns a count of finished InviteServiceMock.Generate invocations
|
|
func (mmGenerate *InviteServiceMock) GenerateAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmGenerate.afterGenerateCounter)
|
|
}
|
|
|
|
// GenerateBeforeCounter returns a count of InviteServiceMock.Generate invocations
|
|
func (mmGenerate *InviteServiceMock) GenerateBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmGenerate.beforeGenerateCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to InviteServiceMock.Generate.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmGenerate *mInviteServiceMockGenerate) Calls() []*InviteServiceMockGenerateParams {
|
|
mmGenerate.mutex.RLock()
|
|
|
|
argCopy := make([]*InviteServiceMockGenerateParams, len(mmGenerate.callArgs))
|
|
copy(argCopy, mmGenerate.callArgs)
|
|
|
|
mmGenerate.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockGenerateDone returns true if the count of the Generate invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *InviteServiceMock) MinimockGenerateDone() bool {
|
|
if m.GenerateMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.GenerateMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.GenerateMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockGenerateInspect logs each unmet expectation
|
|
func (m *InviteServiceMock) MinimockGenerateInspect() {
|
|
for _, e := range m.GenerateMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterGenerateCounter := mm_atomic.LoadUint64(&m.afterGenerateCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.GenerateMock.defaultExpectation != nil && afterGenerateCounter < 1 {
|
|
if m.GenerateMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s", m.GenerateMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s with params: %#v", m.GenerateMock.defaultExpectation.expectationOrigins.origin, *m.GenerateMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcGenerate != nil && afterGenerateCounter < 1 {
|
|
m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s", m.funcGenerateOrigin)
|
|
}
|
|
|
|
if !m.GenerateMock.invocationsDone() && afterGenerateCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to InviteServiceMock.Generate at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.GenerateMock.expectedInvocations), m.GenerateMock.expectedInvocationsOrigin, afterGenerateCounter)
|
|
}
|
|
}
|
|
|
|
type mInviteServiceMockGetInfo struct {
|
|
optional bool
|
|
mock *InviteServiceMock
|
|
defaultExpectation *InviteServiceMockGetInfoExpectation
|
|
expectations []*InviteServiceMockGetInfoExpectation
|
|
|
|
callArgs []*InviteServiceMockGetInfoParams
|
|
mutex sync.RWMutex
|
|
|
|
expectedInvocations uint64
|
|
expectedInvocationsOrigin string
|
|
}
|
|
|
|
// InviteServiceMockGetInfoExpectation specifies expectation struct of the InviteService.GetInfo
|
|
type InviteServiceMockGetInfoExpectation struct {
|
|
mock *InviteServiceMock
|
|
params *InviteServiceMockGetInfoParams
|
|
paramPtrs *InviteServiceMockGetInfoParamPtrs
|
|
expectationOrigins InviteServiceMockGetInfoExpectationOrigins
|
|
results *InviteServiceMockGetInfoResults
|
|
returnOrigin string
|
|
Counter uint64
|
|
}
|
|
|
|
// InviteServiceMockGetInfoParams contains parameters of the InviteService.GetInfo
|
|
type InviteServiceMockGetInfoParams struct {
|
|
ctx context.Context
|
|
userID int
|
|
}
|
|
|
|
// InviteServiceMockGetInfoParamPtrs contains pointers to parameters of the InviteService.GetInfo
|
|
type InviteServiceMockGetInfoParamPtrs struct {
|
|
ctx *context.Context
|
|
userID *int
|
|
}
|
|
|
|
// InviteServiceMockGetInfoResults contains results of the InviteService.GetInfo
|
|
type InviteServiceMockGetInfoResults struct {
|
|
ip1 *model.InviteCode
|
|
err error
|
|
}
|
|
|
|
// InviteServiceMockGetInfoOrigins contains origins of expectations of the InviteService.GetInfo
|
|
type InviteServiceMockGetInfoExpectationOrigins struct {
|
|
origin string
|
|
originCtx string
|
|
originUserID 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 (mmGetInfo *mInviteServiceMockGetInfo) Optional() *mInviteServiceMockGetInfo {
|
|
mmGetInfo.optional = true
|
|
return mmGetInfo
|
|
}
|
|
|
|
// Expect sets up expected params for InviteService.GetInfo
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) Expect(ctx context.Context, userID int) *mInviteServiceMockGetInfo {
|
|
if mmGetInfo.mock.funcGetInfo != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set")
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation == nil {
|
|
mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{}
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation.paramPtrs != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by ExpectParams functions")
|
|
}
|
|
|
|
mmGetInfo.defaultExpectation.params = &InviteServiceMockGetInfoParams{ctx, userID}
|
|
mmGetInfo.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
|
|
for _, e := range mmGetInfo.expectations {
|
|
if minimock.Equal(e.params, mmGetInfo.defaultExpectation.params) {
|
|
mmGetInfo.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetInfo.defaultExpectation.params)
|
|
}
|
|
}
|
|
|
|
return mmGetInfo
|
|
}
|
|
|
|
// ExpectCtxParam1 sets up expected param ctx for InviteService.GetInfo
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) ExpectCtxParam1(ctx context.Context) *mInviteServiceMockGetInfo {
|
|
if mmGetInfo.mock.funcGetInfo != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set")
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation == nil {
|
|
mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{}
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation.params != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Expect")
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation.paramPtrs == nil {
|
|
mmGetInfo.defaultExpectation.paramPtrs = &InviteServiceMockGetInfoParamPtrs{}
|
|
}
|
|
mmGetInfo.defaultExpectation.paramPtrs.ctx = &ctx
|
|
mmGetInfo.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
|
|
|
|
return mmGetInfo
|
|
}
|
|
|
|
// ExpectUserIDParam2 sets up expected param userID for InviteService.GetInfo
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) ExpectUserIDParam2(userID int) *mInviteServiceMockGetInfo {
|
|
if mmGetInfo.mock.funcGetInfo != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set")
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation == nil {
|
|
mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{}
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation.params != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Expect")
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation.paramPtrs == nil {
|
|
mmGetInfo.defaultExpectation.paramPtrs = &InviteServiceMockGetInfoParamPtrs{}
|
|
}
|
|
mmGetInfo.defaultExpectation.paramPtrs.userID = &userID
|
|
mmGetInfo.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1)
|
|
|
|
return mmGetInfo
|
|
}
|
|
|
|
// Inspect accepts an inspector function that has same arguments as the InviteService.GetInfo
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) Inspect(f func(ctx context.Context, userID int)) *mInviteServiceMockGetInfo {
|
|
if mmGetInfo.mock.inspectFuncGetInfo != nil {
|
|
mmGetInfo.mock.t.Fatalf("Inspect function is already set for InviteServiceMock.GetInfo")
|
|
}
|
|
|
|
mmGetInfo.mock.inspectFuncGetInfo = f
|
|
|
|
return mmGetInfo
|
|
}
|
|
|
|
// Return sets up results that will be returned by InviteService.GetInfo
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) Return(ip1 *model.InviteCode, err error) *InviteServiceMock {
|
|
if mmGetInfo.mock.funcGetInfo != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set")
|
|
}
|
|
|
|
if mmGetInfo.defaultExpectation == nil {
|
|
mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{mock: mmGetInfo.mock}
|
|
}
|
|
mmGetInfo.defaultExpectation.results = &InviteServiceMockGetInfoResults{ip1, err}
|
|
mmGetInfo.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
|
|
return mmGetInfo.mock
|
|
}
|
|
|
|
// Set uses given function f to mock the InviteService.GetInfo method
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) Set(f func(ctx context.Context, userID int) (ip1 *model.InviteCode, err error)) *InviteServiceMock {
|
|
if mmGetInfo.defaultExpectation != nil {
|
|
mmGetInfo.mock.t.Fatalf("Default expectation is already set for the InviteService.GetInfo method")
|
|
}
|
|
|
|
if len(mmGetInfo.expectations) > 0 {
|
|
mmGetInfo.mock.t.Fatalf("Some expectations are already set for the InviteService.GetInfo method")
|
|
}
|
|
|
|
mmGetInfo.mock.funcGetInfo = f
|
|
mmGetInfo.mock.funcGetInfoOrigin = minimock.CallerInfo(1)
|
|
return mmGetInfo.mock
|
|
}
|
|
|
|
// When sets expectation for the InviteService.GetInfo which will trigger the result defined by the following
|
|
// Then helper
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) When(ctx context.Context, userID int) *InviteServiceMockGetInfoExpectation {
|
|
if mmGetInfo.mock.funcGetInfo != nil {
|
|
mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set")
|
|
}
|
|
|
|
expectation := &InviteServiceMockGetInfoExpectation{
|
|
mock: mmGetInfo.mock,
|
|
params: &InviteServiceMockGetInfoParams{ctx, userID},
|
|
expectationOrigins: InviteServiceMockGetInfoExpectationOrigins{origin: minimock.CallerInfo(1)},
|
|
}
|
|
mmGetInfo.expectations = append(mmGetInfo.expectations, expectation)
|
|
return expectation
|
|
}
|
|
|
|
// Then sets up InviteService.GetInfo return parameters for the expectation previously defined by the When method
|
|
func (e *InviteServiceMockGetInfoExpectation) Then(ip1 *model.InviteCode, err error) *InviteServiceMock {
|
|
e.results = &InviteServiceMockGetInfoResults{ip1, err}
|
|
return e.mock
|
|
}
|
|
|
|
// Times sets number of times InviteService.GetInfo should be invoked
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) Times(n uint64) *mInviteServiceMockGetInfo {
|
|
if n == 0 {
|
|
mmGetInfo.mock.t.Fatalf("Times of InviteServiceMock.GetInfo mock can not be zero")
|
|
}
|
|
mm_atomic.StoreUint64(&mmGetInfo.expectedInvocations, n)
|
|
mmGetInfo.expectedInvocationsOrigin = minimock.CallerInfo(1)
|
|
return mmGetInfo
|
|
}
|
|
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) invocationsDone() bool {
|
|
if len(mmGetInfo.expectations) == 0 && mmGetInfo.defaultExpectation == nil && mmGetInfo.mock.funcGetInfo == nil {
|
|
return true
|
|
}
|
|
|
|
totalInvocations := mm_atomic.LoadUint64(&mmGetInfo.mock.afterGetInfoCounter)
|
|
expectedInvocations := mm_atomic.LoadUint64(&mmGetInfo.expectedInvocations)
|
|
|
|
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
|
|
}
|
|
|
|
// GetInfo implements mm_service.InviteService
|
|
func (mmGetInfo *InviteServiceMock) GetInfo(ctx context.Context, userID int) (ip1 *model.InviteCode, err error) {
|
|
mm_atomic.AddUint64(&mmGetInfo.beforeGetInfoCounter, 1)
|
|
defer mm_atomic.AddUint64(&mmGetInfo.afterGetInfoCounter, 1)
|
|
|
|
mmGetInfo.t.Helper()
|
|
|
|
if mmGetInfo.inspectFuncGetInfo != nil {
|
|
mmGetInfo.inspectFuncGetInfo(ctx, userID)
|
|
}
|
|
|
|
mm_params := InviteServiceMockGetInfoParams{ctx, userID}
|
|
|
|
// Record call args
|
|
mmGetInfo.GetInfoMock.mutex.Lock()
|
|
mmGetInfo.GetInfoMock.callArgs = append(mmGetInfo.GetInfoMock.callArgs, &mm_params)
|
|
mmGetInfo.GetInfoMock.mutex.Unlock()
|
|
|
|
for _, e := range mmGetInfo.GetInfoMock.expectations {
|
|
if minimock.Equal(*e.params, mm_params) {
|
|
mm_atomic.AddUint64(&e.Counter, 1)
|
|
return e.results.ip1, e.results.err
|
|
}
|
|
}
|
|
|
|
if mmGetInfo.GetInfoMock.defaultExpectation != nil {
|
|
mm_atomic.AddUint64(&mmGetInfo.GetInfoMock.defaultExpectation.Counter, 1)
|
|
mm_want := mmGetInfo.GetInfoMock.defaultExpectation.params
|
|
mm_want_ptrs := mmGetInfo.GetInfoMock.defaultExpectation.paramPtrs
|
|
|
|
mm_got := InviteServiceMockGetInfoParams{ctx, userID}
|
|
|
|
if mm_want_ptrs != nil {
|
|
|
|
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
|
|
mmGetInfo.t.Errorf("InviteServiceMock.GetInfo got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
|
|
}
|
|
|
|
if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) {
|
|
mmGetInfo.t.Errorf("InviteServiceMock.GetInfo got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID))
|
|
}
|
|
|
|
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
mmGetInfo.t.Errorf("InviteServiceMock.GetInfo got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
|
|
mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
}
|
|
|
|
mm_results := mmGetInfo.GetInfoMock.defaultExpectation.results
|
|
if mm_results == nil {
|
|
mmGetInfo.t.Fatal("No results are set for the InviteServiceMock.GetInfo")
|
|
}
|
|
return (*mm_results).ip1, (*mm_results).err
|
|
}
|
|
if mmGetInfo.funcGetInfo != nil {
|
|
return mmGetInfo.funcGetInfo(ctx, userID)
|
|
}
|
|
mmGetInfo.t.Fatalf("Unexpected call to InviteServiceMock.GetInfo. %v %v", ctx, userID)
|
|
return
|
|
}
|
|
|
|
// GetInfoAfterCounter returns a count of finished InviteServiceMock.GetInfo invocations
|
|
func (mmGetInfo *InviteServiceMock) GetInfoAfterCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmGetInfo.afterGetInfoCounter)
|
|
}
|
|
|
|
// GetInfoBeforeCounter returns a count of InviteServiceMock.GetInfo invocations
|
|
func (mmGetInfo *InviteServiceMock) GetInfoBeforeCounter() uint64 {
|
|
return mm_atomic.LoadUint64(&mmGetInfo.beforeGetInfoCounter)
|
|
}
|
|
|
|
// Calls returns a list of arguments used in each call to InviteServiceMock.GetInfo.
|
|
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
func (mmGetInfo *mInviteServiceMockGetInfo) Calls() []*InviteServiceMockGetInfoParams {
|
|
mmGetInfo.mutex.RLock()
|
|
|
|
argCopy := make([]*InviteServiceMockGetInfoParams, len(mmGetInfo.callArgs))
|
|
copy(argCopy, mmGetInfo.callArgs)
|
|
|
|
mmGetInfo.mutex.RUnlock()
|
|
|
|
return argCopy
|
|
}
|
|
|
|
// MinimockGetInfoDone returns true if the count of the GetInfo invocations corresponds
|
|
// the number of defined expectations
|
|
func (m *InviteServiceMock) MinimockGetInfoDone() bool {
|
|
if m.GetInfoMock.optional {
|
|
// Optional methods provide '0 or more' call count restriction.
|
|
return true
|
|
}
|
|
|
|
for _, e := range m.GetInfoMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return m.GetInfoMock.invocationsDone()
|
|
}
|
|
|
|
// MinimockGetInfoInspect logs each unmet expectation
|
|
func (m *InviteServiceMock) MinimockGetInfoInspect() {
|
|
for _, e := range m.GetInfoMock.expectations {
|
|
if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
|
|
}
|
|
}
|
|
|
|
afterGetInfoCounter := mm_atomic.LoadUint64(&m.afterGetInfoCounter)
|
|
// if default expectation was set then invocations count should be greater than zero
|
|
if m.GetInfoMock.defaultExpectation != nil && afterGetInfoCounter < 1 {
|
|
if m.GetInfoMock.defaultExpectation.params == nil {
|
|
m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s", m.GetInfoMock.defaultExpectation.returnOrigin)
|
|
} else {
|
|
m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s with params: %#v", m.GetInfoMock.defaultExpectation.expectationOrigins.origin, *m.GetInfoMock.defaultExpectation.params)
|
|
}
|
|
}
|
|
// if func was set then invocations count should be greater than zero
|
|
if m.funcGetInfo != nil && afterGetInfoCounter < 1 {
|
|
m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s", m.funcGetInfoOrigin)
|
|
}
|
|
|
|
if !m.GetInfoMock.invocationsDone() && afterGetInfoCounter > 0 {
|
|
m.t.Errorf("Expected %d calls to InviteServiceMock.GetInfo at\n%s but found %d calls",
|
|
mm_atomic.LoadUint64(&m.GetInfoMock.expectedInvocations), m.GetInfoMock.expectedInvocationsOrigin, afterGetInfoCounter)
|
|
}
|
|
}
|
|
|
|
// MinimockFinish checks that all mocked methods have been called the expected number of times
|
|
func (m *InviteServiceMock) MinimockFinish() {
|
|
m.finishOnce.Do(func() {
|
|
if !m.minimockDone() {
|
|
m.MinimockGenerateInspect()
|
|
|
|
m.MinimockGetInfoInspect()
|
|
}
|
|
})
|
|
}
|
|
|
|
// MinimockWait waits for all mocked methods to be called the expected number of times
|
|
func (m *InviteServiceMock) MinimockWait(timeout mm_time.Duration) {
|
|
timeoutCh := mm_time.After(timeout)
|
|
for {
|
|
if m.minimockDone() {
|
|
return
|
|
}
|
|
select {
|
|
case <-timeoutCh:
|
|
m.MinimockFinish()
|
|
return
|
|
case <-mm_time.After(10 * mm_time.Millisecond):
|
|
}
|
|
}
|
|
}
|
|
|
|
func (m *InviteServiceMock) minimockDone() bool {
|
|
done := true
|
|
return done &&
|
|
m.MinimockGenerateDone() &&
|
|
m.MinimockGetInfoDone()
|
|
}
|