// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.

package mocks

//go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/tag.TagRepository -o tag_repository_minimock.go -n TagRepositoryMock -p mocks

import (
	"context"
	"sync"
	mm_atomic "sync/atomic"
	mm_time "time"

	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
	"github.com/gojuno/minimock/v3"
)

// TagRepositoryMock implements tag.TagRepository
type TagRepositoryMock struct {
	t          minimock.Tester
	finishOnce sync.Once

	funcAdd          func(ctx context.Context, req models.AddTagRequest) (u1 uint64, err error)
	inspectFuncAdd   func(ctx context.Context, req models.AddTagRequest)
	afterAddCounter  uint64
	beforeAddCounter uint64
	AddMock          mTagRepositoryMockAdd

	funcDelete          func(ctx context.Context, id uint64) (err error)
	inspectFuncDelete   func(ctx context.Context, id uint64)
	afterDeleteCounter  uint64
	beforeDeleteCounter uint64
	DeleteMock          mTagRepositoryMockDelete

	funcGet          func(ctx context.Context, id uint64) (tp1 *models.Tag, err error)
	inspectFuncGet   func(ctx context.Context, id uint64)
	afterGetCounter  uint64
	beforeGetCounter uint64
	GetMock          mTagRepositoryMockGet

	funcGetAll          func(ctx context.Context) (ta1 []models.Tag, err error)
	inspectFuncGetAll   func(ctx context.Context)
	afterGetAllCounter  uint64
	beforeGetAllCounter uint64
	GetAllMock          mTagRepositoryMockGetAll

	funcGetByThingID          func(ctx context.Context, id uint64) (ta1 []models.Tag, err error)
	inspectFuncGetByThingID   func(ctx context.Context, id uint64)
	afterGetByThingIDCounter  uint64
	beforeGetByThingIDCounter uint64
	GetByThingIDMock          mTagRepositoryMockGetByThingID

	funcUpdate          func(ctx context.Context, req models.UpdateTagRequest) (err error)
	inspectFuncUpdate   func(ctx context.Context, req models.UpdateTagRequest)
	afterUpdateCounter  uint64
	beforeUpdateCounter uint64
	UpdateMock          mTagRepositoryMockUpdate
}

// NewTagRepositoryMock returns a mock for tag.TagRepository
func NewTagRepositoryMock(t minimock.Tester) *TagRepositoryMock {
	m := &TagRepositoryMock{t: t}

	if controller, ok := t.(minimock.MockController); ok {
		controller.RegisterMocker(m)
	}

	m.AddMock = mTagRepositoryMockAdd{mock: m}
	m.AddMock.callArgs = []*TagRepositoryMockAddParams{}

	m.DeleteMock = mTagRepositoryMockDelete{mock: m}
	m.DeleteMock.callArgs = []*TagRepositoryMockDeleteParams{}

	m.GetMock = mTagRepositoryMockGet{mock: m}
	m.GetMock.callArgs = []*TagRepositoryMockGetParams{}

	m.GetAllMock = mTagRepositoryMockGetAll{mock: m}
	m.GetAllMock.callArgs = []*TagRepositoryMockGetAllParams{}

	m.GetByThingIDMock = mTagRepositoryMockGetByThingID{mock: m}
	m.GetByThingIDMock.callArgs = []*TagRepositoryMockGetByThingIDParams{}

	m.UpdateMock = mTagRepositoryMockUpdate{mock: m}
	m.UpdateMock.callArgs = []*TagRepositoryMockUpdateParams{}

	t.Cleanup(m.MinimockFinish)

	return m
}

type mTagRepositoryMockAdd struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockAddExpectation
	expectations       []*TagRepositoryMockAddExpectation

	callArgs []*TagRepositoryMockAddParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockAddExpectation specifies expectation struct of the TagRepository.Add
type TagRepositoryMockAddExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockAddParams
	paramPtrs *TagRepositoryMockAddParamPtrs
	results   *TagRepositoryMockAddResults
	Counter   uint64
}

// TagRepositoryMockAddParams contains parameters of the TagRepository.Add
type TagRepositoryMockAddParams struct {
	ctx context.Context
	req models.AddTagRequest
}

// TagRepositoryMockAddParamPtrs contains pointers to parameters of the TagRepository.Add
type TagRepositoryMockAddParamPtrs struct {
	ctx *context.Context
	req *models.AddTagRequest
}

// TagRepositoryMockAddResults contains results of the TagRepository.Add
type TagRepositoryMockAddResults struct {
	u1  uint64
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmAdd *mTagRepositoryMockAdd) Optional() *mTagRepositoryMockAdd {
	mmAdd.optional = true
	return mmAdd
}

// Expect sets up expected params for TagRepository.Add
func (mmAdd *mTagRepositoryMockAdd) Expect(ctx context.Context, req models.AddTagRequest) *mTagRepositoryMockAdd {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &TagRepositoryMockAddExpectation{}
	}

	if mmAdd.defaultExpectation.paramPtrs != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by ExpectParams functions")
	}

	mmAdd.defaultExpectation.params = &TagRepositoryMockAddParams{ctx, req}
	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
}

// ExpectCtxParam1 sets up expected param ctx for TagRepository.Add
func (mmAdd *mTagRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockAdd {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &TagRepositoryMockAddExpectation{}
	}

	if mmAdd.defaultExpectation.params != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Expect")
	}

	if mmAdd.defaultExpectation.paramPtrs == nil {
		mmAdd.defaultExpectation.paramPtrs = &TagRepositoryMockAddParamPtrs{}
	}
	mmAdd.defaultExpectation.paramPtrs.ctx = &ctx

	return mmAdd
}

// ExpectReqParam2 sets up expected param req for TagRepository.Add
func (mmAdd *mTagRepositoryMockAdd) ExpectReqParam2(req models.AddTagRequest) *mTagRepositoryMockAdd {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &TagRepositoryMockAddExpectation{}
	}

	if mmAdd.defaultExpectation.params != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Expect")
	}

	if mmAdd.defaultExpectation.paramPtrs == nil {
		mmAdd.defaultExpectation.paramPtrs = &TagRepositoryMockAddParamPtrs{}
	}
	mmAdd.defaultExpectation.paramPtrs.req = &req

	return mmAdd
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.Add
func (mmAdd *mTagRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddTagRequest)) *mTagRepositoryMockAdd {
	if mmAdd.mock.inspectFuncAdd != nil {
		mmAdd.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.Add")
	}

	mmAdd.mock.inspectFuncAdd = f

	return mmAdd
}

