|
@@ -1,2113 +0,0 @@
|
|
-package mocks
|
|
|
|
-
|
|
|
|
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
|
|
|
|
-
|
|
|
|
-//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.ITagRepository -o ./mocks/i_tag_repository_minimock.go -n ITagRepositoryMock
|
|
|
|
-
|
|
|
|
-import (
|
|
|
|
- "context"
|
|
|
|
- "sync"
|
|
|
|
- mm_atomic "sync/atomic"
|
|
|
|
- mm_time "time"
|
|
|
|
-
|
|
|
|
- "github.com/dmitriygnatenko/internal/models"
|
|
|
|
- "github.com/gojuno/minimock/v3"
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMock implements interfaces.ITagRepository
|
|
|
|
-type ITagRepositoryMock struct {
|
|
|
|
- t minimock.Tester
|
|
|
|
-
|
|
|
|
- funcAdd func(ctx context.Context, m models.Tag) (err error)
|
|
|
|
- inspectFuncAdd func(ctx context.Context, m models.Tag)
|
|
|
|
- afterAddCounter uint64
|
|
|
|
- beforeAddCounter uint64
|
|
|
|
- AddMock mITagRepositoryMockAdd
|
|
|
|
-
|
|
|
|
- funcDelete func(ctx context.Context, ID int) (err error)
|
|
|
|
- inspectFuncDelete func(ctx context.Context, ID int)
|
|
|
|
- afterDeleteCounter uint64
|
|
|
|
- beforeDeleteCounter uint64
|
|
|
|
- DeleteMock mITagRepositoryMockDelete
|
|
|
|
-
|
|
|
|
- funcGetAll func(ctx context.Context) (ta1 []models.Tag, err error)
|
|
|
|
- inspectFuncGetAll func(ctx context.Context)
|
|
|
|
- afterGetAllCounter uint64
|
|
|
|
- beforeGetAllCounter uint64
|
|
|
|
- GetAllMock mITagRepositoryMockGetAll
|
|
|
|
-
|
|
|
|
- funcGetAllUsed func(ctx context.Context) (ta1 []models.Tag, err error)
|
|
|
|
- inspectFuncGetAllUsed func(ctx context.Context)
|
|
|
|
- afterGetAllUsedCounter uint64
|
|
|
|
- beforeGetAllUsedCounter uint64
|
|
|
|
- GetAllUsedMock mITagRepositoryMockGetAllUsed
|
|
|
|
-
|
|
|
|
- funcGetByArticleID func(ctx context.Context, ID int) (ta1 []models.Tag, err error)
|
|
|
|
- inspectFuncGetByArticleID func(ctx context.Context, ID int)
|
|
|
|
- afterGetByArticleIDCounter uint64
|
|
|
|
- beforeGetByArticleIDCounter uint64
|
|
|
|
- GetByArticleIDMock mITagRepositoryMockGetByArticleID
|
|
|
|
-
|
|
|
|
- funcGetByID func(ctx context.Context, ID int) (tp1 *models.Tag, err error)
|
|
|
|
- inspectFuncGetByID func(ctx context.Context, ID int)
|
|
|
|
- afterGetByIDCounter uint64
|
|
|
|
- beforeGetByIDCounter uint64
|
|
|
|
- GetByIDMock mITagRepositoryMockGetByID
|
|
|
|
-
|
|
|
|
- funcGetByURL func(ctx context.Context, tag string) (tp1 *models.Tag, err error)
|
|
|
|
- inspectFuncGetByURL func(ctx context.Context, tag string)
|
|
|
|
- afterGetByURLCounter uint64
|
|
|
|
- beforeGetByURLCounter uint64
|
|
|
|
- GetByURLMock mITagRepositoryMockGetByURL
|
|
|
|
-
|
|
|
|
- funcIsUsed func(ctx context.Context, ID int) (b1 bool, err error)
|
|
|
|
- inspectFuncIsUsed func(ctx context.Context, ID int)
|
|
|
|
- afterIsUsedCounter uint64
|
|
|
|
- beforeIsUsedCounter uint64
|
|
|
|
- IsUsedMock mITagRepositoryMockIsUsed
|
|
|
|
-
|
|
|
|
- funcUpdate func(ctx context.Context, m models.Tag) (err error)
|
|
|
|
- inspectFuncUpdate func(ctx context.Context, m models.Tag)
|
|
|
|
- afterUpdateCounter uint64
|
|
|
|
- beforeUpdateCounter uint64
|
|
|
|
- UpdateMock mITagRepositoryMockUpdate
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// NewITagRepositoryMock returns a mock for interfaces.ITagRepository
|
|
|
|
-func NewITagRepositoryMock(t minimock.Tester) *ITagRepositoryMock {
|
|
|
|
- m := &ITagRepositoryMock{t: t}
|
|
|
|
- if controller, ok := t.(minimock.MockController); ok {
|
|
|
|
- controller.RegisterMocker(m)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- m.AddMock = mITagRepositoryMockAdd{mock: m}
|
|
|
|
- m.AddMock.callArgs = []*ITagRepositoryMockAddParams{}
|
|
|
|
-
|
|
|
|
- m.DeleteMock = mITagRepositoryMockDelete{mock: m}
|
|
|
|
- m.DeleteMock.callArgs = []*ITagRepositoryMockDeleteParams{}
|
|
|
|
-
|
|
|
|
- m.GetAllMock = mITagRepositoryMockGetAll{mock: m}
|
|
|
|
- m.GetAllMock.callArgs = []*ITagRepositoryMockGetAllParams{}
|
|
|
|
-
|
|
|
|
- m.GetAllUsedMock = mITagRepositoryMockGetAllUsed{mock: m}
|
|
|
|
- m.GetAllUsedMock.callArgs = []*ITagRepositoryMockGetAllUsedParams{}
|
|
|
|
-
|
|
|
|
- m.GetByArticleIDMock = mITagRepositoryMockGetByArticleID{mock: m}
|
|
|
|
- m.GetByArticleIDMock.callArgs = []*ITagRepositoryMockGetByArticleIDParams{}
|
|
|
|
-
|
|
|
|
- m.GetByIDMock = mITagRepositoryMockGetByID{mock: m}
|
|
|
|
- m.GetByIDMock.callArgs = []*ITagRepositoryMockGetByIDParams{}
|
|
|
|
-
|
|
|
|
- m.GetByURLMock = mITagRepositoryMockGetByURL{mock: m}
|
|
|
|
- m.GetByURLMock.callArgs = []*ITagRepositoryMockGetByURLParams{}
|
|
|
|
-
|
|
|
|
- m.IsUsedMock = mITagRepositoryMockIsUsed{mock: m}
|
|
|
|
- m.IsUsedMock.callArgs = []*ITagRepositoryMockIsUsedParams{}
|
|
|
|
-
|
|
|
|
- m.UpdateMock = mITagRepositoryMockUpdate{mock: m}
|
|
|
|
- m.UpdateMock.callArgs = []*ITagRepositoryMockUpdateParams{}
|
|
|
|
-
|
|
|
|
- return m
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockAdd struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockAddExpectation
|
|
|
|
- expectations []*ITagRepositoryMockAddExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockAddParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockAddExpectation specifies expectation struct of the ITagRepository.Add
|
|
|
|
-type ITagRepositoryMockAddExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockAddParams
|
|
|
|
- results *ITagRepositoryMockAddResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockAddParams contains parameters of the ITagRepository.Add
|
|
|
|
-type ITagRepositoryMockAddParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
- m models.Tag
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockAddResults contains results of the ITagRepository.Add
|
|
|
|
-type ITagRepositoryMockAddResults struct {
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.Add
|
|
|
|
-func (mmAdd *mITagRepositoryMockAdd) Expect(ctx context.Context, m models.Tag) *mITagRepositoryMockAdd {
|
|
|
|
- if mmAdd.mock.funcAdd != nil {
|
|
|
|
- mmAdd.mock.t.Fatalf("ITagRepositoryMock.Add mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmAdd.defaultExpectation == nil {
|
|
|
|
- mmAdd.defaultExpectation = &ITagRepositoryMockAddExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmAdd.defaultExpectation.params = &ITagRepositoryMockAddParams{ctx, m}
|
|
|
|
- for _, e := range mmAdd.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
|
|
|
|
- mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmAdd
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.Add
|
|
|
|
-func (mmAdd *mITagRepositoryMockAdd) Inspect(f func(ctx context.Context, m models.Tag)) *mITagRepositoryMockAdd {
|
|
|
|
- if mmAdd.mock.inspectFuncAdd != nil {
|
|
|
|
- mmAdd.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.Add")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmAdd.mock.inspectFuncAdd = f
|
|
|
|
-
|
|
|
|
- return mmAdd
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.Add
|
|
|
|
-func (mmAdd *mITagRepositoryMockAdd) Return(err error) *ITagRepositoryMock {
|
|
|
|
- if mmAdd.mock.funcAdd != nil {
|
|
|
|
- mmAdd.mock.t.Fatalf("ITagRepositoryMock.Add mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmAdd.defaultExpectation == nil {
|
|
|
|
- mmAdd.defaultExpectation = &ITagRepositoryMockAddExpectation{mock: mmAdd.mock}
|
|
|
|
- }
|
|
|
|
- mmAdd.defaultExpectation.results = &ITagRepositoryMockAddResults{err}
|
|
|
|
- return mmAdd.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.Add method
|
|
|
|
-func (mmAdd *mITagRepositoryMockAdd) Set(f func(ctx context.Context, m models.Tag) (err error)) *ITagRepositoryMock {
|
|
|
|
- if mmAdd.defaultExpectation != nil {
|
|
|
|
- mmAdd.mock.t.Fatalf("Default expectation is already set for the ITagRepository.Add method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmAdd.expectations) > 0 {
|
|
|
|
- mmAdd.mock.t.Fatalf("Some expectations are already set for the ITagRepository.Add method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmAdd.mock.funcAdd = f
|
|
|
|
- return mmAdd.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.Add which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmAdd *mITagRepositoryMockAdd) When(ctx context.Context, m models.Tag) *ITagRepositoryMockAddExpectation {
|
|
|
|
- if mmAdd.mock.funcAdd != nil {
|
|
|
|
- mmAdd.mock.t.Fatalf("ITagRepositoryMock.Add mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockAddExpectation{
|
|
|
|
- mock: mmAdd.mock,
|
|
|
|
- params: &ITagRepositoryMockAddParams{ctx, m},
|
|
|
|
- }
|
|
|
|
- mmAdd.expectations = append(mmAdd.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.Add return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockAddExpectation) Then(err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockAddResults{err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Add implements interfaces.ITagRepository
|
|
|
|
-func (mmAdd *ITagRepositoryMock) Add(ctx context.Context, m models.Tag) (err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmAdd.inspectFuncAdd != nil {
|
|
|
|
- mmAdd.inspectFuncAdd(ctx, m)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockAddParams{ctx, m}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmAdd.AddMock.mutex.Lock()
|
|
|
|
- mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
|
|
|
|
- mmAdd.AddMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmAdd.AddMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmAdd.AddMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmAdd.AddMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockAddParams{ctx, m}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmAdd.t.Errorf("ITagRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmAdd.AddMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmAdd.t.Fatal("No results are set for the ITagRepositoryMock.Add")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmAdd.funcAdd != nil {
|
|
|
|
- return mmAdd.funcAdd(ctx, m)
|
|
|
|
- }
|
|
|
|
- mmAdd.t.Fatalf("Unexpected call to ITagRepositoryMock.Add. %v %v", ctx, m)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// AddAfterCounter returns a count of finished ITagRepositoryMock.Add invocations
|
|
|
|
-func (mmAdd *ITagRepositoryMock) AddAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// AddBeforeCounter returns a count of ITagRepositoryMock.Add invocations
|
|
|
|
-func (mmAdd *ITagRepositoryMock) AddBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.Add.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmAdd *mITagRepositoryMockAdd) Calls() []*ITagRepositoryMockAddParams {
|
|
|
|
- mmAdd.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockAddParams, len(mmAdd.callArgs))
|
|
|
|
- copy(argCopy, mmAdd.callArgs)
|
|
|
|
-
|
|
|
|
- mmAdd.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockAddDone returns true if the count of the Add invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockAddDone() bool {
|
|
|
|
- for _, e := range m.AddMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockAddInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockAddInspect() {
|
|
|
|
- for _, e := range m.AddMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.Add with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
|
|
|
|
- if m.AddMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.Add")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.Add")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockDelete struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockDeleteExpectation
|
|
|
|
- expectations []*ITagRepositoryMockDeleteExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockDeleteParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockDeleteExpectation specifies expectation struct of the ITagRepository.Delete
|
|
|
|
-type ITagRepositoryMockDeleteExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockDeleteParams
|
|
|
|
- results *ITagRepositoryMockDeleteResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockDeleteParams contains parameters of the ITagRepository.Delete
|
|
|
|
-type ITagRepositoryMockDeleteParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
- ID int
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockDeleteResults contains results of the ITagRepository.Delete
|
|
|
|
-type ITagRepositoryMockDeleteResults struct {
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.Delete
|
|
|
|
-func (mmDelete *mITagRepositoryMockDelete) Expect(ctx context.Context, ID int) *mITagRepositoryMockDelete {
|
|
|
|
- if mmDelete.mock.funcDelete != nil {
|
|
|
|
- mmDelete.mock.t.Fatalf("ITagRepositoryMock.Delete mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmDelete.defaultExpectation == nil {
|
|
|
|
- mmDelete.defaultExpectation = &ITagRepositoryMockDeleteExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmDelete.defaultExpectation.params = &ITagRepositoryMockDeleteParams{ctx, ID}
|
|
|
|
- for _, e := range mmDelete.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
|
|
|
|
- mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmDelete
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.Delete
|
|
|
|
-func (mmDelete *mITagRepositoryMockDelete) Inspect(f func(ctx context.Context, ID int)) *mITagRepositoryMockDelete {
|
|
|
|
- if mmDelete.mock.inspectFuncDelete != nil {
|
|
|
|
- mmDelete.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.Delete")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmDelete.mock.inspectFuncDelete = f
|
|
|
|
-
|
|
|
|
- return mmDelete
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.Delete
|
|
|
|
-func (mmDelete *mITagRepositoryMockDelete) Return(err error) *ITagRepositoryMock {
|
|
|
|
- if mmDelete.mock.funcDelete != nil {
|
|
|
|
- mmDelete.mock.t.Fatalf("ITagRepositoryMock.Delete mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmDelete.defaultExpectation == nil {
|
|
|
|
- mmDelete.defaultExpectation = &ITagRepositoryMockDeleteExpectation{mock: mmDelete.mock}
|
|
|
|
- }
|
|
|
|
- mmDelete.defaultExpectation.results = &ITagRepositoryMockDeleteResults{err}
|
|
|
|
- return mmDelete.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.Delete method
|
|
|
|
-func (mmDelete *mITagRepositoryMockDelete) Set(f func(ctx context.Context, ID int) (err error)) *ITagRepositoryMock {
|
|
|
|
- if mmDelete.defaultExpectation != nil {
|
|
|
|
- mmDelete.mock.t.Fatalf("Default expectation is already set for the ITagRepository.Delete method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmDelete.expectations) > 0 {
|
|
|
|
- mmDelete.mock.t.Fatalf("Some expectations are already set for the ITagRepository.Delete method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmDelete.mock.funcDelete = f
|
|
|
|
- return mmDelete.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.Delete which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmDelete *mITagRepositoryMockDelete) When(ctx context.Context, ID int) *ITagRepositoryMockDeleteExpectation {
|
|
|
|
- if mmDelete.mock.funcDelete != nil {
|
|
|
|
- mmDelete.mock.t.Fatalf("ITagRepositoryMock.Delete mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockDeleteExpectation{
|
|
|
|
- mock: mmDelete.mock,
|
|
|
|
- params: &ITagRepositoryMockDeleteParams{ctx, ID},
|
|
|
|
- }
|
|
|
|
- mmDelete.expectations = append(mmDelete.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.Delete return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockDeleteExpectation) Then(err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockDeleteResults{err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Delete implements interfaces.ITagRepository
|
|
|
|
-func (mmDelete *ITagRepositoryMock) Delete(ctx context.Context, ID int) (err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmDelete.inspectFuncDelete != nil {
|
|
|
|
- mmDelete.inspectFuncDelete(ctx, ID)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockDeleteParams{ctx, ID}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmDelete.DeleteMock.mutex.Lock()
|
|
|
|
- mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, mm_params)
|
|
|
|
- mmDelete.DeleteMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmDelete.DeleteMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmDelete.DeleteMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmDelete.DeleteMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockDeleteParams{ctx, ID}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmDelete.t.Errorf("ITagRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmDelete.DeleteMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmDelete.t.Fatal("No results are set for the ITagRepositoryMock.Delete")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmDelete.funcDelete != nil {
|
|
|
|
- return mmDelete.funcDelete(ctx, ID)
|
|
|
|
- }
|
|
|
|
- mmDelete.t.Fatalf("Unexpected call to ITagRepositoryMock.Delete. %v %v", ctx, ID)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// DeleteAfterCounter returns a count of finished ITagRepositoryMock.Delete invocations
|
|
|
|
-func (mmDelete *ITagRepositoryMock) DeleteAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// DeleteBeforeCounter returns a count of ITagRepositoryMock.Delete invocations
|
|
|
|
-func (mmDelete *ITagRepositoryMock) DeleteBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.Delete.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmDelete *mITagRepositoryMockDelete) Calls() []*ITagRepositoryMockDeleteParams {
|
|
|
|
- mmDelete.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockDeleteParams, len(mmDelete.callArgs))
|
|
|
|
- copy(argCopy, mmDelete.callArgs)
|
|
|
|
-
|
|
|
|
- mmDelete.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockDeleteDone returns true if the count of the Delete invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockDeleteDone() bool {
|
|
|
|
- for _, e := range m.DeleteMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockDeleteInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockDeleteInspect() {
|
|
|
|
- for _, e := range m.DeleteMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.Delete with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
|
|
|
|
- if m.DeleteMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.Delete")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.Delete")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockGetAll struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockGetAllExpectation
|
|
|
|
- expectations []*ITagRepositoryMockGetAllExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockGetAllParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetAllExpectation specifies expectation struct of the ITagRepository.GetAll
|
|
|
|
-type ITagRepositoryMockGetAllExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockGetAllParams
|
|
|
|
- results *ITagRepositoryMockGetAllResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetAllParams contains parameters of the ITagRepository.GetAll
|
|
|
|
-type ITagRepositoryMockGetAllParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetAllResults contains results of the ITagRepository.GetAll
|
|
|
|
-type ITagRepositoryMockGetAllResults struct {
|
|
|
|
- ta1 []models.Tag
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.GetAll
|
|
|
|
-func (mmGetAll *mITagRepositoryMockGetAll) Expect(ctx context.Context) *mITagRepositoryMockGetAll {
|
|
|
|
- if mmGetAll.mock.funcGetAll != nil {
|
|
|
|
- mmGetAll.mock.t.Fatalf("ITagRepositoryMock.GetAll mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetAll.defaultExpectation == nil {
|
|
|
|
- mmGetAll.defaultExpectation = &ITagRepositoryMockGetAllExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetAll.defaultExpectation.params = &ITagRepositoryMockGetAllParams{ctx}
|
|
|
|
- for _, e := range mmGetAll.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmGetAll.defaultExpectation.params) {
|
|
|
|
- mmGetAll.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAll.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmGetAll
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.GetAll
|
|
|
|
-func (mmGetAll *mITagRepositoryMockGetAll) Inspect(f func(ctx context.Context)) *mITagRepositoryMockGetAll {
|
|
|
|
- if mmGetAll.mock.inspectFuncGetAll != nil {
|
|
|
|
- mmGetAll.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.GetAll")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetAll.mock.inspectFuncGetAll = f
|
|
|
|
-
|
|
|
|
- return mmGetAll
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.GetAll
|
|
|
|
-func (mmGetAll *mITagRepositoryMockGetAll) Return(ta1 []models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- if mmGetAll.mock.funcGetAll != nil {
|
|
|
|
- mmGetAll.mock.t.Fatalf("ITagRepositoryMock.GetAll mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetAll.defaultExpectation == nil {
|
|
|
|
- mmGetAll.defaultExpectation = &ITagRepositoryMockGetAllExpectation{mock: mmGetAll.mock}
|
|
|
|
- }
|
|
|
|
- mmGetAll.defaultExpectation.results = &ITagRepositoryMockGetAllResults{ta1, err}
|
|
|
|
- return mmGetAll.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.GetAll method
|
|
|
|
-func (mmGetAll *mITagRepositoryMockGetAll) Set(f func(ctx context.Context) (ta1 []models.Tag, err error)) *ITagRepositoryMock {
|
|
|
|
- if mmGetAll.defaultExpectation != nil {
|
|
|
|
- mmGetAll.mock.t.Fatalf("Default expectation is already set for the ITagRepository.GetAll method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmGetAll.expectations) > 0 {
|
|
|
|
- mmGetAll.mock.t.Fatalf("Some expectations are already set for the ITagRepository.GetAll method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetAll.mock.funcGetAll = f
|
|
|
|
- return mmGetAll.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.GetAll which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmGetAll *mITagRepositoryMockGetAll) When(ctx context.Context) *ITagRepositoryMockGetAllExpectation {
|
|
|
|
- if mmGetAll.mock.funcGetAll != nil {
|
|
|
|
- mmGetAll.mock.t.Fatalf("ITagRepositoryMock.GetAll mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockGetAllExpectation{
|
|
|
|
- mock: mmGetAll.mock,
|
|
|
|
- params: &ITagRepositoryMockGetAllParams{ctx},
|
|
|
|
- }
|
|
|
|
- mmGetAll.expectations = append(mmGetAll.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.GetAll return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockGetAllExpectation) Then(ta1 []models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockGetAllResults{ta1, err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetAll implements interfaces.ITagRepository
|
|
|
|
-func (mmGetAll *ITagRepositoryMock) GetAll(ctx context.Context) (ta1 []models.Tag, err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmGetAll.beforeGetAllCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmGetAll.afterGetAllCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmGetAll.inspectFuncGetAll != nil {
|
|
|
|
- mmGetAll.inspectFuncGetAll(ctx)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockGetAllParams{ctx}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmGetAll.GetAllMock.mutex.Lock()
|
|
|
|
- mmGetAll.GetAllMock.callArgs = append(mmGetAll.GetAllMock.callArgs, mm_params)
|
|
|
|
- mmGetAll.GetAllMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmGetAll.GetAllMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.ta1, e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetAll.GetAllMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmGetAll.GetAllMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmGetAll.GetAllMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockGetAllParams{ctx}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmGetAll.t.Errorf("ITagRepositoryMock.GetAll got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmGetAll.GetAllMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmGetAll.t.Fatal("No results are set for the ITagRepositoryMock.GetAll")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).ta1, (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmGetAll.funcGetAll != nil {
|
|
|
|
- return mmGetAll.funcGetAll(ctx)
|
|
|
|
- }
|
|
|
|
- mmGetAll.t.Fatalf("Unexpected call to ITagRepositoryMock.GetAll. %v", ctx)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetAllAfterCounter returns a count of finished ITagRepositoryMock.GetAll invocations
|
|
|
|
-func (mmGetAll *ITagRepositoryMock) GetAllAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetAllBeforeCounter returns a count of ITagRepositoryMock.GetAll invocations
|
|
|
|
-func (mmGetAll *ITagRepositoryMock) GetAllBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.GetAll.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmGetAll *mITagRepositoryMockGetAll) Calls() []*ITagRepositoryMockGetAllParams {
|
|
|
|
- mmGetAll.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockGetAllParams, len(mmGetAll.callArgs))
|
|
|
|
- copy(argCopy, mmGetAll.callArgs)
|
|
|
|
-
|
|
|
|
- mmGetAll.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetAllDone returns true if the count of the GetAll invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetAllDone() bool {
|
|
|
|
- for _, e := range m.GetAllMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetAllInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetAllInspect() {
|
|
|
|
- for _, e := range m.GetAllMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetAll with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
|
|
|
|
- if m.GetAllMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetAll")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetAll with params: %#v", *m.GetAllMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetAll")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockGetAllUsed struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockGetAllUsedExpectation
|
|
|
|
- expectations []*ITagRepositoryMockGetAllUsedExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockGetAllUsedParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetAllUsedExpectation specifies expectation struct of the ITagRepository.GetAllUsed
|
|
|
|
-type ITagRepositoryMockGetAllUsedExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockGetAllUsedParams
|
|
|
|
- results *ITagRepositoryMockGetAllUsedResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetAllUsedParams contains parameters of the ITagRepository.GetAllUsed
|
|
|
|
-type ITagRepositoryMockGetAllUsedParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetAllUsedResults contains results of the ITagRepository.GetAllUsed
|
|
|
|
-type ITagRepositoryMockGetAllUsedResults struct {
|
|
|
|
- ta1 []models.Tag
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.GetAllUsed
|
|
|
|
-func (mmGetAllUsed *mITagRepositoryMockGetAllUsed) Expect(ctx context.Context) *mITagRepositoryMockGetAllUsed {
|
|
|
|
- if mmGetAllUsed.mock.funcGetAllUsed != nil {
|
|
|
|
- mmGetAllUsed.mock.t.Fatalf("ITagRepositoryMock.GetAllUsed mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetAllUsed.defaultExpectation == nil {
|
|
|
|
- mmGetAllUsed.defaultExpectation = &ITagRepositoryMockGetAllUsedExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetAllUsed.defaultExpectation.params = &ITagRepositoryMockGetAllUsedParams{ctx}
|
|
|
|
- for _, e := range mmGetAllUsed.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmGetAllUsed.defaultExpectation.params) {
|
|
|
|
- mmGetAllUsed.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllUsed.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmGetAllUsed
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.GetAllUsed
|
|
|
|
-func (mmGetAllUsed *mITagRepositoryMockGetAllUsed) Inspect(f func(ctx context.Context)) *mITagRepositoryMockGetAllUsed {
|
|
|
|
- if mmGetAllUsed.mock.inspectFuncGetAllUsed != nil {
|
|
|
|
- mmGetAllUsed.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.GetAllUsed")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetAllUsed.mock.inspectFuncGetAllUsed = f
|
|
|
|
-
|
|
|
|
- return mmGetAllUsed
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.GetAllUsed
|
|
|
|
-func (mmGetAllUsed *mITagRepositoryMockGetAllUsed) Return(ta1 []models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- if mmGetAllUsed.mock.funcGetAllUsed != nil {
|
|
|
|
- mmGetAllUsed.mock.t.Fatalf("ITagRepositoryMock.GetAllUsed mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetAllUsed.defaultExpectation == nil {
|
|
|
|
- mmGetAllUsed.defaultExpectation = &ITagRepositoryMockGetAllUsedExpectation{mock: mmGetAllUsed.mock}
|
|
|
|
- }
|
|
|
|
- mmGetAllUsed.defaultExpectation.results = &ITagRepositoryMockGetAllUsedResults{ta1, err}
|
|
|
|
- return mmGetAllUsed.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.GetAllUsed method
|
|
|
|
-func (mmGetAllUsed *mITagRepositoryMockGetAllUsed) Set(f func(ctx context.Context) (ta1 []models.Tag, err error)) *ITagRepositoryMock {
|
|
|
|
- if mmGetAllUsed.defaultExpectation != nil {
|
|
|
|
- mmGetAllUsed.mock.t.Fatalf("Default expectation is already set for the ITagRepository.GetAllUsed method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmGetAllUsed.expectations) > 0 {
|
|
|
|
- mmGetAllUsed.mock.t.Fatalf("Some expectations are already set for the ITagRepository.GetAllUsed method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetAllUsed.mock.funcGetAllUsed = f
|
|
|
|
- return mmGetAllUsed.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.GetAllUsed which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmGetAllUsed *mITagRepositoryMockGetAllUsed) When(ctx context.Context) *ITagRepositoryMockGetAllUsedExpectation {
|
|
|
|
- if mmGetAllUsed.mock.funcGetAllUsed != nil {
|
|
|
|
- mmGetAllUsed.mock.t.Fatalf("ITagRepositoryMock.GetAllUsed mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockGetAllUsedExpectation{
|
|
|
|
- mock: mmGetAllUsed.mock,
|
|
|
|
- params: &ITagRepositoryMockGetAllUsedParams{ctx},
|
|
|
|
- }
|
|
|
|
- mmGetAllUsed.expectations = append(mmGetAllUsed.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.GetAllUsed return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockGetAllUsedExpectation) Then(ta1 []models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockGetAllUsedResults{ta1, err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetAllUsed implements interfaces.ITagRepository
|
|
|
|
-func (mmGetAllUsed *ITagRepositoryMock) GetAllUsed(ctx context.Context) (ta1 []models.Tag, err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmGetAllUsed.beforeGetAllUsedCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmGetAllUsed.afterGetAllUsedCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmGetAllUsed.inspectFuncGetAllUsed != nil {
|
|
|
|
- mmGetAllUsed.inspectFuncGetAllUsed(ctx)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockGetAllUsedParams{ctx}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmGetAllUsed.GetAllUsedMock.mutex.Lock()
|
|
|
|
- mmGetAllUsed.GetAllUsedMock.callArgs = append(mmGetAllUsed.GetAllUsedMock.callArgs, mm_params)
|
|
|
|
- mmGetAllUsed.GetAllUsedMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmGetAllUsed.GetAllUsedMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.ta1, e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetAllUsed.GetAllUsedMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmGetAllUsed.GetAllUsedMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmGetAllUsed.GetAllUsedMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockGetAllUsedParams{ctx}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmGetAllUsed.t.Errorf("ITagRepositoryMock.GetAllUsed got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmGetAllUsed.GetAllUsedMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmGetAllUsed.t.Fatal("No results are set for the ITagRepositoryMock.GetAllUsed")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).ta1, (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmGetAllUsed.funcGetAllUsed != nil {
|
|
|
|
- return mmGetAllUsed.funcGetAllUsed(ctx)
|
|
|
|
- }
|
|
|
|
- mmGetAllUsed.t.Fatalf("Unexpected call to ITagRepositoryMock.GetAllUsed. %v", ctx)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetAllUsedAfterCounter returns a count of finished ITagRepositoryMock.GetAllUsed invocations
|
|
|
|
-func (mmGetAllUsed *ITagRepositoryMock) GetAllUsedAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetAllUsed.afterGetAllUsedCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetAllUsedBeforeCounter returns a count of ITagRepositoryMock.GetAllUsed invocations
|
|
|
|
-func (mmGetAllUsed *ITagRepositoryMock) GetAllUsedBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetAllUsed.beforeGetAllUsedCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.GetAllUsed.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmGetAllUsed *mITagRepositoryMockGetAllUsed) Calls() []*ITagRepositoryMockGetAllUsedParams {
|
|
|
|
- mmGetAllUsed.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockGetAllUsedParams, len(mmGetAllUsed.callArgs))
|
|
|
|
- copy(argCopy, mmGetAllUsed.callArgs)
|
|
|
|
-
|
|
|
|
- mmGetAllUsed.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetAllUsedDone returns true if the count of the GetAllUsed invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetAllUsedDone() bool {
|
|
|
|
- for _, e := range m.GetAllUsedMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetAllUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetAllUsed != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetAllUsedInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetAllUsedInspect() {
|
|
|
|
- for _, e := range m.GetAllUsedMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetAllUsed with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetAllUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
|
|
|
|
- if m.GetAllUsedMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetAllUsed")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetAllUsed with params: %#v", *m.GetAllUsedMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetAllUsed != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetAllUsed")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockGetByArticleID struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockGetByArticleIDExpectation
|
|
|
|
- expectations []*ITagRepositoryMockGetByArticleIDExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockGetByArticleIDParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByArticleIDExpectation specifies expectation struct of the ITagRepository.GetByArticleID
|
|
|
|
-type ITagRepositoryMockGetByArticleIDExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockGetByArticleIDParams
|
|
|
|
- results *ITagRepositoryMockGetByArticleIDResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByArticleIDParams contains parameters of the ITagRepository.GetByArticleID
|
|
|
|
-type ITagRepositoryMockGetByArticleIDParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
- ID int
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByArticleIDResults contains results of the ITagRepository.GetByArticleID
|
|
|
|
-type ITagRepositoryMockGetByArticleIDResults struct {
|
|
|
|
- ta1 []models.Tag
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.GetByArticleID
|
|
|
|
-func (mmGetByArticleID *mITagRepositoryMockGetByArticleID) Expect(ctx context.Context, ID int) *mITagRepositoryMockGetByArticleID {
|
|
|
|
- if mmGetByArticleID.mock.funcGetByArticleID != nil {
|
|
|
|
- mmGetByArticleID.mock.t.Fatalf("ITagRepositoryMock.GetByArticleID mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByArticleID.defaultExpectation == nil {
|
|
|
|
- mmGetByArticleID.defaultExpectation = &ITagRepositoryMockGetByArticleIDExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByArticleID.defaultExpectation.params = &ITagRepositoryMockGetByArticleIDParams{ctx, ID}
|
|
|
|
- for _, e := range mmGetByArticleID.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmGetByArticleID.defaultExpectation.params) {
|
|
|
|
- mmGetByArticleID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByArticleID.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmGetByArticleID
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.GetByArticleID
|
|
|
|
-func (mmGetByArticleID *mITagRepositoryMockGetByArticleID) Inspect(f func(ctx context.Context, ID int)) *mITagRepositoryMockGetByArticleID {
|
|
|
|
- if mmGetByArticleID.mock.inspectFuncGetByArticleID != nil {
|
|
|
|
- mmGetByArticleID.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.GetByArticleID")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByArticleID.mock.inspectFuncGetByArticleID = f
|
|
|
|
-
|
|
|
|
- return mmGetByArticleID
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.GetByArticleID
|
|
|
|
-func (mmGetByArticleID *mITagRepositoryMockGetByArticleID) Return(ta1 []models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- if mmGetByArticleID.mock.funcGetByArticleID != nil {
|
|
|
|
- mmGetByArticleID.mock.t.Fatalf("ITagRepositoryMock.GetByArticleID mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByArticleID.defaultExpectation == nil {
|
|
|
|
- mmGetByArticleID.defaultExpectation = &ITagRepositoryMockGetByArticleIDExpectation{mock: mmGetByArticleID.mock}
|
|
|
|
- }
|
|
|
|
- mmGetByArticleID.defaultExpectation.results = &ITagRepositoryMockGetByArticleIDResults{ta1, err}
|
|
|
|
- return mmGetByArticleID.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.GetByArticleID method
|
|
|
|
-func (mmGetByArticleID *mITagRepositoryMockGetByArticleID) Set(f func(ctx context.Context, ID int) (ta1 []models.Tag, err error)) *ITagRepositoryMock {
|
|
|
|
- if mmGetByArticleID.defaultExpectation != nil {
|
|
|
|
- mmGetByArticleID.mock.t.Fatalf("Default expectation is already set for the ITagRepository.GetByArticleID method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmGetByArticleID.expectations) > 0 {
|
|
|
|
- mmGetByArticleID.mock.t.Fatalf("Some expectations are already set for the ITagRepository.GetByArticleID method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByArticleID.mock.funcGetByArticleID = f
|
|
|
|
- return mmGetByArticleID.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.GetByArticleID which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmGetByArticleID *mITagRepositoryMockGetByArticleID) When(ctx context.Context, ID int) *ITagRepositoryMockGetByArticleIDExpectation {
|
|
|
|
- if mmGetByArticleID.mock.funcGetByArticleID != nil {
|
|
|
|
- mmGetByArticleID.mock.t.Fatalf("ITagRepositoryMock.GetByArticleID mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockGetByArticleIDExpectation{
|
|
|
|
- mock: mmGetByArticleID.mock,
|
|
|
|
- params: &ITagRepositoryMockGetByArticleIDParams{ctx, ID},
|
|
|
|
- }
|
|
|
|
- mmGetByArticleID.expectations = append(mmGetByArticleID.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.GetByArticleID return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockGetByArticleIDExpectation) Then(ta1 []models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockGetByArticleIDResults{ta1, err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByArticleID implements interfaces.ITagRepository
|
|
|
|
-func (mmGetByArticleID *ITagRepositoryMock) GetByArticleID(ctx context.Context, ID int) (ta1 []models.Tag, err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmGetByArticleID.beforeGetByArticleIDCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmGetByArticleID.afterGetByArticleIDCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmGetByArticleID.inspectFuncGetByArticleID != nil {
|
|
|
|
- mmGetByArticleID.inspectFuncGetByArticleID(ctx, ID)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockGetByArticleIDParams{ctx, ID}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmGetByArticleID.GetByArticleIDMock.mutex.Lock()
|
|
|
|
- mmGetByArticleID.GetByArticleIDMock.callArgs = append(mmGetByArticleID.GetByArticleIDMock.callArgs, mm_params)
|
|
|
|
- mmGetByArticleID.GetByArticleIDMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmGetByArticleID.GetByArticleIDMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.ta1, e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByArticleID.GetByArticleIDMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmGetByArticleID.GetByArticleIDMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmGetByArticleID.GetByArticleIDMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockGetByArticleIDParams{ctx, ID}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmGetByArticleID.t.Errorf("ITagRepositoryMock.GetByArticleID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmGetByArticleID.GetByArticleIDMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmGetByArticleID.t.Fatal("No results are set for the ITagRepositoryMock.GetByArticleID")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).ta1, (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmGetByArticleID.funcGetByArticleID != nil {
|
|
|
|
- return mmGetByArticleID.funcGetByArticleID(ctx, ID)
|
|
|
|
- }
|
|
|
|
- mmGetByArticleID.t.Fatalf("Unexpected call to ITagRepositoryMock.GetByArticleID. %v %v", ctx, ID)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByArticleIDAfterCounter returns a count of finished ITagRepositoryMock.GetByArticleID invocations
|
|
|
|
-func (mmGetByArticleID *ITagRepositoryMock) GetByArticleIDAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetByArticleID.afterGetByArticleIDCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByArticleIDBeforeCounter returns a count of ITagRepositoryMock.GetByArticleID invocations
|
|
|
|
-func (mmGetByArticleID *ITagRepositoryMock) GetByArticleIDBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetByArticleID.beforeGetByArticleIDCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.GetByArticleID.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmGetByArticleID *mITagRepositoryMockGetByArticleID) Calls() []*ITagRepositoryMockGetByArticleIDParams {
|
|
|
|
- mmGetByArticleID.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockGetByArticleIDParams, len(mmGetByArticleID.callArgs))
|
|
|
|
- copy(argCopy, mmGetByArticleID.callArgs)
|
|
|
|
-
|
|
|
|
- mmGetByArticleID.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetByArticleIDDone returns true if the count of the GetByArticleID invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetByArticleIDDone() bool {
|
|
|
|
- for _, e := range m.GetByArticleIDMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetByArticleIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetByArticleID != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetByArticleIDInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetByArticleIDInspect() {
|
|
|
|
- for _, e := range m.GetByArticleIDMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetByArticleID with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetByArticleIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
|
|
|
|
- if m.GetByArticleIDMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetByArticleID")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetByArticleID with params: %#v", *m.GetByArticleIDMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetByArticleID != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetByArticleID")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockGetByID struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockGetByIDExpectation
|
|
|
|
- expectations []*ITagRepositoryMockGetByIDExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockGetByIDParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByIDExpectation specifies expectation struct of the ITagRepository.GetByID
|
|
|
|
-type ITagRepositoryMockGetByIDExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockGetByIDParams
|
|
|
|
- results *ITagRepositoryMockGetByIDResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByIDParams contains parameters of the ITagRepository.GetByID
|
|
|
|
-type ITagRepositoryMockGetByIDParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
- ID int
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByIDResults contains results of the ITagRepository.GetByID
|
|
|
|
-type ITagRepositoryMockGetByIDResults struct {
|
|
|
|
- tp1 *models.Tag
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.GetByID
|
|
|
|
-func (mmGetByID *mITagRepositoryMockGetByID) Expect(ctx context.Context, ID int) *mITagRepositoryMockGetByID {
|
|
|
|
- if mmGetByID.mock.funcGetByID != nil {
|
|
|
|
- mmGetByID.mock.t.Fatalf("ITagRepositoryMock.GetByID mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByID.defaultExpectation == nil {
|
|
|
|
- mmGetByID.defaultExpectation = &ITagRepositoryMockGetByIDExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByID.defaultExpectation.params = &ITagRepositoryMockGetByIDParams{ctx, ID}
|
|
|
|
- for _, e := range mmGetByID.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmGetByID.defaultExpectation.params) {
|
|
|
|
- mmGetByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByID.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmGetByID
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.GetByID
|
|
|
|
-func (mmGetByID *mITagRepositoryMockGetByID) Inspect(f func(ctx context.Context, ID int)) *mITagRepositoryMockGetByID {
|
|
|
|
- if mmGetByID.mock.inspectFuncGetByID != nil {
|
|
|
|
- mmGetByID.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.GetByID")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByID.mock.inspectFuncGetByID = f
|
|
|
|
-
|
|
|
|
- return mmGetByID
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.GetByID
|
|
|
|
-func (mmGetByID *mITagRepositoryMockGetByID) Return(tp1 *models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- if mmGetByID.mock.funcGetByID != nil {
|
|
|
|
- mmGetByID.mock.t.Fatalf("ITagRepositoryMock.GetByID mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByID.defaultExpectation == nil {
|
|
|
|
- mmGetByID.defaultExpectation = &ITagRepositoryMockGetByIDExpectation{mock: mmGetByID.mock}
|
|
|
|
- }
|
|
|
|
- mmGetByID.defaultExpectation.results = &ITagRepositoryMockGetByIDResults{tp1, err}
|
|
|
|
- return mmGetByID.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.GetByID method
|
|
|
|
-func (mmGetByID *mITagRepositoryMockGetByID) Set(f func(ctx context.Context, ID int) (tp1 *models.Tag, err error)) *ITagRepositoryMock {
|
|
|
|
- if mmGetByID.defaultExpectation != nil {
|
|
|
|
- mmGetByID.mock.t.Fatalf("Default expectation is already set for the ITagRepository.GetByID method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmGetByID.expectations) > 0 {
|
|
|
|
- mmGetByID.mock.t.Fatalf("Some expectations are already set for the ITagRepository.GetByID method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByID.mock.funcGetByID = f
|
|
|
|
- return mmGetByID.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.GetByID which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmGetByID *mITagRepositoryMockGetByID) When(ctx context.Context, ID int) *ITagRepositoryMockGetByIDExpectation {
|
|
|
|
- if mmGetByID.mock.funcGetByID != nil {
|
|
|
|
- mmGetByID.mock.t.Fatalf("ITagRepositoryMock.GetByID mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockGetByIDExpectation{
|
|
|
|
- mock: mmGetByID.mock,
|
|
|
|
- params: &ITagRepositoryMockGetByIDParams{ctx, ID},
|
|
|
|
- }
|
|
|
|
- mmGetByID.expectations = append(mmGetByID.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.GetByID return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockGetByIDExpectation) Then(tp1 *models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockGetByIDResults{tp1, err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByID implements interfaces.ITagRepository
|
|
|
|
-func (mmGetByID *ITagRepositoryMock) GetByID(ctx context.Context, ID int) (tp1 *models.Tag, err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmGetByID.beforeGetByIDCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmGetByID.afterGetByIDCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmGetByID.inspectFuncGetByID != nil {
|
|
|
|
- mmGetByID.inspectFuncGetByID(ctx, ID)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockGetByIDParams{ctx, ID}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmGetByID.GetByIDMock.mutex.Lock()
|
|
|
|
- mmGetByID.GetByIDMock.callArgs = append(mmGetByID.GetByIDMock.callArgs, mm_params)
|
|
|
|
- mmGetByID.GetByIDMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmGetByID.GetByIDMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.tp1, e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByID.GetByIDMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmGetByID.GetByIDMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmGetByID.GetByIDMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockGetByIDParams{ctx, ID}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmGetByID.t.Errorf("ITagRepositoryMock.GetByID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmGetByID.GetByIDMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmGetByID.t.Fatal("No results are set for the ITagRepositoryMock.GetByID")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).tp1, (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmGetByID.funcGetByID != nil {
|
|
|
|
- return mmGetByID.funcGetByID(ctx, ID)
|
|
|
|
- }
|
|
|
|
- mmGetByID.t.Fatalf("Unexpected call to ITagRepositoryMock.GetByID. %v %v", ctx, ID)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByIDAfterCounter returns a count of finished ITagRepositoryMock.GetByID invocations
|
|
|
|
-func (mmGetByID *ITagRepositoryMock) GetByIDAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetByID.afterGetByIDCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByIDBeforeCounter returns a count of ITagRepositoryMock.GetByID invocations
|
|
|
|
-func (mmGetByID *ITagRepositoryMock) GetByIDBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetByID.beforeGetByIDCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.GetByID.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmGetByID *mITagRepositoryMockGetByID) Calls() []*ITagRepositoryMockGetByIDParams {
|
|
|
|
- mmGetByID.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockGetByIDParams, len(mmGetByID.callArgs))
|
|
|
|
- copy(argCopy, mmGetByID.callArgs)
|
|
|
|
-
|
|
|
|
- mmGetByID.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetByIDDone returns true if the count of the GetByID invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetByIDDone() bool {
|
|
|
|
- for _, e := range m.GetByIDMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetByIDInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetByIDInspect() {
|
|
|
|
- for _, e := range m.GetByIDMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetByID with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
|
|
|
|
- if m.GetByIDMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetByID")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetByID with params: %#v", *m.GetByIDMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetByID")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockGetByURL struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockGetByURLExpectation
|
|
|
|
- expectations []*ITagRepositoryMockGetByURLExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockGetByURLParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByURLExpectation specifies expectation struct of the ITagRepository.GetByURL
|
|
|
|
-type ITagRepositoryMockGetByURLExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockGetByURLParams
|
|
|
|
- results *ITagRepositoryMockGetByURLResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByURLParams contains parameters of the ITagRepository.GetByURL
|
|
|
|
-type ITagRepositoryMockGetByURLParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
- tag string
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockGetByURLResults contains results of the ITagRepository.GetByURL
|
|
|
|
-type ITagRepositoryMockGetByURLResults struct {
|
|
|
|
- tp1 *models.Tag
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.GetByURL
|
|
|
|
-func (mmGetByURL *mITagRepositoryMockGetByURL) Expect(ctx context.Context, tag string) *mITagRepositoryMockGetByURL {
|
|
|
|
- if mmGetByURL.mock.funcGetByURL != nil {
|
|
|
|
- mmGetByURL.mock.t.Fatalf("ITagRepositoryMock.GetByURL mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByURL.defaultExpectation == nil {
|
|
|
|
- mmGetByURL.defaultExpectation = &ITagRepositoryMockGetByURLExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByURL.defaultExpectation.params = &ITagRepositoryMockGetByURLParams{ctx, tag}
|
|
|
|
- for _, e := range mmGetByURL.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) {
|
|
|
|
- mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmGetByURL
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.GetByURL
|
|
|
|
-func (mmGetByURL *mITagRepositoryMockGetByURL) Inspect(f func(ctx context.Context, tag string)) *mITagRepositoryMockGetByURL {
|
|
|
|
- if mmGetByURL.mock.inspectFuncGetByURL != nil {
|
|
|
|
- mmGetByURL.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.GetByURL")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByURL.mock.inspectFuncGetByURL = f
|
|
|
|
-
|
|
|
|
- return mmGetByURL
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.GetByURL
|
|
|
|
-func (mmGetByURL *mITagRepositoryMockGetByURL) Return(tp1 *models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- if mmGetByURL.mock.funcGetByURL != nil {
|
|
|
|
- mmGetByURL.mock.t.Fatalf("ITagRepositoryMock.GetByURL mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByURL.defaultExpectation == nil {
|
|
|
|
- mmGetByURL.defaultExpectation = &ITagRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
|
|
|
|
- }
|
|
|
|
- mmGetByURL.defaultExpectation.results = &ITagRepositoryMockGetByURLResults{tp1, err}
|
|
|
|
- return mmGetByURL.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.GetByURL method
|
|
|
|
-func (mmGetByURL *mITagRepositoryMockGetByURL) Set(f func(ctx context.Context, tag string) (tp1 *models.Tag, err error)) *ITagRepositoryMock {
|
|
|
|
- if mmGetByURL.defaultExpectation != nil {
|
|
|
|
- mmGetByURL.mock.t.Fatalf("Default expectation is already set for the ITagRepository.GetByURL method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmGetByURL.expectations) > 0 {
|
|
|
|
- mmGetByURL.mock.t.Fatalf("Some expectations are already set for the ITagRepository.GetByURL method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmGetByURL.mock.funcGetByURL = f
|
|
|
|
- return mmGetByURL.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.GetByURL which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmGetByURL *mITagRepositoryMockGetByURL) When(ctx context.Context, tag string) *ITagRepositoryMockGetByURLExpectation {
|
|
|
|
- if mmGetByURL.mock.funcGetByURL != nil {
|
|
|
|
- mmGetByURL.mock.t.Fatalf("ITagRepositoryMock.GetByURL mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockGetByURLExpectation{
|
|
|
|
- mock: mmGetByURL.mock,
|
|
|
|
- params: &ITagRepositoryMockGetByURLParams{ctx, tag},
|
|
|
|
- }
|
|
|
|
- mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.GetByURL return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockGetByURLExpectation) Then(tp1 *models.Tag, err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockGetByURLResults{tp1, err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByURL implements interfaces.ITagRepository
|
|
|
|
-func (mmGetByURL *ITagRepositoryMock) GetByURL(ctx context.Context, tag string) (tp1 *models.Tag, err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmGetByURL.inspectFuncGetByURL != nil {
|
|
|
|
- mmGetByURL.inspectFuncGetByURL(ctx, tag)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockGetByURLParams{ctx, tag}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmGetByURL.GetByURLMock.mutex.Lock()
|
|
|
|
- mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, mm_params)
|
|
|
|
- mmGetByURL.GetByURLMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmGetByURL.GetByURLMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.tp1, e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmGetByURL.GetByURLMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockGetByURLParams{ctx, tag}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmGetByURL.t.Errorf("ITagRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmGetByURL.t.Fatal("No results are set for the ITagRepositoryMock.GetByURL")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).tp1, (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmGetByURL.funcGetByURL != nil {
|
|
|
|
- return mmGetByURL.funcGetByURL(ctx, tag)
|
|
|
|
- }
|
|
|
|
- mmGetByURL.t.Fatalf("Unexpected call to ITagRepositoryMock.GetByURL. %v %v", ctx, tag)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByURLAfterCounter returns a count of finished ITagRepositoryMock.GetByURL invocations
|
|
|
|
-func (mmGetByURL *ITagRepositoryMock) GetByURLAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// GetByURLBeforeCounter returns a count of ITagRepositoryMock.GetByURL invocations
|
|
|
|
-func (mmGetByURL *ITagRepositoryMock) GetByURLBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.GetByURL.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmGetByURL *mITagRepositoryMockGetByURL) Calls() []*ITagRepositoryMockGetByURLParams {
|
|
|
|
- mmGetByURL.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
|
|
|
|
- copy(argCopy, mmGetByURL.callArgs)
|
|
|
|
-
|
|
|
|
- mmGetByURL.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetByURLDone() bool {
|
|
|
|
- for _, e := range m.GetByURLMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockGetByURLInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockGetByURLInspect() {
|
|
|
|
- for _, e := range m.GetByURLMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetByURL with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
|
|
|
|
- if m.GetByURLMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetByURL")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.GetByURL")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockIsUsed struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockIsUsedExpectation
|
|
|
|
- expectations []*ITagRepositoryMockIsUsedExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockIsUsedParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockIsUsedExpectation specifies expectation struct of the ITagRepository.IsUsed
|
|
|
|
-type ITagRepositoryMockIsUsedExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockIsUsedParams
|
|
|
|
- results *ITagRepositoryMockIsUsedResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockIsUsedParams contains parameters of the ITagRepository.IsUsed
|
|
|
|
-type ITagRepositoryMockIsUsedParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
- ID int
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockIsUsedResults contains results of the ITagRepository.IsUsed
|
|
|
|
-type ITagRepositoryMockIsUsedResults struct {
|
|
|
|
- b1 bool
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.IsUsed
|
|
|
|
-func (mmIsUsed *mITagRepositoryMockIsUsed) Expect(ctx context.Context, ID int) *mITagRepositoryMockIsUsed {
|
|
|
|
- if mmIsUsed.mock.funcIsUsed != nil {
|
|
|
|
- mmIsUsed.mock.t.Fatalf("ITagRepositoryMock.IsUsed mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmIsUsed.defaultExpectation == nil {
|
|
|
|
- mmIsUsed.defaultExpectation = &ITagRepositoryMockIsUsedExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmIsUsed.defaultExpectation.params = &ITagRepositoryMockIsUsedParams{ctx, ID}
|
|
|
|
- for _, e := range mmIsUsed.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmIsUsed.defaultExpectation.params) {
|
|
|
|
- mmIsUsed.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsUsed.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmIsUsed
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.IsUsed
|
|
|
|
-func (mmIsUsed *mITagRepositoryMockIsUsed) Inspect(f func(ctx context.Context, ID int)) *mITagRepositoryMockIsUsed {
|
|
|
|
- if mmIsUsed.mock.inspectFuncIsUsed != nil {
|
|
|
|
- mmIsUsed.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.IsUsed")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmIsUsed.mock.inspectFuncIsUsed = f
|
|
|
|
-
|
|
|
|
- return mmIsUsed
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.IsUsed
|
|
|
|
-func (mmIsUsed *mITagRepositoryMockIsUsed) Return(b1 bool, err error) *ITagRepositoryMock {
|
|
|
|
- if mmIsUsed.mock.funcIsUsed != nil {
|
|
|
|
- mmIsUsed.mock.t.Fatalf("ITagRepositoryMock.IsUsed mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmIsUsed.defaultExpectation == nil {
|
|
|
|
- mmIsUsed.defaultExpectation = &ITagRepositoryMockIsUsedExpectation{mock: mmIsUsed.mock}
|
|
|
|
- }
|
|
|
|
- mmIsUsed.defaultExpectation.results = &ITagRepositoryMockIsUsedResults{b1, err}
|
|
|
|
- return mmIsUsed.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.IsUsed method
|
|
|
|
-func (mmIsUsed *mITagRepositoryMockIsUsed) Set(f func(ctx context.Context, ID int) (b1 bool, err error)) *ITagRepositoryMock {
|
|
|
|
- if mmIsUsed.defaultExpectation != nil {
|
|
|
|
- mmIsUsed.mock.t.Fatalf("Default expectation is already set for the ITagRepository.IsUsed method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmIsUsed.expectations) > 0 {
|
|
|
|
- mmIsUsed.mock.t.Fatalf("Some expectations are already set for the ITagRepository.IsUsed method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmIsUsed.mock.funcIsUsed = f
|
|
|
|
- return mmIsUsed.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.IsUsed which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmIsUsed *mITagRepositoryMockIsUsed) When(ctx context.Context, ID int) *ITagRepositoryMockIsUsedExpectation {
|
|
|
|
- if mmIsUsed.mock.funcIsUsed != nil {
|
|
|
|
- mmIsUsed.mock.t.Fatalf("ITagRepositoryMock.IsUsed mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockIsUsedExpectation{
|
|
|
|
- mock: mmIsUsed.mock,
|
|
|
|
- params: &ITagRepositoryMockIsUsedParams{ctx, ID},
|
|
|
|
- }
|
|
|
|
- mmIsUsed.expectations = append(mmIsUsed.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.IsUsed return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockIsUsedExpectation) Then(b1 bool, err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockIsUsedResults{b1, err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// IsUsed implements interfaces.ITagRepository
|
|
|
|
-func (mmIsUsed *ITagRepositoryMock) IsUsed(ctx context.Context, ID int) (b1 bool, err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmIsUsed.beforeIsUsedCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmIsUsed.afterIsUsedCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmIsUsed.inspectFuncIsUsed != nil {
|
|
|
|
- mmIsUsed.inspectFuncIsUsed(ctx, ID)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockIsUsedParams{ctx, ID}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmIsUsed.IsUsedMock.mutex.Lock()
|
|
|
|
- mmIsUsed.IsUsedMock.callArgs = append(mmIsUsed.IsUsedMock.callArgs, mm_params)
|
|
|
|
- mmIsUsed.IsUsedMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmIsUsed.IsUsedMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.b1, e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmIsUsed.IsUsedMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmIsUsed.IsUsedMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmIsUsed.IsUsedMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockIsUsedParams{ctx, ID}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmIsUsed.t.Errorf("ITagRepositoryMock.IsUsed got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmIsUsed.IsUsedMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmIsUsed.t.Fatal("No results are set for the ITagRepositoryMock.IsUsed")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).b1, (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmIsUsed.funcIsUsed != nil {
|
|
|
|
- return mmIsUsed.funcIsUsed(ctx, ID)
|
|
|
|
- }
|
|
|
|
- mmIsUsed.t.Fatalf("Unexpected call to ITagRepositoryMock.IsUsed. %v %v", ctx, ID)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// IsUsedAfterCounter returns a count of finished ITagRepositoryMock.IsUsed invocations
|
|
|
|
-func (mmIsUsed *ITagRepositoryMock) IsUsedAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmIsUsed.afterIsUsedCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// IsUsedBeforeCounter returns a count of ITagRepositoryMock.IsUsed invocations
|
|
|
|
-func (mmIsUsed *ITagRepositoryMock) IsUsedBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmIsUsed.beforeIsUsedCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.IsUsed.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmIsUsed *mITagRepositoryMockIsUsed) Calls() []*ITagRepositoryMockIsUsedParams {
|
|
|
|
- mmIsUsed.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockIsUsedParams, len(mmIsUsed.callArgs))
|
|
|
|
- copy(argCopy, mmIsUsed.callArgs)
|
|
|
|
-
|
|
|
|
- mmIsUsed.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockIsUsedDone returns true if the count of the IsUsed invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockIsUsedDone() bool {
|
|
|
|
- for _, e := range m.IsUsedMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.IsUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcIsUsed != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockIsUsedInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockIsUsedInspect() {
|
|
|
|
- for _, e := range m.IsUsedMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.IsUsed with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.IsUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
|
|
|
|
- if m.IsUsedMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.IsUsed")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.IsUsed with params: %#v", *m.IsUsedMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcIsUsed != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.IsUsed")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-type mITagRepositoryMockUpdate struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- defaultExpectation *ITagRepositoryMockUpdateExpectation
|
|
|
|
- expectations []*ITagRepositoryMockUpdateExpectation
|
|
|
|
-
|
|
|
|
- callArgs []*ITagRepositoryMockUpdateParams
|
|
|
|
- mutex sync.RWMutex
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockUpdateExpectation specifies expectation struct of the ITagRepository.Update
|
|
|
|
-type ITagRepositoryMockUpdateExpectation struct {
|
|
|
|
- mock *ITagRepositoryMock
|
|
|
|
- params *ITagRepositoryMockUpdateParams
|
|
|
|
- results *ITagRepositoryMockUpdateResults
|
|
|
|
- Counter uint64
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockUpdateParams contains parameters of the ITagRepository.Update
|
|
|
|
-type ITagRepositoryMockUpdateParams struct {
|
|
|
|
- ctx context.Context
|
|
|
|
- m models.Tag
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ITagRepositoryMockUpdateResults contains results of the ITagRepository.Update
|
|
|
|
-type ITagRepositoryMockUpdateResults struct {
|
|
|
|
- err error
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Expect sets up expected params for ITagRepository.Update
|
|
|
|
-func (mmUpdate *mITagRepositoryMockUpdate) Expect(ctx context.Context, m models.Tag) *mITagRepositoryMockUpdate {
|
|
|
|
- if mmUpdate.mock.funcUpdate != nil {
|
|
|
|
- mmUpdate.mock.t.Fatalf("ITagRepositoryMock.Update mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmUpdate.defaultExpectation == nil {
|
|
|
|
- mmUpdate.defaultExpectation = &ITagRepositoryMockUpdateExpectation{}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmUpdate.defaultExpectation.params = &ITagRepositoryMockUpdateParams{ctx, m}
|
|
|
|
- for _, e := range mmUpdate.expectations {
|
|
|
|
- if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
|
|
|
|
- mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return mmUpdate
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Inspect accepts an inspector function that has same arguments as the ITagRepository.Update
|
|
|
|
-func (mmUpdate *mITagRepositoryMockUpdate) Inspect(f func(ctx context.Context, m models.Tag)) *mITagRepositoryMockUpdate {
|
|
|
|
- if mmUpdate.mock.inspectFuncUpdate != nil {
|
|
|
|
- mmUpdate.mock.t.Fatalf("Inspect function is already set for ITagRepositoryMock.Update")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmUpdate.mock.inspectFuncUpdate = f
|
|
|
|
-
|
|
|
|
- return mmUpdate
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Return sets up results that will be returned by ITagRepository.Update
|
|
|
|
-func (mmUpdate *mITagRepositoryMockUpdate) Return(err error) *ITagRepositoryMock {
|
|
|
|
- if mmUpdate.mock.funcUpdate != nil {
|
|
|
|
- mmUpdate.mock.t.Fatalf("ITagRepositoryMock.Update mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmUpdate.defaultExpectation == nil {
|
|
|
|
- mmUpdate.defaultExpectation = &ITagRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
|
|
|
|
- }
|
|
|
|
- mmUpdate.defaultExpectation.results = &ITagRepositoryMockUpdateResults{err}
|
|
|
|
- return mmUpdate.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Set uses given function f to mock the ITagRepository.Update method
|
|
|
|
-func (mmUpdate *mITagRepositoryMockUpdate) Set(f func(ctx context.Context, m models.Tag) (err error)) *ITagRepositoryMock {
|
|
|
|
- if mmUpdate.defaultExpectation != nil {
|
|
|
|
- mmUpdate.mock.t.Fatalf("Default expectation is already set for the ITagRepository.Update method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(mmUpdate.expectations) > 0 {
|
|
|
|
- mmUpdate.mock.t.Fatalf("Some expectations are already set for the ITagRepository.Update method")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mmUpdate.mock.funcUpdate = f
|
|
|
|
- return mmUpdate.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// When sets expectation for the ITagRepository.Update which will trigger the result defined by the following
|
|
|
|
-// Then helper
|
|
|
|
-func (mmUpdate *mITagRepositoryMockUpdate) When(ctx context.Context, m models.Tag) *ITagRepositoryMockUpdateExpectation {
|
|
|
|
- if mmUpdate.mock.funcUpdate != nil {
|
|
|
|
- mmUpdate.mock.t.Fatalf("ITagRepositoryMock.Update mock is already set by Set")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- expectation := &ITagRepositoryMockUpdateExpectation{
|
|
|
|
- mock: mmUpdate.mock,
|
|
|
|
- params: &ITagRepositoryMockUpdateParams{ctx, m},
|
|
|
|
- }
|
|
|
|
- mmUpdate.expectations = append(mmUpdate.expectations, expectation)
|
|
|
|
- return expectation
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Then sets up ITagRepository.Update return parameters for the expectation previously defined by the When method
|
|
|
|
-func (e *ITagRepositoryMockUpdateExpectation) Then(err error) *ITagRepositoryMock {
|
|
|
|
- e.results = &ITagRepositoryMockUpdateResults{err}
|
|
|
|
- return e.mock
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Update implements interfaces.ITagRepository
|
|
|
|
-func (mmUpdate *ITagRepositoryMock) Update(ctx context.Context, m models.Tag) (err error) {
|
|
|
|
- mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
|
|
|
|
- defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
|
|
|
|
-
|
|
|
|
- if mmUpdate.inspectFuncUpdate != nil {
|
|
|
|
- mmUpdate.inspectFuncUpdate(ctx, m)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_params := &ITagRepositoryMockUpdateParams{ctx, m}
|
|
|
|
-
|
|
|
|
- // Record call args
|
|
|
|
- mmUpdate.UpdateMock.mutex.Lock()
|
|
|
|
- mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, mm_params)
|
|
|
|
- mmUpdate.UpdateMock.mutex.Unlock()
|
|
|
|
-
|
|
|
|
- for _, e := range mmUpdate.UpdateMock.expectations {
|
|
|
|
- if minimock.Equal(e.params, mm_params) {
|
|
|
|
- mm_atomic.AddUint64(&e.Counter, 1)
|
|
|
|
- return e.results.err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if mmUpdate.UpdateMock.defaultExpectation != nil {
|
|
|
|
- mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
|
|
|
|
- mm_want := mmUpdate.UpdateMock.defaultExpectation.params
|
|
|
|
- mm_got := ITagRepositoryMockUpdateParams{ctx, m}
|
|
|
|
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
|
|
|
|
- mmUpdate.t.Errorf("ITagRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mm_results := mmUpdate.UpdateMock.defaultExpectation.results
|
|
|
|
- if mm_results == nil {
|
|
|
|
- mmUpdate.t.Fatal("No results are set for the ITagRepositoryMock.Update")
|
|
|
|
- }
|
|
|
|
- return (*mm_results).err
|
|
|
|
- }
|
|
|
|
- if mmUpdate.funcUpdate != nil {
|
|
|
|
- return mmUpdate.funcUpdate(ctx, m)
|
|
|
|
- }
|
|
|
|
- mmUpdate.t.Fatalf("Unexpected call to ITagRepositoryMock.Update. %v %v", ctx, m)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// UpdateAfterCounter returns a count of finished ITagRepositoryMock.Update invocations
|
|
|
|
-func (mmUpdate *ITagRepositoryMock) UpdateAfterCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// UpdateBeforeCounter returns a count of ITagRepositoryMock.Update invocations
|
|
|
|
-func (mmUpdate *ITagRepositoryMock) UpdateBeforeCounter() uint64 {
|
|
|
|
- return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Calls returns a list of arguments used in each call to ITagRepositoryMock.Update.
|
|
|
|
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
|
|
|
|
-func (mmUpdate *mITagRepositoryMockUpdate) Calls() []*ITagRepositoryMockUpdateParams {
|
|
|
|
- mmUpdate.mutex.RLock()
|
|
|
|
-
|
|
|
|
- argCopy := make([]*ITagRepositoryMockUpdateParams, len(mmUpdate.callArgs))
|
|
|
|
- copy(argCopy, mmUpdate.callArgs)
|
|
|
|
-
|
|
|
|
- mmUpdate.mutex.RUnlock()
|
|
|
|
-
|
|
|
|
- return argCopy
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockUpdateDone returns true if the count of the Update invocations corresponds
|
|
|
|
-// the number of defined expectations
|
|
|
|
-func (m *ITagRepositoryMock) MinimockUpdateDone() bool {
|
|
|
|
- for _, e := range m.UpdateMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockUpdateInspect logs each unmet expectation
|
|
|
|
-func (m *ITagRepositoryMock) MinimockUpdateInspect() {
|
|
|
|
- for _, e := range m.UpdateMock.expectations {
|
|
|
|
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.Update with params: %#v", *e.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if default expectation was set then invocations count should be greater than zero
|
|
|
|
- if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
|
|
|
|
- if m.UpdateMock.defaultExpectation.params == nil {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.Update")
|
|
|
|
- } else {
|
|
|
|
- m.t.Errorf("Expected call to ITagRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // if func was set then invocations count should be greater than zero
|
|
|
|
- if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
|
|
|
|
- m.t.Error("Expected call to ITagRepositoryMock.Update")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockFinish checks that all mocked methods have been called the expected number of times
|
|
|
|
-func (m *ITagRepositoryMock) MinimockFinish() {
|
|
|
|
- if !m.minimockDone() {
|
|
|
|
- m.MinimockAddInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockDeleteInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockGetAllInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockGetAllUsedInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockGetByArticleIDInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockGetByIDInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockGetByURLInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockIsUsedInspect()
|
|
|
|
-
|
|
|
|
- m.MinimockUpdateInspect()
|
|
|
|
- m.t.FailNow()
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinimockWait waits for all mocked methods to be called the expected number of times
|
|
|
|
-func (m *ITagRepositoryMock) 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 *ITagRepositoryMock) minimockDone() bool {
|
|
|
|
- done := true
|
|
|
|
- return done &&
|
|
|
|
- m.MinimockAddDone() &&
|
|
|
|
- m.MinimockDeleteDone() &&
|
|
|
|
- m.MinimockGetAllDone() &&
|
|
|
|
- m.MinimockGetAllUsedDone() &&
|
|
|
|
- m.MinimockGetByArticleIDDone() &&
|
|
|
|
- m.MinimockGetByIDDone() &&
|
|
|
|
- m.MinimockGetByURLDone() &&
|
|
|
|
- m.MinimockIsUsedDone() &&
|
|
|
|
- m.MinimockUpdateDone()
|
|
|
|
-}
|
|
|