add service
All checks were successful
Deploy Smart Search Backend Test / deploy (push) Successful in 1m36s

This commit is contained in:
vallyenfail
2026-01-19 16:26:03 +03:00
parent 6d238a96ec
commit d782ab21ab
3 changed files with 477 additions and 28 deletions

View File

@@ -21,6 +21,13 @@ type RequestRepositoryMock struct {
t minimock.Tester
finishOnce sync.Once
funcCheckOwnership func(ctx context.Context, requestID uuid.UUID, userID int) (b1 bool, err error)
funcCheckOwnershipOrigin string
inspectFuncCheckOwnership func(ctx context.Context, requestID uuid.UUID, userID int)
afterCheckOwnershipCounter uint64
beforeCheckOwnershipCounter uint64
CheckOwnershipMock mRequestRepositoryMockCheckOwnership
funcCreate func(ctx context.Context, req *model.Request) (err error)
funcCreateOrigin string
inspectFuncCreate func(ctx context.Context, req *model.Request)
@@ -86,6 +93,9 @@ func NewRequestRepositoryMock(t minimock.Tester) *RequestRepositoryMock {
controller.RegisterMocker(m)
}
m.CheckOwnershipMock = mRequestRepositoryMockCheckOwnership{mock: m}
m.CheckOwnershipMock.callArgs = []*RequestRepositoryMockCheckOwnershipParams{}
m.CreateMock = mRequestRepositoryMockCreate{mock: m}
m.CreateMock.callArgs = []*RequestRepositoryMockCreateParams{}
@@ -115,6 +125,380 @@ func NewRequestRepositoryMock(t minimock.Tester) *RequestRepositoryMock {
return m
}
type mRequestRepositoryMockCheckOwnership struct {
optional bool
mock *RequestRepositoryMock
defaultExpectation *RequestRepositoryMockCheckOwnershipExpectation
expectations []*RequestRepositoryMockCheckOwnershipExpectation
callArgs []*RequestRepositoryMockCheckOwnershipParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// RequestRepositoryMockCheckOwnershipExpectation specifies expectation struct of the RequestRepository.CheckOwnership
type RequestRepositoryMockCheckOwnershipExpectation struct {
mock *RequestRepositoryMock
params *RequestRepositoryMockCheckOwnershipParams
paramPtrs *RequestRepositoryMockCheckOwnershipParamPtrs
expectationOrigins RequestRepositoryMockCheckOwnershipExpectationOrigins
results *RequestRepositoryMockCheckOwnershipResults
returnOrigin string
Counter uint64
}
// RequestRepositoryMockCheckOwnershipParams contains parameters of the RequestRepository.CheckOwnership
type RequestRepositoryMockCheckOwnershipParams struct {
ctx context.Context
requestID uuid.UUID
userID int
}
// RequestRepositoryMockCheckOwnershipParamPtrs contains pointers to parameters of the RequestRepository.CheckOwnership
type RequestRepositoryMockCheckOwnershipParamPtrs struct {
ctx *context.Context
requestID *uuid.UUID
userID *int
}
// RequestRepositoryMockCheckOwnershipResults contains results of the RequestRepository.CheckOwnership
type RequestRepositoryMockCheckOwnershipResults struct {
b1 bool
err error
}
// RequestRepositoryMockCheckOwnershipOrigins contains origins of expectations of the RequestRepository.CheckOwnership
type RequestRepositoryMockCheckOwnershipExpectationOrigins struct {
origin string
originCtx string
originRequestID 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 (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) Optional() *mRequestRepositoryMockCheckOwnership {
mmCheckOwnership.optional = true
return mmCheckOwnership
}
// Expect sets up expected params for RequestRepository.CheckOwnership
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) Expect(ctx context.Context, requestID uuid.UUID, userID int) *mRequestRepositoryMockCheckOwnership {
if mmCheckOwnership.mock.funcCheckOwnership != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Set")
}
if mmCheckOwnership.defaultExpectation == nil {
mmCheckOwnership.defaultExpectation = &RequestRepositoryMockCheckOwnershipExpectation{}
}
if mmCheckOwnership.defaultExpectation.paramPtrs != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by ExpectParams functions")
}
mmCheckOwnership.defaultExpectation.params = &RequestRepositoryMockCheckOwnershipParams{ctx, requestID, userID}
mmCheckOwnership.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmCheckOwnership.expectations {
if minimock.Equal(e.params, mmCheckOwnership.defaultExpectation.params) {
mmCheckOwnership.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCheckOwnership.defaultExpectation.params)
}
}
return mmCheckOwnership
}
// ExpectCtxParam1 sets up expected param ctx for RequestRepository.CheckOwnership
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockCheckOwnership {
if mmCheckOwnership.mock.funcCheckOwnership != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Set")
}
if mmCheckOwnership.defaultExpectation == nil {
mmCheckOwnership.defaultExpectation = &RequestRepositoryMockCheckOwnershipExpectation{}
}
if mmCheckOwnership.defaultExpectation.params != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Expect")
}
if mmCheckOwnership.defaultExpectation.paramPtrs == nil {
mmCheckOwnership.defaultExpectation.paramPtrs = &RequestRepositoryMockCheckOwnershipParamPtrs{}
}
mmCheckOwnership.defaultExpectation.paramPtrs.ctx = &ctx
mmCheckOwnership.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmCheckOwnership
}
// ExpectRequestIDParam2 sets up expected param requestID for RequestRepository.CheckOwnership
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) ExpectRequestIDParam2(requestID uuid.UUID) *mRequestRepositoryMockCheckOwnership {
if mmCheckOwnership.mock.funcCheckOwnership != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Set")
}
if mmCheckOwnership.defaultExpectation == nil {
mmCheckOwnership.defaultExpectation = &RequestRepositoryMockCheckOwnershipExpectation{}
}
if mmCheckOwnership.defaultExpectation.params != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Expect")
}
if mmCheckOwnership.defaultExpectation.paramPtrs == nil {
mmCheckOwnership.defaultExpectation.paramPtrs = &RequestRepositoryMockCheckOwnershipParamPtrs{}
}
mmCheckOwnership.defaultExpectation.paramPtrs.requestID = &requestID
mmCheckOwnership.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1)
return mmCheckOwnership
}
// ExpectUserIDParam3 sets up expected param userID for RequestRepository.CheckOwnership
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) ExpectUserIDParam3(userID int) *mRequestRepositoryMockCheckOwnership {
if mmCheckOwnership.mock.funcCheckOwnership != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Set")
}
if mmCheckOwnership.defaultExpectation == nil {
mmCheckOwnership.defaultExpectation = &RequestRepositoryMockCheckOwnershipExpectation{}
}
if mmCheckOwnership.defaultExpectation.params != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Expect")
}
if mmCheckOwnership.defaultExpectation.paramPtrs == nil {
mmCheckOwnership.defaultExpectation.paramPtrs = &RequestRepositoryMockCheckOwnershipParamPtrs{}
}
mmCheckOwnership.defaultExpectation.paramPtrs.userID = &userID
mmCheckOwnership.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1)
return mmCheckOwnership
}
// Inspect accepts an inspector function that has same arguments as the RequestRepository.CheckOwnership
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) Inspect(f func(ctx context.Context, requestID uuid.UUID, userID int)) *mRequestRepositoryMockCheckOwnership {
if mmCheckOwnership.mock.inspectFuncCheckOwnership != nil {
mmCheckOwnership.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.CheckOwnership")
}
mmCheckOwnership.mock.inspectFuncCheckOwnership = f
return mmCheckOwnership
}
// Return sets up results that will be returned by RequestRepository.CheckOwnership
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) Return(b1 bool, err error) *RequestRepositoryMock {
if mmCheckOwnership.mock.funcCheckOwnership != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Set")
}
if mmCheckOwnership.defaultExpectation == nil {
mmCheckOwnership.defaultExpectation = &RequestRepositoryMockCheckOwnershipExpectation{mock: mmCheckOwnership.mock}
}
mmCheckOwnership.defaultExpectation.results = &RequestRepositoryMockCheckOwnershipResults{b1, err}
mmCheckOwnership.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmCheckOwnership.mock
}
// Set uses given function f to mock the RequestRepository.CheckOwnership method
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) Set(f func(ctx context.Context, requestID uuid.UUID, userID int) (b1 bool, err error)) *RequestRepositoryMock {
if mmCheckOwnership.defaultExpectation != nil {
mmCheckOwnership.mock.t.Fatalf("Default expectation is already set for the RequestRepository.CheckOwnership method")
}
if len(mmCheckOwnership.expectations) > 0 {
mmCheckOwnership.mock.t.Fatalf("Some expectations are already set for the RequestRepository.CheckOwnership method")
}
mmCheckOwnership.mock.funcCheckOwnership = f
mmCheckOwnership.mock.funcCheckOwnershipOrigin = minimock.CallerInfo(1)
return mmCheckOwnership.mock
}
// When sets expectation for the RequestRepository.CheckOwnership which will trigger the result defined by the following
// Then helper
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) When(ctx context.Context, requestID uuid.UUID, userID int) *RequestRepositoryMockCheckOwnershipExpectation {
if mmCheckOwnership.mock.funcCheckOwnership != nil {
mmCheckOwnership.mock.t.Fatalf("RequestRepositoryMock.CheckOwnership mock is already set by Set")
}
expectation := &RequestRepositoryMockCheckOwnershipExpectation{
mock: mmCheckOwnership.mock,
params: &RequestRepositoryMockCheckOwnershipParams{ctx, requestID, userID},
expectationOrigins: RequestRepositoryMockCheckOwnershipExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmCheckOwnership.expectations = append(mmCheckOwnership.expectations, expectation)
return expectation
}
// Then sets up RequestRepository.CheckOwnership return parameters for the expectation previously defined by the When method
func (e *RequestRepositoryMockCheckOwnershipExpectation) Then(b1 bool, err error) *RequestRepositoryMock {
e.results = &RequestRepositoryMockCheckOwnershipResults{b1, err}
return e.mock
}
// Times sets number of times RequestRepository.CheckOwnership should be invoked
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) Times(n uint64) *mRequestRepositoryMockCheckOwnership {
if n == 0 {
mmCheckOwnership.mock.t.Fatalf("Times of RequestRepositoryMock.CheckOwnership mock can not be zero")
}
mm_atomic.StoreUint64(&mmCheckOwnership.expectedInvocations, n)
mmCheckOwnership.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmCheckOwnership
}
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) invocationsDone() bool {
if len(mmCheckOwnership.expectations) == 0 && mmCheckOwnership.defaultExpectation == nil && mmCheckOwnership.mock.funcCheckOwnership == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmCheckOwnership.mock.afterCheckOwnershipCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmCheckOwnership.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// CheckOwnership implements mm_repository.RequestRepository
func (mmCheckOwnership *RequestRepositoryMock) CheckOwnership(ctx context.Context, requestID uuid.UUID, userID int) (b1 bool, err error) {
mm_atomic.AddUint64(&mmCheckOwnership.beforeCheckOwnershipCounter, 1)
defer mm_atomic.AddUint64(&mmCheckOwnership.afterCheckOwnershipCounter, 1)
mmCheckOwnership.t.Helper()
if mmCheckOwnership.inspectFuncCheckOwnership != nil {
mmCheckOwnership.inspectFuncCheckOwnership(ctx, requestID, userID)
}
mm_params := RequestRepositoryMockCheckOwnershipParams{ctx, requestID, userID}
// Record call args
mmCheckOwnership.CheckOwnershipMock.mutex.Lock()
mmCheckOwnership.CheckOwnershipMock.callArgs = append(mmCheckOwnership.CheckOwnershipMock.callArgs, &mm_params)
mmCheckOwnership.CheckOwnershipMock.mutex.Unlock()
for _, e := range mmCheckOwnership.CheckOwnershipMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.b1, e.results.err
}
}
if mmCheckOwnership.CheckOwnershipMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmCheckOwnership.CheckOwnershipMock.defaultExpectation.Counter, 1)
mm_want := mmCheckOwnership.CheckOwnershipMock.defaultExpectation.params
mm_want_ptrs := mmCheckOwnership.CheckOwnershipMock.defaultExpectation.paramPtrs
mm_got := RequestRepositoryMockCheckOwnershipParams{ctx, requestID, userID}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmCheckOwnership.t.Errorf("RequestRepositoryMock.CheckOwnership got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmCheckOwnership.CheckOwnershipMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
}
if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) {
mmCheckOwnership.t.Errorf("RequestRepositoryMock.CheckOwnership got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmCheckOwnership.CheckOwnershipMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID))
}
if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) {
mmCheckOwnership.t.Errorf("RequestRepositoryMock.CheckOwnership got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmCheckOwnership.CheckOwnershipMock.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) {
mmCheckOwnership.t.Errorf("RequestRepositoryMock.CheckOwnership got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmCheckOwnership.CheckOwnershipMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmCheckOwnership.CheckOwnershipMock.defaultExpectation.results
if mm_results == nil {
mmCheckOwnership.t.Fatal("No results are set for the RequestRepositoryMock.CheckOwnership")
}
return (*mm_results).b1, (*mm_results).err
}
if mmCheckOwnership.funcCheckOwnership != nil {
return mmCheckOwnership.funcCheckOwnership(ctx, requestID, userID)
}
mmCheckOwnership.t.Fatalf("Unexpected call to RequestRepositoryMock.CheckOwnership. %v %v %v", ctx, requestID, userID)
return
}
// CheckOwnershipAfterCounter returns a count of finished RequestRepositoryMock.CheckOwnership invocations
func (mmCheckOwnership *RequestRepositoryMock) CheckOwnershipAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmCheckOwnership.afterCheckOwnershipCounter)
}
// CheckOwnershipBeforeCounter returns a count of RequestRepositoryMock.CheckOwnership invocations
func (mmCheckOwnership *RequestRepositoryMock) CheckOwnershipBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmCheckOwnership.beforeCheckOwnershipCounter)
}
// Calls returns a list of arguments used in each call to RequestRepositoryMock.CheckOwnership.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmCheckOwnership *mRequestRepositoryMockCheckOwnership) Calls() []*RequestRepositoryMockCheckOwnershipParams {
mmCheckOwnership.mutex.RLock()
argCopy := make([]*RequestRepositoryMockCheckOwnershipParams, len(mmCheckOwnership.callArgs))
copy(argCopy, mmCheckOwnership.callArgs)
mmCheckOwnership.mutex.RUnlock()
return argCopy
}
// MinimockCheckOwnershipDone returns true if the count of the CheckOwnership invocations corresponds
// the number of defined expectations
func (m *RequestRepositoryMock) MinimockCheckOwnershipDone() bool {
if m.CheckOwnershipMock.optional {
// Optional methods provide '0 or more' call count restriction.
return true
}
for _, e := range m.CheckOwnershipMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
return m.CheckOwnershipMock.invocationsDone()
}
// MinimockCheckOwnershipInspect logs each unmet expectation
func (m *RequestRepositoryMock) MinimockCheckOwnershipInspect() {
for _, e := range m.CheckOwnershipMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to RequestRepositoryMock.CheckOwnership at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
}
}
afterCheckOwnershipCounter := mm_atomic.LoadUint64(&m.afterCheckOwnershipCounter)
// if default expectation was set then invocations count should be greater than zero
if m.CheckOwnershipMock.defaultExpectation != nil && afterCheckOwnershipCounter < 1 {
if m.CheckOwnershipMock.defaultExpectation.params == nil {
m.t.Errorf("Expected call to RequestRepositoryMock.CheckOwnership at\n%s", m.CheckOwnershipMock.defaultExpectation.returnOrigin)
} else {
m.t.Errorf("Expected call to RequestRepositoryMock.CheckOwnership at\n%s with params: %#v", m.CheckOwnershipMock.defaultExpectation.expectationOrigins.origin, *m.CheckOwnershipMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcCheckOwnership != nil && afterCheckOwnershipCounter < 1 {
m.t.Errorf("Expected call to RequestRepositoryMock.CheckOwnership at\n%s", m.funcCheckOwnershipOrigin)
}
if !m.CheckOwnershipMock.invocationsDone() && afterCheckOwnershipCounter > 0 {
m.t.Errorf("Expected %d calls to RequestRepositoryMock.CheckOwnership at\n%s but found %d calls",
mm_atomic.LoadUint64(&m.CheckOwnershipMock.expectedInvocations), m.CheckOwnershipMock.expectedInvocationsOrigin, afterCheckOwnershipCounter)
}
}
type mRequestRepositoryMockCreate struct {
optional bool
mock *RequestRepositoryMock
@@ -3047,6 +3431,8 @@ func (m *RequestRepositoryMock) MinimockUpdateWithTZTxInspect() {
func (m *RequestRepositoryMock) MinimockFinish() {
m.finishOnce.Do(func() {
if !m.minimockDone() {
m.MinimockCheckOwnershipInspect()
m.MinimockCreateInspect()
m.MinimockGetByIDInspect()
@@ -3085,6 +3471,7 @@ func (m *RequestRepositoryMock) MinimockWait(timeout mm_time.Duration) {
func (m *RequestRepositoryMock) minimockDone() bool {
done := true
return done &&
m.MinimockCheckOwnershipDone() &&
m.MinimockCreateDone() &&
m.MinimockGetByIDDone() &&
m.MinimockGetByUserIDDone() &&

View File

@@ -41,9 +41,9 @@ type RequestServiceMock struct {
beforeGetMailingListCounter uint64
GetMailingListMock mRequestServiceMockGetMailingList
funcGetMailingListByID func(ctx context.Context, requestID uuid.UUID) (rp1 *model.RequestDetail, err error)
funcGetMailingListByID func(ctx context.Context, requestID uuid.UUID, userID int) (rp1 *model.RequestDetail, err error)
funcGetMailingListByIDOrigin string
inspectFuncGetMailingListByID func(ctx context.Context, requestID uuid.UUID)
inspectFuncGetMailingListByID func(ctx context.Context, requestID uuid.UUID, userID int)
afterGetMailingListByIDCounter uint64
beforeGetMailingListByIDCounter uint64
GetMailingListByIDMock mRequestServiceMockGetMailingListByID
@@ -1225,12 +1225,14 @@ type RequestServiceMockGetMailingListByIDExpectation struct {
type RequestServiceMockGetMailingListByIDParams struct {
ctx context.Context
requestID uuid.UUID
userID int
}
// RequestServiceMockGetMailingListByIDParamPtrs contains pointers to parameters of the RequestService.GetMailingListByID
type RequestServiceMockGetMailingListByIDParamPtrs struct {
ctx *context.Context
requestID *uuid.UUID
userID *int
}
// RequestServiceMockGetMailingListByIDResults contains results of the RequestService.GetMailingListByID
@@ -1244,6 +1246,7 @@ type RequestServiceMockGetMailingListByIDExpectationOrigins struct {
origin string
originCtx string
originRequestID string
originUserID string
}
// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
@@ -1257,7 +1260,7 @@ func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Optional() *m
}
// Expect sets up expected params for RequestService.GetMailingListByID
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Expect(ctx context.Context, requestID uuid.UUID) *mRequestServiceMockGetMailingListByID {
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Expect(ctx context.Context, requestID uuid.UUID, userID int) *mRequestServiceMockGetMailingListByID {
if mmGetMailingListByID.mock.funcGetMailingListByID != nil {
mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set")
}
@@ -1270,7 +1273,7 @@ func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Expect(ctx co
mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by ExpectParams functions")
}
mmGetMailingListByID.defaultExpectation.params = &RequestServiceMockGetMailingListByIDParams{ctx, requestID}
mmGetMailingListByID.defaultExpectation.params = &RequestServiceMockGetMailingListByIDParams{ctx, requestID, userID}
mmGetMailingListByID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmGetMailingListByID.expectations {
if minimock.Equal(e.params, mmGetMailingListByID.defaultExpectation.params) {
@@ -1327,8 +1330,31 @@ func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) ExpectRequest
return mmGetMailingListByID
}
// ExpectUserIDParam3 sets up expected param userID for RequestService.GetMailingListByID
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) ExpectUserIDParam3(userID int) *mRequestServiceMockGetMailingListByID {
if mmGetMailingListByID.mock.funcGetMailingListByID != nil {
mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set")
}
if mmGetMailingListByID.defaultExpectation == nil {
mmGetMailingListByID.defaultExpectation = &RequestServiceMockGetMailingListByIDExpectation{}
}
if mmGetMailingListByID.defaultExpectation.params != nil {
mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Expect")
}
if mmGetMailingListByID.defaultExpectation.paramPtrs == nil {
mmGetMailingListByID.defaultExpectation.paramPtrs = &RequestServiceMockGetMailingListByIDParamPtrs{}
}
mmGetMailingListByID.defaultExpectation.paramPtrs.userID = &userID
mmGetMailingListByID.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1)
return mmGetMailingListByID
}
// Inspect accepts an inspector function that has same arguments as the RequestService.GetMailingListByID
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Inspect(f func(ctx context.Context, requestID uuid.UUID)) *mRequestServiceMockGetMailingListByID {
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Inspect(f func(ctx context.Context, requestID uuid.UUID, userID int)) *mRequestServiceMockGetMailingListByID {
if mmGetMailingListByID.mock.inspectFuncGetMailingListByID != nil {
mmGetMailingListByID.mock.t.Fatalf("Inspect function is already set for RequestServiceMock.GetMailingListByID")
}
@@ -1353,7 +1379,7 @@ func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Return(rp1 *m
}
// Set uses given function f to mock the RequestService.GetMailingListByID method
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Set(f func(ctx context.Context, requestID uuid.UUID) (rp1 *model.RequestDetail, err error)) *RequestServiceMock {
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Set(f func(ctx context.Context, requestID uuid.UUID, userID int) (rp1 *model.RequestDetail, err error)) *RequestServiceMock {
if mmGetMailingListByID.defaultExpectation != nil {
mmGetMailingListByID.mock.t.Fatalf("Default expectation is already set for the RequestService.GetMailingListByID method")
}
@@ -1369,14 +1395,14 @@ func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Set(f func(ct
// When sets expectation for the RequestService.GetMailingListByID which will trigger the result defined by the following
// Then helper
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) When(ctx context.Context, requestID uuid.UUID) *RequestServiceMockGetMailingListByIDExpectation {
func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) When(ctx context.Context, requestID uuid.UUID, userID int) *RequestServiceMockGetMailingListByIDExpectation {
if mmGetMailingListByID.mock.funcGetMailingListByID != nil {
mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set")
}
expectation := &RequestServiceMockGetMailingListByIDExpectation{
mock: mmGetMailingListByID.mock,
params: &RequestServiceMockGetMailingListByIDParams{ctx, requestID},
params: &RequestServiceMockGetMailingListByIDParams{ctx, requestID, userID},
expectationOrigins: RequestServiceMockGetMailingListByIDExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmGetMailingListByID.expectations = append(mmGetMailingListByID.expectations, expectation)
@@ -1411,17 +1437,17 @@ func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) invocationsDo
}
// GetMailingListByID implements mm_service.RequestService
func (mmGetMailingListByID *RequestServiceMock) GetMailingListByID(ctx context.Context, requestID uuid.UUID) (rp1 *model.RequestDetail, err error) {
func (mmGetMailingListByID *RequestServiceMock) GetMailingListByID(ctx context.Context, requestID uuid.UUID, userID int) (rp1 *model.RequestDetail, err error) {
mm_atomic.AddUint64(&mmGetMailingListByID.beforeGetMailingListByIDCounter, 1)
defer mm_atomic.AddUint64(&mmGetMailingListByID.afterGetMailingListByIDCounter, 1)
mmGetMailingListByID.t.Helper()
if mmGetMailingListByID.inspectFuncGetMailingListByID != nil {
mmGetMailingListByID.inspectFuncGetMailingListByID(ctx, requestID)
mmGetMailingListByID.inspectFuncGetMailingListByID(ctx, requestID, userID)
}
mm_params := RequestServiceMockGetMailingListByIDParams{ctx, requestID}
mm_params := RequestServiceMockGetMailingListByIDParams{ctx, requestID, userID}
// Record call args
mmGetMailingListByID.GetMailingListByIDMock.mutex.Lock()
@@ -1440,7 +1466,7 @@ func (mmGetMailingListByID *RequestServiceMock) GetMailingListByID(ctx context.C
mm_want := mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.params
mm_want_ptrs := mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.paramPtrs
mm_got := RequestServiceMockGetMailingListByIDParams{ctx, requestID}
mm_got := RequestServiceMockGetMailingListByIDParams{ctx, requestID, userID}
if mm_want_ptrs != nil {
@@ -1454,6 +1480,11 @@ func (mmGetMailingListByID *RequestServiceMock) GetMailingListByID(ctx context.C
mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID))
}
if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) {
mmGetMailingListByID.t.Errorf("RequestServiceMock.GetMailingListByID got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmGetMailingListByID.GetMailingListByIDMock.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) {
mmGetMailingListByID.t.Errorf("RequestServiceMock.GetMailingListByID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
@@ -1466,9 +1497,9 @@ func (mmGetMailingListByID *RequestServiceMock) GetMailingListByID(ctx context.C
return (*mm_results).rp1, (*mm_results).err
}
if mmGetMailingListByID.funcGetMailingListByID != nil {
return mmGetMailingListByID.funcGetMailingListByID(ctx, requestID)
return mmGetMailingListByID.funcGetMailingListByID(ctx, requestID, userID)
}
mmGetMailingListByID.t.Fatalf("Unexpected call to RequestServiceMock.GetMailingListByID. %v %v", ctx, requestID)
mmGetMailingListByID.t.Fatalf("Unexpected call to RequestServiceMock.GetMailingListByID. %v %v %v", ctx, requestID, userID)
return
}

View File

@@ -19,9 +19,9 @@ type SupplierServiceMock struct {
t minimock.Tester
finishOnce sync.Once
funcExportExcel func(ctx context.Context, requestID uuid.UUID) (ba1 []byte, err error)
funcExportExcel func(ctx context.Context, requestID uuid.UUID, userID int) (ba1 []byte, err error)
funcExportExcelOrigin string
inspectFuncExportExcel func(ctx context.Context, requestID uuid.UUID)
inspectFuncExportExcel func(ctx context.Context, requestID uuid.UUID, userID int)
afterExportExcelCounter uint64
beforeExportExcelCounter uint64
ExportExcelMock mSupplierServiceMockExportExcel
@@ -71,12 +71,14 @@ type SupplierServiceMockExportExcelExpectation struct {
type SupplierServiceMockExportExcelParams struct {
ctx context.Context
requestID uuid.UUID
userID int
}
// SupplierServiceMockExportExcelParamPtrs contains pointers to parameters of the SupplierService.ExportExcel
type SupplierServiceMockExportExcelParamPtrs struct {
ctx *context.Context
requestID *uuid.UUID
userID *int
}
// SupplierServiceMockExportExcelResults contains results of the SupplierService.ExportExcel
@@ -90,6 +92,7 @@ type SupplierServiceMockExportExcelExpectationOrigins struct {
origin string
originCtx string
originRequestID string
originUserID string
}
// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
@@ -103,7 +106,7 @@ func (mmExportExcel *mSupplierServiceMockExportExcel) Optional() *mSupplierServi
}
// Expect sets up expected params for SupplierService.ExportExcel
func (mmExportExcel *mSupplierServiceMockExportExcel) Expect(ctx context.Context, requestID uuid.UUID) *mSupplierServiceMockExportExcel {
func (mmExportExcel *mSupplierServiceMockExportExcel) Expect(ctx context.Context, requestID uuid.UUID, userID int) *mSupplierServiceMockExportExcel {
if mmExportExcel.mock.funcExportExcel != nil {
mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set")
}
@@ -116,7 +119,7 @@ func (mmExportExcel *mSupplierServiceMockExportExcel) Expect(ctx context.Context
mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by ExpectParams functions")
}
mmExportExcel.defaultExpectation.params = &SupplierServiceMockExportExcelParams{ctx, requestID}
mmExportExcel.defaultExpectation.params = &SupplierServiceMockExportExcelParams{ctx, requestID, userID}
mmExportExcel.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmExportExcel.expectations {
if minimock.Equal(e.params, mmExportExcel.defaultExpectation.params) {
@@ -173,8 +176,31 @@ func (mmExportExcel *mSupplierServiceMockExportExcel) ExpectRequestIDParam2(requ
return mmExportExcel
}
// ExpectUserIDParam3 sets up expected param userID for SupplierService.ExportExcel
func (mmExportExcel *mSupplierServiceMockExportExcel) ExpectUserIDParam3(userID int) *mSupplierServiceMockExportExcel {
if mmExportExcel.mock.funcExportExcel != nil {
mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set")
}
if mmExportExcel.defaultExpectation == nil {
mmExportExcel.defaultExpectation = &SupplierServiceMockExportExcelExpectation{}
}
if mmExportExcel.defaultExpectation.params != nil {
mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Expect")
}
if mmExportExcel.defaultExpectation.paramPtrs == nil {
mmExportExcel.defaultExpectation.paramPtrs = &SupplierServiceMockExportExcelParamPtrs{}
}
mmExportExcel.defaultExpectation.paramPtrs.userID = &userID
mmExportExcel.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1)
return mmExportExcel
}
// Inspect accepts an inspector function that has same arguments as the SupplierService.ExportExcel
func (mmExportExcel *mSupplierServiceMockExportExcel) Inspect(f func(ctx context.Context, requestID uuid.UUID)) *mSupplierServiceMockExportExcel {
func (mmExportExcel *mSupplierServiceMockExportExcel) Inspect(f func(ctx context.Context, requestID uuid.UUID, userID int)) *mSupplierServiceMockExportExcel {
if mmExportExcel.mock.inspectFuncExportExcel != nil {
mmExportExcel.mock.t.Fatalf("Inspect function is already set for SupplierServiceMock.ExportExcel")
}
@@ -199,7 +225,7 @@ func (mmExportExcel *mSupplierServiceMockExportExcel) Return(ba1 []byte, err err
}
// Set uses given function f to mock the SupplierService.ExportExcel method
func (mmExportExcel *mSupplierServiceMockExportExcel) Set(f func(ctx context.Context, requestID uuid.UUID) (ba1 []byte, err error)) *SupplierServiceMock {
func (mmExportExcel *mSupplierServiceMockExportExcel) Set(f func(ctx context.Context, requestID uuid.UUID, userID int) (ba1 []byte, err error)) *SupplierServiceMock {
if mmExportExcel.defaultExpectation != nil {
mmExportExcel.mock.t.Fatalf("Default expectation is already set for the SupplierService.ExportExcel method")
}
@@ -215,14 +241,14 @@ func (mmExportExcel *mSupplierServiceMockExportExcel) Set(f func(ctx context.Con
// When sets expectation for the SupplierService.ExportExcel which will trigger the result defined by the following
// Then helper
func (mmExportExcel *mSupplierServiceMockExportExcel) When(ctx context.Context, requestID uuid.UUID) *SupplierServiceMockExportExcelExpectation {
func (mmExportExcel *mSupplierServiceMockExportExcel) When(ctx context.Context, requestID uuid.UUID, userID int) *SupplierServiceMockExportExcelExpectation {
if mmExportExcel.mock.funcExportExcel != nil {
mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set")
}
expectation := &SupplierServiceMockExportExcelExpectation{
mock: mmExportExcel.mock,
params: &SupplierServiceMockExportExcelParams{ctx, requestID},
params: &SupplierServiceMockExportExcelParams{ctx, requestID, userID},
expectationOrigins: SupplierServiceMockExportExcelExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmExportExcel.expectations = append(mmExportExcel.expectations, expectation)
@@ -257,17 +283,17 @@ func (mmExportExcel *mSupplierServiceMockExportExcel) invocationsDone() bool {
}
// ExportExcel implements mm_service.SupplierService
func (mmExportExcel *SupplierServiceMock) ExportExcel(ctx context.Context, requestID uuid.UUID) (ba1 []byte, err error) {
func (mmExportExcel *SupplierServiceMock) ExportExcel(ctx context.Context, requestID uuid.UUID, userID int) (ba1 []byte, err error) {
mm_atomic.AddUint64(&mmExportExcel.beforeExportExcelCounter, 1)
defer mm_atomic.AddUint64(&mmExportExcel.afterExportExcelCounter, 1)
mmExportExcel.t.Helper()
if mmExportExcel.inspectFuncExportExcel != nil {
mmExportExcel.inspectFuncExportExcel(ctx, requestID)
mmExportExcel.inspectFuncExportExcel(ctx, requestID, userID)
}
mm_params := SupplierServiceMockExportExcelParams{ctx, requestID}
mm_params := SupplierServiceMockExportExcelParams{ctx, requestID, userID}
// Record call args
mmExportExcel.ExportExcelMock.mutex.Lock()
@@ -286,7 +312,7 @@ func (mmExportExcel *SupplierServiceMock) ExportExcel(ctx context.Context, reque
mm_want := mmExportExcel.ExportExcelMock.defaultExpectation.params
mm_want_ptrs := mmExportExcel.ExportExcelMock.defaultExpectation.paramPtrs
mm_got := SupplierServiceMockExportExcelParams{ctx, requestID}
mm_got := SupplierServiceMockExportExcelParams{ctx, requestID, userID}
if mm_want_ptrs != nil {
@@ -300,6 +326,11 @@ func (mmExportExcel *SupplierServiceMock) ExportExcel(ctx context.Context, reque
mmExportExcel.ExportExcelMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID))
}
if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) {
mmExportExcel.t.Errorf("SupplierServiceMock.ExportExcel got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmExportExcel.ExportExcelMock.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) {
mmExportExcel.t.Errorf("SupplierServiceMock.ExportExcel got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmExportExcel.ExportExcelMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
@@ -312,9 +343,9 @@ func (mmExportExcel *SupplierServiceMock) ExportExcel(ctx context.Context, reque
return (*mm_results).ba1, (*mm_results).err
}
if mmExportExcel.funcExportExcel != nil {
return mmExportExcel.funcExportExcel(ctx, requestID)
return mmExportExcel.funcExportExcel(ctx, requestID, userID)
}
mmExportExcel.t.Fatalf("Unexpected call to SupplierServiceMock.ExportExcel. %v %v", ctx, requestID)
mmExportExcel.t.Fatalf("Unexpected call to SupplierServiceMock.ExportExcel. %v %v %v", ctx, requestID, userID)
return
}