// Return sets up results that will be returned by TagRepository.Add
func (mmAdd *mTagRepositoryMockAdd) Return(u1 uint64, err error) *TagRepositoryMock {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &TagRepositoryMockAddExpectation{mock: mmAdd.mock}
	}
	mmAdd.defaultExpectation.results = &TagRepositoryMockAddResults{u1, err}
	return mmAdd.mock
}

// Set uses given function f to mock the TagRepository.Add method
func (mmAdd *mTagRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddTagRequest) (u1 uint64, err error)) *TagRepositoryMock {
	if mmAdd.defaultExpectation != nil {
		mmAdd.mock.t.Fatalf("Default expectation is already set for the TagRepository.Add method")
	}

	if len(mmAdd.expectations) > 0 {
		mmAdd.mock.t.Fatalf("Some expectations are already set for the TagRepository.Add method")
	}

	mmAdd.mock.funcAdd = f
	return mmAdd.mock
}

// When sets expectation for the TagRepository.Add which will trigger the result defined by the following
// Then helper
func (mmAdd *mTagRepositoryMockAdd) When(ctx context.Context, req models.AddTagRequest) *TagRepositoryMockAddExpectation {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
	}

	expectation := &TagRepositoryMockAddExpectation{
		mock:   mmAdd.mock,
		params: &TagRepositoryMockAddParams{ctx, req},
	}
	mmAdd.expectations = append(mmAdd.expectations, expectation)
	return expectation
}

// Then sets up TagRepository.Add return parameters for the expectation previously defined by the When method
func (e *TagRepositoryMockAddExpectation) Then(u1 uint64, err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockAddResults{u1, err}
	return e.mock
}

// Times sets number of times TagRepository.Add should be invoked
func (mmAdd *mTagRepositoryMockAdd) Times(n uint64) *mTagRepositoryMockAdd {
	if n == 0 {
		mmAdd.mock.t.Fatalf("Times of TagRepositoryMock.Add mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
	return mmAdd
}

func (mmAdd *mTagRepositoryMockAdd) invocationsDone() bool {
	if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Add implements tag.TagRepository
func (mmAdd *TagRepositoryMock) Add(ctx context.Context, req models.AddTagRequest) (u1 uint64, err error) {
	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)

	if mmAdd.inspectFuncAdd != nil {
		mmAdd.inspectFuncAdd(ctx, req)
	}

	mm_params := TagRepositoryMockAddParams{ctx, req}

	// 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.u1, e.results.err
		}
	}

	if mmAdd.AddMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
		mm_want := mmAdd.AddMock.defaultExpectation.params
		mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs

		mm_got := TagRepositoryMockAddParams{ctx, req}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmAdd.t.Errorf("TagRepositoryMock.Add got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
				mmAdd.t.Errorf("TagRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmAdd.t.Errorf("TagRepositoryMock.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 TagRepositoryMock.Add")
		}
		return (*mm_results).u1, (*mm_results).err
	}
	if mmAdd.funcAdd != nil {
		return mmAdd.funcAdd(ctx, req)
	}
	mmAdd.t.Fatalf("Unexpected call to TagRepositoryMock.Add. %v %v", ctx, req)
	return
}

// AddAfterCounter returns a count of finished TagRepositoryMock.Add invocations
func (mmAdd *TagRepositoryMock) AddAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
}

// AddBeforeCounter returns a count of TagRepositoryMock.Add invocations
func (mmAdd *TagRepositoryMock) AddBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
}

// Calls returns a list of arguments used in each call to TagRepositoryMock.Add.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmAdd *mTagRepositoryMockAdd) Calls() []*TagRepositoryMockAddParams {
	mmAdd.mutex.RLock()

	argCopy := make([]*TagRepositoryMockAddParams, 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 *TagRepositoryMock) MinimockAddDone() bool {
	if m.AddMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.AddMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.AddMock.invocationsDone()
}

// MinimockAddInspect logs each unmet expectation
func (m *TagRepositoryMock) MinimockAddInspect() {
	for _, e := range m.AddMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to TagRepositoryMock.Add with params: %#v", *e.params)
		}
	}

	afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
		if m.AddMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to TagRepositoryMock.Add")
		} else {
			m.t.Errorf("Expected call to TagRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcAdd != nil && afterAddCounter < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Add")
	}

	if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
		m.t.Errorf("Expected %d calls to TagRepositoryMock.Add but found %d calls",
			mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
	}
}

type mTagRepositoryMockDelete struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockDeleteExpectation
	expectations       []*TagRepositoryMockDeleteExpectation

	callArgs []*TagRepositoryMockDeleteParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockDeleteExpectation specifies expectation struct of the TagRepository.Delete
type TagRepositoryMockDeleteExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockDeleteParams
	paramPtrs *TagRepositoryMockDeleteParamPtrs
	results   *TagRepositoryMockDeleteResults
	Counter   uint64
}

// TagRepositoryMockDeleteParams contains parameters of the TagRepository.Delete
type TagRepositoryMockDeleteParams struct {
	ctx context.Context
	id  uint64
}

// TagRepositoryMockDeleteParamPtrs contains pointers to parameters of the TagRepository.Delete
type TagRepositoryMockDeleteParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// TagRepositoryMockDeleteResults contains results of the TagRepository.Delete
type TagRepositoryMockDeleteResults struct {
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmDelete *mTagRepositoryMockDelete) Optional() *mTagRepositoryMockDelete {
	mmDelete.optional = true
	return mmDelete
}

// Expect sets up expected params for TagRepository.Delete
func (mmDelete *mTagRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mTagRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &TagRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.paramPtrs != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by ExpectParams functions")
	}

	mmDelete.defaultExpectation.params = &TagRepositoryMockDeleteParams{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
}

// ExpectCtxParam1 sets up expected param ctx for TagRepository.Delete
func (mmDelete *mTagRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &TagRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.params != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Expect")
	}

	if mmDelete.defaultExpectation.paramPtrs == nil {
		mmDelete.defaultExpectation.paramPtrs = &TagRepositoryMockDeleteParamPtrs{}
	}
	mmDelete.defaultExpectation.paramPtrs.ctx = &ctx

	return mmDelete
}

