package mocks

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

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

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

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

// TagRepositoryMock implements interfaces.TagRepository
type TagRepositoryMock struct {
	t minimock.Tester

	funcAdd          func(ctx context.Context, req models.AddTagRequest, tx *sql.Tx) (i1 int, err error)
	inspectFuncAdd   func(ctx context.Context, req models.AddTagRequest, tx *sql.Tx)
	afterAddCounter  uint64
	beforeAddCounter uint64
	AddMock          mTagRepositoryMockAdd

	funcBeginTx          func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)
	inspectFuncBeginTx   func(ctx context.Context, level sql.IsolationLevel)
	afterBeginTxCounter  uint64
	beforeBeginTxCounter uint64
	BeginTxMock          mTagRepositoryMockBeginTx

	funcCommitTx          func(tx *sql.Tx) (err error)
	inspectFuncCommitTx   func(tx *sql.Tx)
	afterCommitTxCounter  uint64
	beforeCommitTxCounter uint64
	CommitTxMock          mTagRepositoryMockCommitTx

	funcDelete          func(ctx context.Context, tagID int, tx *sql.Tx) (err error)
	inspectFuncDelete   func(ctx context.Context, tagID int, tx *sql.Tx)
	afterDeleteCounter  uint64
	beforeDeleteCounter uint64
	DeleteMock          mTagRepositoryMockDelete

	funcGet          func(ctx context.Context, tagID int) (tp1 *models.Tag, err error)
	inspectFuncGet   func(ctx context.Context, tagID int)
	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, thingID int) (ta1 []models.Tag, err error)
	inspectFuncGetByThingID   func(ctx context.Context, thingID int)
	afterGetByThingIDCounter  uint64
	beforeGetByThingIDCounter uint64
	GetByThingIDMock          mTagRepositoryMockGetByThingID

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

// NewTagRepositoryMock returns a mock for interfaces.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.BeginTxMock = mTagRepositoryMockBeginTx{mock: m}
	m.BeginTxMock.callArgs = []*TagRepositoryMockBeginTxParams{}

	m.CommitTxMock = mTagRepositoryMockCommitTx{mock: m}
	m.CommitTxMock.callArgs = []*TagRepositoryMockCommitTxParams{}

	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{}

	return m
}

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

	callArgs []*TagRepositoryMockAddParams
	mutex    sync.RWMutex
}

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

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

// TagRepositoryMockAddResults contains results of the TagRepository.Add
type TagRepositoryMockAddResults struct {
	i1  int
	err error
}

// Expect sets up expected params for TagRepository.Add
func (mmAdd *mTagRepositoryMockAdd) Expect(ctx context.Context, req models.AddTagRequest, tx *sql.Tx) *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{}
	}

	mmAdd.defaultExpectation.params = &TagRepositoryMockAddParams{ctx, req, tx}
	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 TagRepository.Add
func (mmAdd *mTagRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddTagRequest, tx *sql.Tx)) *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(i1 int, 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{i1, 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, tx *sql.Tx) (i1 int, 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, tx *sql.Tx) *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, tx},
	}
	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(i1 int, err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockAddResults{i1, err}
	return e.mock
}

// Add implements interfaces.TagRepository
func (mmAdd *TagRepositoryMock) Add(ctx context.Context, req models.AddTagRequest, tx *sql.Tx) (i1 int, err error) {
	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)

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

	mm_params := &TagRepositoryMockAddParams{ctx, req, tx}

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

	if mmAdd.AddMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
		mm_want := mmAdd.AddMock.defaultExpectation.params
		mm_got := TagRepositoryMockAddParams{ctx, req, tx}
		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).i1, (*mm_results).err
	}
	if mmAdd.funcAdd != nil {
		return mmAdd.funcAdd(ctx, req, tx)
	}
	mmAdd.t.Fatalf("Unexpected call to TagRepositoryMock.Add. %v %v %v", ctx, req, tx)
	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 {
	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 *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)
		}
	}

	// 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 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 && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Add")
	}
}