// ExpectIdParam2 sets up expected param id for TagRepository.Delete
func (mmDelete *mTagRepositoryMockDelete) ExpectIdParam2(id uint64) *mTagRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &TagRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.params != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Expect")
	}

	if mmDelete.defaultExpectation.paramPtrs == nil {
		mmDelete.defaultExpectation.paramPtrs = &TagRepositoryMockDeleteParamPtrs{}
	}
	mmDelete.defaultExpectation.paramPtrs.id = &id

	return mmDelete
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.Delete
func (mmDelete *mTagRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mTagRepositoryMockDelete {
	if mmDelete.mock.inspectFuncDelete != nil {
		mmDelete.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.Delete")
	}

	mmDelete.mock.inspectFuncDelete = f

	return mmDelete
}

// Return sets up results that will be returned by TagRepository.Delete
func (mmDelete *mTagRepositoryMockDelete) Return(err error) *TagRepositoryMock {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &TagRepositoryMockDeleteExpectation{mock: mmDelete.mock}
	}
	mmDelete.defaultExpectation.results = &TagRepositoryMockDeleteResults{err}
	return mmDelete.mock
}

// Set uses given function f to mock the TagRepository.Delete method
func (mmDelete *mTagRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *TagRepositoryMock {
	if mmDelete.defaultExpectation != nil {
		mmDelete.mock.t.Fatalf("Default expectation is already set for the TagRepository.Delete method")
	}

	if len(mmDelete.expectations) > 0 {
		mmDelete.mock.t.Fatalf("Some expectations are already set for the TagRepository.Delete method")
	}

	mmDelete.mock.funcDelete = f
	return mmDelete.mock
}

// When sets expectation for the TagRepository.Delete which will trigger the result defined by the following
// Then helper
func (mmDelete *mTagRepositoryMockDelete) When(ctx context.Context, id uint64) *TagRepositoryMockDeleteExpectation {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
	}

	expectation := &TagRepositoryMockDeleteExpectation{
		mock:   mmDelete.mock,
		params: &TagRepositoryMockDeleteParams{ctx, id},
	}
	mmDelete.expectations = append(mmDelete.expectations, expectation)
	return expectation
}

// Then sets up TagRepository.Delete return parameters for the expectation previously defined by the When method
func (e *TagRepositoryMockDeleteExpectation) Then(err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockDeleteResults{err}
	return e.mock
}

// Times sets number of times TagRepository.Delete should be invoked
func (mmDelete *mTagRepositoryMockDelete) Times(n uint64) *mTagRepositoryMockDelete {
	if n == 0 {
		mmDelete.mock.t.Fatalf("Times of TagRepositoryMock.Delete mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
	return mmDelete
}

func (mmDelete *mTagRepositoryMockDelete) invocationsDone() bool {
	if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Delete implements tag.TagRepository
func (mmDelete *TagRepositoryMock) Delete(ctx context.Context, id uint64) (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 := TagRepositoryMockDeleteParams{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_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs

		mm_got := TagRepositoryMockDeleteParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmDelete.t.Errorf("TagRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmDelete.t.Errorf("TagRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmDelete.t.Errorf("TagRepositoryMock.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 TagRepositoryMock.Delete")
		}
		return (*mm_results).err
	}
	if mmDelete.funcDelete != nil {
		return mmDelete.funcDelete(ctx, id)
	}
	mmDelete.t.Fatalf("Unexpected call to TagRepositoryMock.Delete. %v %v", ctx, id)
	return
}

// DeleteAfterCounter returns a count of finished TagRepositoryMock.Delete invocations
func (mmDelete *TagRepositoryMock) DeleteAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
}

// DeleteBeforeCounter returns a count of TagRepositoryMock.Delete invocations
func (mmDelete *TagRepositoryMock) DeleteBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
}

// Calls returns a list of arguments used in each call to TagRepositoryMock.Delete.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmDelete *mTagRepositoryMockDelete) Calls() []*TagRepositoryMockDeleteParams {
	mmDelete.mutex.RLock()

	argCopy := make([]*TagRepositoryMockDeleteParams, 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 *TagRepositoryMock) MinimockDeleteDone() bool {
	if m.DeleteMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.DeleteMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.DeleteMock.invocationsDone()
}

// MinimockDeleteInspect logs each unmet expectation
func (m *TagRepositoryMock) MinimockDeleteInspect() {
	for _, e := range m.DeleteMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to TagRepositoryMock.Delete with params: %#v", *e.params)
		}
	}

	afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
		if m.DeleteMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to TagRepositoryMock.Delete")
		} else {
			m.t.Errorf("Expected call to TagRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcDelete != nil && afterDeleteCounter < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Delete")
	}

	if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
		m.t.Errorf("Expected %d calls to TagRepositoryMock.Delete but found %d calls",
			mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
	}
}

type mTagRepositoryMockGet struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockGetExpectation
	expectations       []*TagRepositoryMockGetExpectation

	callArgs []*TagRepositoryMockGetParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockGetExpectation specifies expectation struct of the TagRepository.Get
type TagRepositoryMockGetExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockGetParams
	paramPtrs *TagRepositoryMockGetParamPtrs
	results   *TagRepositoryMockGetResults
	Counter   uint64
}

// TagRepositoryMockGetParams contains parameters of the TagRepository.Get
type TagRepositoryMockGetParams struct {
	ctx context.Context
	id  uint64
}

// TagRepositoryMockGetParamPtrs contains pointers to parameters of the TagRepository.Get
type TagRepositoryMockGetParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// TagRepositoryMockGetResults contains results of the TagRepository.Get
type TagRepositoryMockGetResults struct {
	tp1 *models.Tag
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmGet *mTagRepositoryMockGet) Optional() *mTagRepositoryMockGet {
	mmGet.optional = true
	return mmGet
}

// Expect sets up expected params for TagRepository.Get
func (mmGet *mTagRepositoryMockGet) Expect(ctx context.Context, id uint64) *mTagRepositoryMockGet {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &TagRepositoryMockGetExpectation{}
	}

	if mmGet.defaultExpectation.paramPtrs != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by ExpectParams functions")
	}

	mmGet.defaultExpectation.params = &TagRepositoryMockGetParams{ctx, id}
	for _, e := range mmGet.expectations {
		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
		}
	}

	return mmGet
}

// ExpectCtxParam1 sets up expected param ctx for TagRepository.Get
func (mmGet *mTagRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockGet {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &TagRepositoryMockGetExpectation{}
	}

	if mmGet.defaultExpectation.params != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by Expect")
	}

	if mmGet.defaultExpectation.paramPtrs == nil {
		mmGet.defaultExpectation.paramPtrs = &TagRepositoryMockGetParamPtrs{}
	}
	mmGet.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGet
}