type mTagRepositoryMockBeginTx struct {
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockBeginTxExpectation
	expectations       []*TagRepositoryMockBeginTxExpectation

	callArgs []*TagRepositoryMockBeginTxParams
	mutex    sync.RWMutex
}

// TagRepositoryMockBeginTxExpectation specifies expectation struct of the TagRepository.BeginTx
type TagRepositoryMockBeginTxExpectation struct {
	mock    *TagRepositoryMock
	params  *TagRepositoryMockBeginTxParams
	results *TagRepositoryMockBeginTxResults
	Counter uint64
}

// TagRepositoryMockBeginTxParams contains parameters of the TagRepository.BeginTx
type TagRepositoryMockBeginTxParams struct {
	ctx   context.Context
	level sql.IsolationLevel
}

// TagRepositoryMockBeginTxResults contains results of the TagRepository.BeginTx
type TagRepositoryMockBeginTxResults struct {
	tp1 *sql.Tx
	err error
}

// Expect sets up expected params for TagRepository.BeginTx
func (mmBeginTx *mTagRepositoryMockBeginTx) Expect(ctx context.Context, level sql.IsolationLevel) *mTagRepositoryMockBeginTx {
	if mmBeginTx.mock.funcBeginTx != nil {
		mmBeginTx.mock.t.Fatalf("TagRepositoryMock.BeginTx mock is already set by Set")
	}

	if mmBeginTx.defaultExpectation == nil {
		mmBeginTx.defaultExpectation = &TagRepositoryMockBeginTxExpectation{}
	}

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

	return mmBeginTx
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.BeginTx
func (mmBeginTx *mTagRepositoryMockBeginTx) Inspect(f func(ctx context.Context, level sql.IsolationLevel)) *mTagRepositoryMockBeginTx {
	if mmBeginTx.mock.inspectFuncBeginTx != nil {
		mmBeginTx.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.BeginTx")
	}

	mmBeginTx.mock.inspectFuncBeginTx = f

	return mmBeginTx
}

// Return sets up results that will be returned by TagRepository.BeginTx
func (mmBeginTx *mTagRepositoryMockBeginTx) Return(tp1 *sql.Tx, err error) *TagRepositoryMock {
	if mmBeginTx.mock.funcBeginTx != nil {
		mmBeginTx.mock.t.Fatalf("TagRepositoryMock.BeginTx mock is already set by Set")
	}

	if mmBeginTx.defaultExpectation == nil {
		mmBeginTx.defaultExpectation = &TagRepositoryMockBeginTxExpectation{mock: mmBeginTx.mock}
	}
	mmBeginTx.defaultExpectation.results = &TagRepositoryMockBeginTxResults{tp1, err}
	return mmBeginTx.mock
}

// Set uses given function f to mock the TagRepository.BeginTx method
func (mmBeginTx *mTagRepositoryMockBeginTx) Set(f func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)) *TagRepositoryMock {
	if mmBeginTx.defaultExpectation != nil {
		mmBeginTx.mock.t.Fatalf("Default expectation is already set for the TagRepository.BeginTx method")
	}

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

	mmBeginTx.mock.funcBeginTx = f
	return mmBeginTx.mock
}

// When sets expectation for the TagRepository.BeginTx which will trigger the result defined by the following
// Then helper
func (mmBeginTx *mTagRepositoryMockBeginTx) When(ctx context.Context, level sql.IsolationLevel) *TagRepositoryMockBeginTxExpectation {
	if mmBeginTx.mock.funcBeginTx != nil {
		mmBeginTx.mock.t.Fatalf("TagRepositoryMock.BeginTx mock is already set by Set")
	}

	expectation := &TagRepositoryMockBeginTxExpectation{
		mock:   mmBeginTx.mock,
		params: &TagRepositoryMockBeginTxParams{ctx, level},
	}
	mmBeginTx.expectations = append(mmBeginTx.expectations, expectation)
	return expectation
}