// ExpectIdParam2 sets up expected param id for TagRepository.Get
func (mmGet *mTagRepositoryMockGet) ExpectIdParam2(id uint64) *mTagRepositoryMockGet {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &TagRepositoryMockGetExpectation{}
	}

	if mmGet.defaultExpectation.params != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by Expect")
	}

	if mmGet.defaultExpectation.paramPtrs == nil {
		mmGet.defaultExpectation.paramPtrs = &TagRepositoryMockGetParamPtrs{}
	}
	mmGet.defaultExpectation.paramPtrs.id = &id

	return mmGet
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.Get
func (mmGet *mTagRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mTagRepositoryMockGet {
	if mmGet.mock.inspectFuncGet != nil {
		mmGet.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.Get")
	}

	mmGet.mock.inspectFuncGet = f

	return mmGet
}

// Return sets up results that will be returned by TagRepository.Get
func (mmGet *mTagRepositoryMockGet) Return(tp1 *models.Tag, err error) *TagRepositoryMock {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &TagRepositoryMockGetExpectation{mock: mmGet.mock}
	}
	mmGet.defaultExpectation.results = &TagRepositoryMockGetResults{tp1, err}
	return mmGet.mock
}

// Set uses given function f to mock the TagRepository.Get method
func (mmGet *mTagRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (tp1 *models.Tag, err error)) *TagRepositoryMock {
	if mmGet.defaultExpectation != nil {
		mmGet.mock.t.Fatalf("Default expectation is already set for the TagRepository.Get method")
	}

	if len(mmGet.expectations) > 0 {
		mmGet.mock.t.Fatalf("Some expectations are already set for the TagRepository.Get method")
	}

	mmGet.mock.funcGet = f
	return mmGet.mock
}

// When sets expectation for the TagRepository.Get which will trigger the result defined by the following
// Then helper
func (mmGet *mTagRepositoryMockGet) When(ctx context.Context, id uint64) *TagRepositoryMockGetExpectation {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("TagRepositoryMock.Get mock is already set by Set")
	}

	expectation := &TagRepositoryMockGetExpectation{
		mock:   mmGet.mock,
		params: &TagRepositoryMockGetParams{ctx, id},
	}
	mmGet.expectations = append(mmGet.expectations, expectation)
	return expectation
}

// Then sets up TagRepository.Get return parameters for the expectation previously defined by the When method
func (e *TagRepositoryMockGetExpectation) Then(tp1 *models.Tag, err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockGetResults{tp1, err}
	return e.mock
}

// Times sets number of times TagRepository.Get should be invoked
func (mmGet *mTagRepositoryMockGet) Times(n uint64) *mTagRepositoryMockGet {
	if n == 0 {
		mmGet.mock.t.Fatalf("Times of TagRepositoryMock.Get mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
	return mmGet
}

func (mmGet *mTagRepositoryMockGet) invocationsDone() bool {
	if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Get implements tag.TagRepository
func (mmGet *TagRepositoryMock) Get(ctx context.Context, id uint64) (tp1 *models.Tag, err error) {
	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)

	if mmGet.inspectFuncGet != nil {
		mmGet.inspectFuncGet(ctx, id)
	}

	mm_params := TagRepositoryMockGetParams{ctx, id}

	// Record call args
	mmGet.GetMock.mutex.Lock()
	mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
	mmGet.GetMock.mutex.Unlock()

	for _, e := range mmGet.GetMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.tp1, e.results.err
		}
	}

	if mmGet.GetMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
		mm_want := mmGet.GetMock.defaultExpectation.params
		mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs

		mm_got := TagRepositoryMockGetParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGet.t.Errorf("TagRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmGet.t.Errorf("TagRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmGet.t.Errorf("TagRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmGet.GetMock.defaultExpectation.results
		if mm_results == nil {
			mmGet.t.Fatal("No results are set for the TagRepositoryMock.Get")
		}
		return (*mm_results).tp1, (*mm_results).err
	}
	if mmGet.funcGet != nil {
		return mmGet.funcGet(ctx, id)
	}
	mmGet.t.Fatalf("Unexpected call to TagRepositoryMock.Get. %v %v", ctx, id)
	return
}

// GetAfterCounter returns a count of finished TagRepositoryMock.Get invocations
func (mmGet *TagRepositoryMock) GetAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
}

// GetBeforeCounter returns a count of TagRepositoryMock.Get invocations
func (mmGet *TagRepositoryMock) GetBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
}

// Calls returns a list of arguments used in each call to TagRepositoryMock.Get.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmGet *mTagRepositoryMockGet) Calls() []*TagRepositoryMockGetParams {
	mmGet.mutex.RLock()

	argCopy := make([]*TagRepositoryMockGetParams, len(mmGet.callArgs))
	copy(argCopy, mmGet.callArgs)

	mmGet.mutex.RUnlock()

	return argCopy
}

// MinimockGetDone returns true if the count of the Get invocations corresponds
// the number of defined expectations
func (m *TagRepositoryMock) MinimockGetDone() bool {
	if m.GetMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.GetMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.GetMock.invocationsDone()
}

// MinimockGetInspect logs each unmet expectation
func (m *TagRepositoryMock) MinimockGetInspect() {
	for _, e := range m.GetMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to TagRepositoryMock.Get with params: %#v", *e.params)
		}
	}

	afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
		if m.GetMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to TagRepositoryMock.Get")
		} else {
			m.t.Errorf("Expected call to TagRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGet != nil && afterGetCounter < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Get")
	}

	if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
		m.t.Errorf("Expected %d calls to TagRepositoryMock.Get but found %d calls",
			mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
	}
}

type mTagRepositoryMockGetAll struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockGetAllExpectation
	expectations       []*TagRepositoryMockGetAllExpectation

	callArgs []*TagRepositoryMockGetAllParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockGetAllExpectation specifies expectation struct of the TagRepository.GetAll
type TagRepositoryMockGetAllExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockGetAllParams
	paramPtrs *TagRepositoryMockGetAllParamPtrs
	results   *TagRepositoryMockGetAllResults
	Counter   uint64
}

// TagRepositoryMockGetAllParams contains parameters of the TagRepository.GetAll
type TagRepositoryMockGetAllParams struct {
	ctx context.Context
}

// TagRepositoryMockGetAllParamPtrs contains pointers to parameters of the TagRepository.GetAll
type TagRepositoryMockGetAllParamPtrs struct {
	ctx *context.Context
}

// TagRepositoryMockGetAllResults contains results of the TagRepository.GetAll
type TagRepositoryMockGetAllResults struct {
	ta1 []models.Tag
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmGetAll *mTagRepositoryMockGetAll) Optional() *mTagRepositoryMockGetAll {
	mmGetAll.optional = true
	return mmGetAll
}

// Expect sets up expected params for TagRepository.GetAll
func (mmGetAll *mTagRepositoryMockGetAll) Expect(ctx context.Context) *mTagRepositoryMockGetAll {
	if mmGetAll.mock.funcGetAll != nil {
		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Set")
	}

	if mmGetAll.defaultExpectation == nil {
		mmGetAll.defaultExpectation = &TagRepositoryMockGetAllExpectation{}
	}

	if mmGetAll.defaultExpectation.paramPtrs != nil {
		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by ExpectParams functions")
	}

	mmGetAll.defaultExpectation.params = &TagRepositoryMockGetAllParams{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
}

// ExpectCtxParam1 sets up expected param ctx for TagRepository.GetAll
func (mmGetAll *mTagRepositoryMockGetAll) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockGetAll {
	if mmGetAll.mock.funcGetAll != nil {
		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Set")
	}

	if mmGetAll.defaultExpectation == nil {
		mmGetAll.defaultExpectation = &TagRepositoryMockGetAllExpectation{}
	}

	if mmGetAll.defaultExpectation.params != nil {
		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Expect")
	}

	if mmGetAll.defaultExpectation.paramPtrs == nil {
		mmGetAll.defaultExpectation.paramPtrs = &TagRepositoryMockGetAllParamPtrs{}
	}
	mmGetAll.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGetAll
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.GetAll
func (mmGetAll *mTagRepositoryMockGetAll) Inspect(f func(ctx context.Context)) *mTagRepositoryMockGetAll {
	if mmGetAll.mock.inspectFuncGetAll != nil {
		mmGetAll.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetAll")
	}

	mmGetAll.mock.inspectFuncGetAll = f

	return mmGetAll
}

// Return sets up results that will be returned by TagRepository.GetAll
func (mmGetAll *mTagRepositoryMockGetAll) Return(ta1 []models.Tag, err error) *TagRepositoryMock {
	if mmGetAll.mock.funcGetAll != nil {
		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Set")
	}

	if mmGetAll.defaultExpectation == nil {
		mmGetAll.defaultExpectation = &TagRepositoryMockGetAllExpectation{mock: mmGetAll.mock}
	}
	mmGetAll.defaultExpectation.results = &TagRepositoryMockGetAllResults{ta1, err}
	return mmGetAll.mock
}

// Set uses given function f to mock the TagRepository.GetAll method
func (mmGetAll *mTagRepositoryMockGetAll) Set(f func(ctx context.Context) (ta1 []models.Tag, err error)) *TagRepositoryMock {
	if mmGetAll.defaultExpectation != nil {
		mmGetAll.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetAll method")
	}

	if len(mmGetAll.expectations) > 0 {
		mmGetAll.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetAll method")
	}

	mmGetAll.mock.funcGetAll = f
	return mmGetAll.mock
}

// When sets expectation for the TagRepository.GetAll which will trigger the result defined by the following
// Then helper
func (mmGetAll *mTagRepositoryMockGetAll) When(ctx context.Context) *TagRepositoryMockGetAllExpectation {
	if mmGetAll.mock.funcGetAll != nil {
		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Set")
	}

	expectation := &TagRepositoryMockGetAllExpectation{
		mock:   mmGetAll.mock,
		params: &TagRepositoryMockGetAllParams{ctx},
	}
	mmGetAll.expectations = append(mmGetAll.expectations, expectation)
	return expectation
}

// Then sets up TagRepository.GetAll return parameters for the expectation previously defined by the When method
func (e *TagRepositoryMockGetAllExpectation) Then(ta1 []models.Tag, err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockGetAllResults{ta1, err}
	return e.mock
}

// Times sets number of times TagRepository.GetAll should be invoked
func (mmGetAll *mTagRepositoryMockGetAll) Times(n uint64) *mTagRepositoryMockGetAll {
	if n == 0 {
		mmGetAll.mock.t.Fatalf("Times of TagRepositoryMock.GetAll mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmGetAll.expectedInvocations, n)
	return mmGetAll
}

func (mmGetAll *mTagRepositoryMockGetAll) invocationsDone() bool {
	if len(mmGetAll.expectations) == 0 && mmGetAll.defaultExpectation == nil && mmGetAll.mock.funcGetAll == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGetAll.mock.afterGetAllCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGetAll.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// GetAll implements tag.TagRepository
func (mmGetAll *TagRepositoryMock) 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 := TagRepositoryMockGetAllParams{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_want_ptrs := mmGetAll.GetAllMock.defaultExpectation.paramPtrs

		mm_got := TagRepositoryMockGetAllParams{ctx}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGetAll.t.Errorf("TagRepositoryMock.GetAll got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmGetAll.t.Errorf("TagRepositoryMock.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 TagRepositoryMock.GetAll")
		}
		return (*mm_results).ta1, (*mm_results).err
	}
	if mmGetAll.funcGetAll != nil {
		return mmGetAll.funcGetAll(ctx)
	}
	mmGetAll.t.Fatalf("Unexpected call to TagRepositoryMock.GetAll. %v", ctx)
	return
}

// GetAllAfterCounter returns a count of finished TagRepositoryMock.GetAll invocations
func (mmGetAll *TagRepositoryMock) GetAllAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter)
}

// GetAllBeforeCounter returns a count of TagRepositoryMock.GetAll invocations
func (mmGetAll *TagRepositoryMock) GetAllBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter)
}

// Calls returns a list of arguments used in each call to TagRepositoryMock.GetAll.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmGetAll *mTagRepositoryMockGetAll) Calls() []*TagRepositoryMockGetAllParams {
	mmGetAll.mutex.RLock()

	argCopy := make([]*TagRepositoryMockGetAllParams, 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 *TagRepositoryMock) MinimockGetAllDone() bool {
	if m.GetAllMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.GetAllMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.GetAllMock.invocationsDone()
}