// Then sets up TagRepository.BeginTx return parameters for the expectation previously defined by the When method
func (e *TagRepositoryMockBeginTxExpectation) Then(tp1 *sql.Tx, err error) *TagRepositoryMock {
	e.results = &TagRepositoryMockBeginTxResults{tp1, err}
	return e.mock
}

// BeginTx implements interfaces.TagRepository
func (mmBeginTx *TagRepositoryMock) BeginTx(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error) {
	mm_atomic.AddUint64(&mmBeginTx.beforeBeginTxCounter, 1)
	defer mm_atomic.AddUint64(&mmBeginTx.afterBeginTxCounter, 1)

	if mmBeginTx.inspectFuncBeginTx != nil {
		mmBeginTx.inspectFuncBeginTx(ctx, level)
	}

	mm_params := &TagRepositoryMockBeginTxParams{ctx, level}

	// Record call args
	mmBeginTx.BeginTxMock.mutex.Lock()
	mmBeginTx.BeginTxMock.callArgs = append(mmBeginTx.BeginTxMock.callArgs, mm_params)
	mmBeginTx.BeginTxMock.mutex.Unlock()

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

	if mmBeginTx.BeginTxMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmBeginTx.BeginTxMock.defaultExpectation.Counter, 1)
		mm_want := mmBeginTx.BeginTxMock.defaultExpectation.params
		mm_got := TagRepositoryMockBeginTxParams{ctx, level}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmBeginTx.t.Errorf("TagRepositoryMock.BeginTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmBeginTx.BeginTxMock.defaultExpectation.results
		if mm_results == nil {
			mmBeginTx.t.Fatal("No results are set for the TagRepositoryMock.BeginTx")
		}
		return (*mm_results).tp1, (*mm_results).err
	}
	if mmBeginTx.funcBeginTx != nil {
		return mmBeginTx.funcBeginTx(ctx, level)
	}
	mmBeginTx.t.Fatalf("Unexpected call to TagRepositoryMock.BeginTx. %v %v", ctx, level)
	return
}

// BeginTxAfterCounter returns a count of finished TagRepositoryMock.BeginTx invocations
func (mmBeginTx *TagRepositoryMock) BeginTxAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmBeginTx.afterBeginTxCounter)
}

// BeginTxBeforeCounter returns a count of TagRepositoryMock.BeginTx invocations
func (mmBeginTx *TagRepositoryMock) BeginTxBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmBeginTx.beforeBeginTxCounter)
}

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

	argCopy := make([]*TagRepositoryMockBeginTxParams, len(mmBeginTx.callArgs))
	copy(argCopy, mmBeginTx.callArgs)

	mmBeginTx.mutex.RUnlock()

	return argCopy
}

// MinimockBeginTxDone returns true if the count of the BeginTx invocations corresponds
// the number of defined expectations
func (m *TagRepositoryMock) MinimockBeginTxDone() bool {
	for _, e := range m.BeginTxMock.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.BeginTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcBeginTx != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
		return false
	}
	return true
}

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

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

type mTagRepositoryMockCommitTx struct {
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockCommitTxExpectation
	expectations       []*TagRepositoryMockCommitTxExpectation

	callArgs []*TagRepositoryMockCommitTxParams
	mutex    sync.RWMutex
}

// TagRepositoryMockCommitTxExpectation specifies expectation struct of the TagRepository.CommitTx
type TagRepositoryMockCommitTxExpectation struct {
	mock    *TagRepositoryMock
	params  *TagRepositoryMockCommitTxParams
	results *TagRepositoryMockCommitTxResults
	Counter uint64
}

// TagRepositoryMockCommitTxParams contains parameters of the TagRepository.CommitTx
type TagRepositoryMockCommitTxParams struct {
	tx *sql.Tx
}

// TagRepositoryMockCommitTxResults contains results of the TagRepository.CommitTx
type TagRepositoryMockCommitTxResults struct {
	err error
}