// MinimockGetAllInspect logs each unmet expectation
func (m *TagRepositoryMock) MinimockGetAllInspect() {
	for _, e := range m.GetAllMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to TagRepositoryMock.GetAll with params: %#v", *e.params)
		}
	}

	afterGetAllCounter := mm_atomic.LoadUint64(&m.afterGetAllCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.GetAllMock.defaultExpectation != nil && afterGetAllCounter < 1 {
		if m.GetAllMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to TagRepositoryMock.GetAll")
		} else {
			m.t.Errorf("Expected call to TagRepositoryMock.GetAll with params: %#v", *m.GetAllMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGetAll != nil && afterGetAllCounter < 1 {
		m.t.Error("Expected call to TagRepositoryMock.GetAll")
	}

	if !m.GetAllMock.invocationsDone() && afterGetAllCounter > 0 {
		m.t.Errorf("Expected %d calls to TagRepositoryMock.GetAll but found %d calls",
			mm_atomic.LoadUint64(&m.GetAllMock.expectedInvocations), afterGetAllCounter)
	}
}

type mTagRepositoryMockGetByThingID struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockGetByThingIDExpectation
	expectations       []*TagRepositoryMockGetByThingIDExpectation

	callArgs []*TagRepositoryMockGetByThingIDParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockGetByThingIDExpectation specifies expectation struct of the TagRepository.GetByThingID
type TagRepositoryMockGetByThingIDExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockGetByThingIDParams
	paramPtrs *TagRepositoryMockGetByThingIDParamPtrs
	results   *TagRepositoryMockGetByThingIDResults
	Counter   uint64
}

// TagRepositoryMockGetByThingIDParams contains parameters of the TagRepository.GetByThingID
type TagRepositoryMockGetByThingIDParams struct {
	ctx context.Context
	id  uint64
}

// TagRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the TagRepository.GetByThingID
type TagRepositoryMockGetByThingIDParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// TagRepositoryMockGetByThingIDResults contains results of the TagRepository.GetByThingID
type TagRepositoryMockGetByThingIDResults struct {
	ta1 []models.Tag
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Optional() *mTagRepositoryMockGetByThingID {
	mmGetByThingID.optional = true
	return mmGetByThingID
}

// Expect sets up expected params for TagRepository.GetByThingID
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Expect(ctx context.Context, id uint64) *mTagRepositoryMockGetByThingID {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by Set")
	}

	if mmGetByThingID.defaultExpectation == nil {
		mmGetByThingID.defaultExpectation = &TagRepositoryMockGetByThingIDExpectation{}
	}

	if mmGetByThingID.defaultExpectation.paramPtrs != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
	}

	mmGetByThingID.defaultExpectation.params = &TagRepositoryMockGetByThingIDParams{ctx, id}
	for _, e := range mmGetByThingID.expectations {
		if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
			mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
		}
	}

	return mmGetByThingID
}

// ExpectCtxParam1 sets up expected param ctx for TagRepository.GetByThingID
func (mmGetByThingID *mTagRepositoryMockGetByThingID) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockGetByThingID {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by Set")
	}

	if mmGetByThingID.defaultExpectation == nil {
		mmGetByThingID.defaultExpectation = &TagRepositoryMockGetByThingIDExpectation{}
	}

	if mmGetByThingID.defaultExpectation.params != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by Expect")
	}

	if mmGetByThingID.defaultExpectation.paramPtrs == nil {
		mmGetByThingID.defaultExpectation.paramPtrs = &TagRepositoryMockGetByThingIDParamPtrs{}
	}
	mmGetByThingID.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGetByThingID
}

// ExpectIdParam2 sets up expected param id for TagRepository.GetByThingID
func (mmGetByThingID *mTagRepositoryMockGetByThingID) ExpectIdParam2(id uint64) *mTagRepositoryMockGetByThingID {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by Set")
	}

	if mmGetByThingID.defaultExpectation == nil {
		mmGetByThingID.defaultExpectation = &TagRepositoryMockGetByThingIDExpectation{}
	}

	if mmGetByThingID.defaultExpectation.params != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by Expect")
	}

	if mmGetByThingID.defaultExpectation.paramPtrs == nil {
		mmGetByThingID.defaultExpectation.paramPtrs = &TagRepositoryMockGetByThingIDParamPtrs{}
	}
	mmGetByThingID.defaultExpectation.paramPtrs.id = &id

	return mmGetByThingID
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.GetByThingID
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, id uint64)) *mTagRepositoryMockGetByThingID {
	if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetByThingID")
	}

	mmGetByThingID.mock.inspectFuncGetByThingID = f

	return mmGetByThingID
}

// Return sets up results that will be returned by TagRepository.GetByThingID
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Return(ta1 []models.Tag, err error) *TagRepositoryMock {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by Set")
	}

	if mmGetByThingID.defaultExpectation == nil {
		mmGetByThingID.defaultExpectation = &TagRepositoryMockGetByThingIDExpectation{mock: mmGetByThingID.mock}
	}
	mmGetByThingID.defaultExpectation.results = &TagRepositoryMockGetByThingIDResults{ta1, err}
	return mmGetByThingID.mock
}

// Set uses given function f to mock the TagRepository.GetByThingID method
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Tag, err error)) *TagRepositoryMock {
	if mmGetByThingID.defaultExpectation != nil {
		mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetByThingID method")
	}

	if len(mmGetByThingID.expectations) > 0 {
		mmGetByThingID.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetByThingID method")
	}

	mmGetByThingID.mock.funcGetByThingID = f
	return mmGetByThingID.mock
}

// When sets expectation for the TagRepository.GetByThingID which will trigger the result defined by the following
// Then helper
func (mmGetByThingID *mTagRepositoryMockGetByThingID) When(ctx context.Context, id uint64) *TagRepositoryMockGetByThingIDExpectation {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("TagRepositoryMock.GetByThingID mock is already set by Set")
	}

	expectation := &TagRepositoryMockGetByThingIDExpectation{
		mock:   mmGetByThingID.mock,
		params: &TagRepositoryMockGetByThingIDParams{ctx, id},
	}
	mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
	return expectation
}

// Then sets up TagRepository.GetByThingID return parameters for the expectation previously defined by the When method
func (e *TagRepositoryMockGetByThingIDExpectation) Then(ta1 []models.Tag, err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockGetByThingIDResults{ta1, err}
	return e.mock
}

// Times sets number of times TagRepository.GetByThingID should be invoked
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Times(n uint64) *mTagRepositoryMockGetByThingID {
	if n == 0 {
		mmGetByThingID.mock.t.Fatalf("Times of TagRepositoryMock.GetByThingID mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmGetByThingID.expectedInvocations, n)
	return mmGetByThingID
}

func (mmGetByThingID *mTagRepositoryMockGetByThingID) invocationsDone() bool {
	if len(mmGetByThingID.expectations) == 0 && mmGetByThingID.defaultExpectation == nil && mmGetByThingID.mock.funcGetByThingID == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGetByThingID.mock.afterGetByThingIDCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGetByThingID.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// GetByThingID implements tag.TagRepository
func (mmGetByThingID *TagRepositoryMock) GetByThingID(ctx context.Context, id uint64) (ta1 []models.Tag, err error) {
	mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
	defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)

	if mmGetByThingID.inspectFuncGetByThingID != nil {
		mmGetByThingID.inspectFuncGetByThingID(ctx, id)
	}

	mm_params := TagRepositoryMockGetByThingIDParams{ctx, id}

	// Record call args
	mmGetByThingID.GetByThingIDMock.mutex.Lock()
	mmGetByThingID.GetByThingIDMock.callArgs = append(mmGetByThingID.GetByThingIDMock.callArgs, &mm_params)
	mmGetByThingID.GetByThingIDMock.mutex.Unlock()

	for _, e := range mmGetByThingID.GetByThingIDMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.ta1, e.results.err
		}
	}

	if mmGetByThingID.GetByThingIDMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmGetByThingID.GetByThingIDMock.defaultExpectation.Counter, 1)
		mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
		mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs

		mm_got := TagRepositoryMockGetByThingIDParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGetByThingID.t.Errorf("TagRepositoryMock.GetByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmGetByThingID.t.Errorf("TagRepositoryMock.GetByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmGetByThingID.t.Errorf("TagRepositoryMock.GetByThingID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmGetByThingID.GetByThingIDMock.defaultExpectation.results
		if mm_results == nil {
			mmGetByThingID.t.Fatal("No results are set for the TagRepositoryMock.GetByThingID")
		}
		return (*mm_results).ta1, (*mm_results).err
	}
	if mmGetByThingID.funcGetByThingID != nil {
		return mmGetByThingID.funcGetByThingID(ctx, id)
	}
	mmGetByThingID.t.Fatalf("Unexpected call to TagRepositoryMock.GetByThingID. %v %v", ctx, id)
	return
}

// GetByThingIDAfterCounter returns a count of finished TagRepositoryMock.GetByThingID invocations
func (mmGetByThingID *TagRepositoryMock) GetByThingIDAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByThingID.afterGetByThingIDCounter)
}

// GetByThingIDBeforeCounter returns a count of TagRepositoryMock.GetByThingID invocations
func (mmGetByThingID *TagRepositoryMock) GetByThingIDBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByThingID.beforeGetByThingIDCounter)
}

// Calls returns a list of arguments used in each call to TagRepositoryMock.GetByThingID.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Calls() []*TagRepositoryMockGetByThingIDParams {
	mmGetByThingID.mutex.RLock()

	argCopy := make([]*TagRepositoryMockGetByThingIDParams, len(mmGetByThingID.callArgs))
	copy(argCopy, mmGetByThingID.callArgs)

	mmGetByThingID.mutex.RUnlock()

	return argCopy
}

// MinimockGetByThingIDDone returns true if the count of the GetByThingID invocations corresponds
// the number of defined expectations
func (m *TagRepositoryMock) MinimockGetByThingIDDone() bool {
	if m.GetByThingIDMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.GetByThingIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.GetByThingIDMock.invocationsDone()
}

// MinimockGetByThingIDInspect logs each unmet expectation
func (m *TagRepositoryMock) MinimockGetByThingIDInspect() {
	for _, e := range m.GetByThingIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to TagRepositoryMock.GetByThingID with params: %#v", *e.params)
		}
	}

	afterGetByThingIDCounter := mm_atomic.LoadUint64(&m.afterGetByThingIDCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.GetByThingIDMock.defaultExpectation != nil && afterGetByThingIDCounter < 1 {
		if m.GetByThingIDMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to TagRepositoryMock.GetByThingID")
		} else {
			m.t.Errorf("Expected call to TagRepositoryMock.GetByThingID with params: %#v", *m.GetByThingIDMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGetByThingID != nil && afterGetByThingIDCounter < 1 {
		m.t.Error("Expected call to TagRepositoryMock.GetByThingID")
	}

	if !m.GetByThingIDMock.invocationsDone() && afterGetByThingIDCounter > 0 {
		m.t.Errorf("Expected %d calls to TagRepositoryMock.GetByThingID but found %d calls",
			mm_atomic.LoadUint64(&m.GetByThingIDMock.expectedInvocations), afterGetByThingIDCounter)
	}
}

type mTagRepositoryMockUpdate struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockUpdateExpectation
	expectations       []*TagRepositoryMockUpdateExpectation

	callArgs []*TagRepositoryMockUpdateParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockUpdateExpectation specifies expectation struct of the TagRepository.Update
type TagRepositoryMockUpdateExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockUpdateParams
	paramPtrs *TagRepositoryMockUpdateParamPtrs
	results   *TagRepositoryMockUpdateResults
	Counter   uint64
}

// TagRepositoryMockUpdateParams contains parameters of the TagRepository.Update
type TagRepositoryMockUpdateParams struct {
	ctx context.Context
	req models.UpdateTagRequest
}

// TagRepositoryMockUpdateParamPtrs contains pointers to parameters of the TagRepository.Update
type TagRepositoryMockUpdateParamPtrs struct {
	ctx *context.Context
	req *models.UpdateTagRequest
}

// TagRepositoryMockUpdateResults contains results of the TagRepository.Update
type TagRepositoryMockUpdateResults struct {
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmUpdate *mTagRepositoryMockUpdate) Optional() *mTagRepositoryMockUpdate {
	mmUpdate.optional = true
	return mmUpdate
}

// Expect sets up expected params for TagRepository.Update
func (mmUpdate *mTagRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateTagRequest) *mTagRepositoryMockUpdate {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &TagRepositoryMockUpdateExpectation{}
	}

	if mmUpdate.defaultExpectation.paramPtrs != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by ExpectParams functions")
	}

	mmUpdate.defaultExpectation.params = &TagRepositoryMockUpdateParams{ctx, req}
	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
}