// Expect sets up expected params for TagRepository.CommitTx
func (mmCommitTx *mTagRepositoryMockCommitTx) Expect(tx *sql.Tx) *mTagRepositoryMockCommitTx {
	if mmCommitTx.mock.funcCommitTx != nil {
		mmCommitTx.mock.t.Fatalf("TagRepositoryMock.CommitTx mock is already set by Set")
	}

	if mmCommitTx.defaultExpectation == nil {
		mmCommitTx.defaultExpectation = &TagRepositoryMockCommitTxExpectation{}
	}

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

	return mmCommitTx
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.CommitTx
func (mmCommitTx *mTagRepositoryMockCommitTx) Inspect(f func(tx *sql.Tx)) *mTagRepositoryMockCommitTx {
	if mmCommitTx.mock.inspectFuncCommitTx != nil {
		mmCommitTx.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.CommitTx")
	}

	mmCommitTx.mock.inspectFuncCommitTx = f

	return mmCommitTx
}

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

	if mmCommitTx.defaultExpectation == nil {
		mmCommitTx.defaultExpectation = &TagRepositoryMockCommitTxExpectation{mock: mmCommitTx.mock}
	}
	mmCommitTx.defaultExpectation.results = &TagRepositoryMockCommitTxResults{err}
	return mmCommitTx.mock
}

// Set uses given function f to mock the TagRepository.CommitTx method
func (mmCommitTx *mTagRepositoryMockCommitTx) Set(f func(tx *sql.Tx) (err error)) *TagRepositoryMock {
	if mmCommitTx.defaultExpectation != nil {
		mmCommitTx.mock.t.Fatalf("Default expectation is already set for the TagRepository.CommitTx method")
	}

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

	mmCommitTx.mock.funcCommitTx = f
	return mmCommitTx.mock
}

// When sets expectation for the TagRepository.CommitTx which will trigger the result defined by the following
// Then helper
func (mmCommitTx *mTagRepositoryMockCommitTx) When(tx *sql.Tx) *TagRepositoryMockCommitTxExpectation {
	if mmCommitTx.mock.funcCommitTx != nil {
		mmCommitTx.mock.t.Fatalf("TagRepositoryMock.CommitTx mock is already set by Set")
	}

	expectation := &TagRepositoryMockCommitTxExpectation{
		mock:   mmCommitTx.mock,
		params: &TagRepositoryMockCommitTxParams{tx},
	}
	mmCommitTx.expectations = append(mmCommitTx.expectations, expectation)
	return expectation
}

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

// CommitTx implements interfaces.TagRepository
func (mmCommitTx *TagRepositoryMock) CommitTx(tx *sql.Tx) (err error) {
	mm_atomic.AddUint64(&mmCommitTx.beforeCommitTxCounter, 1)
	defer mm_atomic.AddUint64(&mmCommitTx.afterCommitTxCounter, 1)

	if mmCommitTx.inspectFuncCommitTx != nil {
		mmCommitTx.inspectFuncCommitTx(tx)
	}

	mm_params := &TagRepositoryMockCommitTxParams{tx}

	// Record call args
	mmCommitTx.CommitTxMock.mutex.Lock()
	mmCommitTx.CommitTxMock.callArgs = append(mmCommitTx.CommitTxMock.callArgs, mm_params)
	mmCommitTx.CommitTxMock.mutex.Unlock()

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

	if mmCommitTx.CommitTxMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmCommitTx.CommitTxMock.defaultExpectation.Counter, 1)
		mm_want := mmCommitTx.CommitTxMock.defaultExpectation.params
		mm_got := TagRepositoryMockCommitTxParams{tx}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmCommitTx.t.Errorf("TagRepositoryMock.CommitTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmCommitTx.CommitTxMock.defaultExpectation.results
		if mm_results == nil {
			mmCommitTx.t.Fatal("No results are set for the TagRepositoryMock.CommitTx")
		}
		return (*mm_results).err
	}
	if mmCommitTx.funcCommitTx != nil {
		return mmCommitTx.funcCommitTx(tx)
	}
	mmCommitTx.t.Fatalf("Unexpected call to TagRepositoryMock.CommitTx. %v", tx)
	return
}