// ExpectCtxParam1 sets up expected param ctx for TagRepository.Update
func (mmUpdate *mTagRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockUpdate {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &TagRepositoryMockUpdateExpectation{}
	}

	if mmUpdate.defaultExpectation.params != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Expect")
	}

	if mmUpdate.defaultExpectation.paramPtrs == nil {
		mmUpdate.defaultExpectation.paramPtrs = &TagRepositoryMockUpdateParamPtrs{}
	}
	mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx

	return mmUpdate
}

// ExpectReqParam2 sets up expected param req for TagRepository.Update
func (mmUpdate *mTagRepositoryMockUpdate) ExpectReqParam2(req models.UpdateTagRequest) *mTagRepositoryMockUpdate {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &TagRepositoryMockUpdateExpectation{}
	}

	if mmUpdate.defaultExpectation.params != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Expect")
	}

	if mmUpdate.defaultExpectation.paramPtrs == nil {
		mmUpdate.defaultExpectation.paramPtrs = &TagRepositoryMockUpdateParamPtrs{}
	}
	mmUpdate.defaultExpectation.paramPtrs.req = &req

	return mmUpdate
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.Update
func (mmUpdate *mTagRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateTagRequest)) *mTagRepositoryMockUpdate {
	if mmUpdate.mock.inspectFuncUpdate != nil {
		mmUpdate.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.Update")
	}

	mmUpdate.mock.inspectFuncUpdate = f

	return mmUpdate
}

// Return sets up results that will be returned by TagRepository.Update
func (mmUpdate *mTagRepositoryMockUpdate) Return(err error) *TagRepositoryMock {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &TagRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
	}
	mmUpdate.defaultExpectation.results = &TagRepositoryMockUpdateResults{err}
	return mmUpdate.mock
}

// Set uses given function f to mock the TagRepository.Update method
func (mmUpdate *mTagRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateTagRequest) (err error)) *TagRepositoryMock {
	if mmUpdate.defaultExpectation != nil {
		mmUpdate.mock.t.Fatalf("Default expectation is already set for the TagRepository.Update method")
	}

	if len(mmUpdate.expectations) > 0 {
		mmUpdate.mock.t.Fatalf("Some expectations are already set for the TagRepository.Update method")
	}

	mmUpdate.mock.funcUpdate = f
	return mmUpdate.mock
}

// When sets expectation for the TagRepository.Update which will trigger the result defined by the following
// Then helper
func (mmUpdate *mTagRepositoryMockUpdate) When(ctx context.Context, req models.UpdateTagRequest) *TagRepositoryMockUpdateExpectation {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
	}

	expectation := &TagRepositoryMockUpdateExpectation{
		mock:   mmUpdate.mock,
		params: &TagRepositoryMockUpdateParams{ctx, req},
	}
	mmUpdate.expectations = append(mmUpdate.expectations, expectation)
	return expectation
}

// Then sets up TagRepository.Update return parameters for the expectation previously defined by the When method
func (e *TagRepositoryMockUpdateExpectation) Then(err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockUpdateResults{err}
	return e.mock
}

// Times sets number of times TagRepository.Update should be invoked
func (mmUpdate *mTagRepositoryMockUpdate) Times(n uint64) *mTagRepositoryMockUpdate {
	if n == 0 {
		mmUpdate.mock.t.Fatalf("Times of TagRepositoryMock.Update mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
	return mmUpdate
}

func (mmUpdate *mTagRepositoryMockUpdate) invocationsDone() bool {
	if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Update implements tag.TagRepository
func (mmUpdate *TagRepositoryMock) Update(ctx context.Context, req models.UpdateTagRequest) (err error) {
	mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
	defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)

	if mmUpdate.inspectFuncUpdate != nil {
		mmUpdate.inspectFuncUpdate(ctx, req)
	}

	mm_params := TagRepositoryMockUpdateParams{ctx, req}

	// 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_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs

		mm_got := TagRepositoryMockUpdateParams{ctx, req}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmUpdate.t.Errorf("TagRepositoryMock.Update got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
				mmUpdate.t.Errorf("TagRepositoryMock.Update got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmUpdate.t.Errorf("TagRepositoryMock.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 TagRepositoryMock.Update")
		}
		return (*mm_results).err
	}
	if mmUpdate.funcUpdate != nil {
		return mmUpdate.funcUpdate(ctx, req)
	}
	mmUpdate.t.Fatalf("Unexpected call to TagRepositoryMock.Update. %v %v", ctx, req)
	return
}

// UpdateAfterCounter returns a count of finished TagRepositoryMock.Update invocations
func (mmUpdate *TagRepositoryMock) UpdateAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
}

// UpdateBeforeCounter returns a count of TagRepositoryMock.Update invocations
func (mmUpdate *TagRepositoryMock) UpdateBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
}

// Calls returns a list of arguments used in each call to TagRepositoryMock.Update.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmUpdate *mTagRepositoryMockUpdate) Calls() []*TagRepositoryMockUpdateParams {
	mmUpdate.mutex.RLock()

	argCopy := make([]*TagRepositoryMockUpdateParams, 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 *TagRepositoryMock) MinimockUpdateDone() bool {
	if m.UpdateMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.UpdateMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.UpdateMock.invocationsDone()
}

// MinimockUpdateInspect logs each unmet expectation
func (m *TagRepositoryMock) MinimockUpdateInspect() {
	for _, e := range m.UpdateMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to TagRepositoryMock.Update with params: %#v", *e.params)
		}
	}

	afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
		if m.UpdateMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to TagRepositoryMock.Update")
		} else {
			m.t.Errorf("Expected call to TagRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcUpdate != nil && afterUpdateCounter < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Update")
	}

	if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
		m.t.Errorf("Expected %d calls to TagRepositoryMock.Update but found %d calls",
			mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
	}
}

// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *TagRepositoryMock) MinimockFinish() {
	m.finishOnce.Do(func() {
		if !m.minimockDone() {
			m.MinimockAddInspect()

			m.MinimockDeleteInspect()

			m.MinimockGetInspect()

			m.MinimockGetAllInspect()

			m.MinimockGetByThingIDInspect()

			m.MinimockUpdateInspect()
		}
	})
}

// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *TagRepositoryMock) 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 *TagRepositoryMock) minimockDone() bool {
	done := true
	return done &&
		m.MinimockAddDone() &&
		m.MinimockDeleteDone() &&
		m.MinimockGetDone() &&
		m.MinimockGetAllDone() &&
		m.MinimockGetByThingIDDone() &&
		m.MinimockUpdateDone()
}