// CommitTxAfterCounter returns a count of finished TagRepositoryMock.CommitTx invocations
func (mmCommitTx *TagRepositoryMock) CommitTxAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmCommitTx.afterCommitTxCounter)
}

// CommitTxBeforeCounter returns a count of TagRepositoryMock.CommitTx invocations
func (mmCommitTx *TagRepositoryMock) CommitTxBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmCommitTx.beforeCommitTxCounter)
}

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

	argCopy := make([]*TagRepositoryMockCommitTxParams, len(mmCommitTx.callArgs))
	copy(argCopy, mmCommitTx.callArgs)

	mmCommitTx.mutex.RUnlock()

	return argCopy
}

// MinimockCommitTxDone returns true if the count of the CommitTx invocations corresponds
// the number of defined expectations
func (m *TagRepositoryMock) MinimockCommitTxDone() bool {
	for _, e := range m.CommitTxMock.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.CommitTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcCommitTx != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
		return false
	}
	return true
}

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

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

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

	callArgs []*TagRepositoryMockDeleteParams
	mutex    sync.RWMutex
}

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

// TagRepositoryMockDeleteParams contains parameters of the TagRepository.Delete
type TagRepositoryMockDeleteParams struct {
	ctx   context.Context
	tagID int
	tx    *sql.Tx
}

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

// Expect sets up expected params for TagRepository.Delete
func (mmDelete *mTagRepositoryMockDelete) Expect(ctx context.Context, tagID int, tx *sql.Tx) *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{}
	}

	mmDelete.defaultExpectation.params = &TagRepositoryMockDeleteParams{ctx, tagID, tx}
	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 TagRepository.Delete
func (mmDelete *mTagRepositoryMockDelete) Inspect(f func(ctx context.Context, tagID int, tx *sql.Tx)) *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, tagID int, tx *sql.Tx) (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, tagID int, tx *sql.Tx) *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, tagID, tx},
	}
	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
}

// Delete implements interfaces.TagRepository
func (mmDelete *TagRepositoryMock) Delete(ctx context.Context, tagID int, tx *sql.Tx) (err error) {
	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)

	if mmDelete.inspectFuncDelete != nil {
		mmDelete.inspectFuncDelete(ctx, tagID, tx)
	}

	mm_params := &TagRepositoryMockDeleteParams{ctx, tagID, tx}

	// 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 := TagRepositoryMockDeleteParams{ctx, tagID, tx}
		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, tagID, tx)
	}
	mmDelete.t.Fatalf("Unexpected call to TagRepositoryMock.Delete. %v %v %v", ctx, tagID, tx)
	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 {
	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 *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)
		}
	}

	// 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 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 && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Delete")
	}
}

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

	callArgs []*TagRepositoryMockGetParams
	mutex    sync.RWMutex
}

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

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

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

// Expect sets up expected params for TagRepository.Get
func (mmGet *mTagRepositoryMockGet) Expect(ctx context.Context, tagID int) *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{}
	}

	mmGet.defaultExpectation.params = &TagRepositoryMockGetParams{ctx, tagID}
	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
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.Get
func (mmGet *mTagRepositoryMockGet) Inspect(f func(ctx context.Context, tagID int)) *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, tagID int) (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, tagID int) *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, tagID},
	}
	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
}

// Get implements interfaces.TagRepository
func (mmGet *TagRepositoryMock) Get(ctx context.Context, tagID int) (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, tagID)
	}

	mm_params := &TagRepositoryMockGetParams{ctx, tagID}

	// 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_got := TagRepositoryMockGetParams{ctx, tagID}
		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, tagID)
	}
	mmGet.t.Fatalf("Unexpected call to TagRepositoryMock.Get. %v %v", ctx, tagID)
	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 {
	for _, e := range m.GetMock.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.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
		return false
	}
	return true
}

// 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)
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.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 && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Get")
	}
}

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

	callArgs []*TagRepositoryMockGetAllParams
	mutex    sync.RWMutex
}

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

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

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

// 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{}
	}

	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
}

// 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
}

// GetAll implements interfaces.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_got := TagRepositoryMockGetAllParams{ctx}
		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 {
	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 *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)
		}
	}

	// 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 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 && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
		m.t.Error("Expected call to TagRepositoryMock.GetAll")
	}
}

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

	callArgs []*TagRepositoryMockGetByThingIDParams
	mutex    sync.RWMutex
}

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

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

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

// Expect sets up expected params for TagRepository.GetByThingID
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Expect(ctx context.Context, thingID int) *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{}
	}

	mmGetByThingID.defaultExpectation.params = &TagRepositoryMockGetByThingIDParams{ctx, thingID}
	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
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.GetByThingID
func (mmGetByThingID *mTagRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, thingID int)) *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, thingID int) (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, thingID int) *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, thingID},
	}
	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
}

// GetByThingID implements interfaces.TagRepository
func (mmGetByThingID *TagRepositoryMock) GetByThingID(ctx context.Context, thingID int) (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, thingID)
	}

	mm_params := &TagRepositoryMockGetByThingIDParams{ctx, thingID}

	// 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_got := TagRepositoryMockGetByThingIDParams{ctx, thingID}
		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, thingID)
	}
	mmGetByThingID.t.Fatalf("Unexpected call to TagRepositoryMock.GetByThingID. %v %v", ctx, thingID)
	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 {
	for _, e := range m.GetByThingIDMock.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.GetByThingIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByThingIDCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGetByThingID != nil && mm_atomic.LoadUint64(&m.afterGetByThingIDCounter) < 1 {
		return false
	}
	return true
}

// 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)
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.GetByThingIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.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 && mm_atomic.LoadUint64(&m.afterGetByThingIDCounter) < 1 {
		m.t.Error("Expected call to TagRepositoryMock.GetByThingID")
	}
}

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

	callArgs []*TagRepositoryMockUpdateParams
	mutex    sync.RWMutex
}

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

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

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

// Expect sets up expected params for TagRepository.Update
func (mmUpdate *mTagRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateTagRequest, tx *sql.Tx) *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{}
	}

	mmUpdate.defaultExpectation.params = &TagRepositoryMockUpdateParams{ctx, req, tx}
	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 TagRepository.Update
func (mmUpdate *mTagRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateTagRequest, tx *sql.Tx)) *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, tx *sql.Tx) (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, tx *sql.Tx) *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, tx},
	}
	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
}

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

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

	mm_params := &TagRepositoryMockUpdateParams{ctx, req, tx}

	// 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 := TagRepositoryMockUpdateParams{ctx, req, tx}
		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, tx)
	}
	mmUpdate.t.Fatalf("Unexpected call to TagRepositoryMock.Update. %v %v %v", ctx, req, tx)
	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 {
	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 *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)
		}
	}

	// 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 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 && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
		m.t.Error("Expected call to TagRepositoryMock.Update")
	}
}

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

		m.MinimockBeginTxInspect()

		m.MinimockCommitTxInspect()

		m.MinimockDeleteInspect()

		m.MinimockGetInspect()

		m.MinimockGetAllInspect()

		m.MinimockGetByThingIDInspect()

		m.MinimockUpdateInspect()
		m.t.FailNow()
	}
}

// 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.MinimockBeginTxDone() &&
		m.MinimockCommitTxDone() &&
		m.MinimockDeleteDone() &&
		m.MinimockGetDone() &&
		m.MinimockGetAllDone() &&
		m.MinimockGetByThingIDDone() &&
		m.MinimockUpdateDone()
}
