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

package mocks

//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/service/handler.TagRepository -o tag_repository_minimock.go -n TagRepositoryMock -p mocks

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

	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/model"
	"github.com/gojuno/minimock/v3"
)

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

	funcGetAllUsed          func(ctx context.Context, lang model.LanguageID) (ta1 []model.Tag, err error)
	inspectFuncGetAllUsed   func(ctx context.Context, lang model.LanguageID)
	afterGetAllUsedCounter  uint64
	beforeGetAllUsedCounter uint64
	GetAllUsedMock          mTagRepositoryMockGetAllUsed

	funcGetByURL          func(ctx context.Context, tag string) (tp1 *model.Tag, err error)
	inspectFuncGetByURL   func(ctx context.Context, tag string)
	afterGetByURLCounter  uint64
	beforeGetByURLCounter uint64
	GetByURLMock          mTagRepositoryMockGetByURL
}

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

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

	m.GetAllUsedMock = mTagRepositoryMockGetAllUsed{mock: m}
	m.GetAllUsedMock.callArgs = []*TagRepositoryMockGetAllUsedParams{}

	m.GetByURLMock = mTagRepositoryMockGetByURL{mock: m}
	m.GetByURLMock.callArgs = []*TagRepositoryMockGetByURLParams{}

	t.Cleanup(m.MinimockFinish)

	return m
}

type mTagRepositoryMockGetAllUsed struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockGetAllUsedExpectation
	expectations       []*TagRepositoryMockGetAllUsedExpectation

	callArgs []*TagRepositoryMockGetAllUsedParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockGetAllUsedExpectation specifies expectation struct of the TagRepository.GetAllUsed
type TagRepositoryMockGetAllUsedExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockGetAllUsedParams
	paramPtrs *TagRepositoryMockGetAllUsedParamPtrs
	results   *TagRepositoryMockGetAllUsedResults
	Counter   uint64
}

// TagRepositoryMockGetAllUsedParams contains parameters of the TagRepository.GetAllUsed
type TagRepositoryMockGetAllUsedParams struct {
	ctx  context.Context
	lang model.LanguageID
}

// TagRepositoryMockGetAllUsedParamPtrs contains pointers to parameters of the TagRepository.GetAllUsed
type TagRepositoryMockGetAllUsedParamPtrs struct {
	ctx  *context.Context
	lang *model.LanguageID
}

// TagRepositoryMockGetAllUsedResults contains results of the TagRepository.GetAllUsed
type TagRepositoryMockGetAllUsedResults struct {
	ta1 []model.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 (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Optional() *mTagRepositoryMockGetAllUsed {
	mmGetAllUsed.optional = true
	return mmGetAllUsed
}

// Expect sets up expected params for TagRepository.GetAllUsed
func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Expect(ctx context.Context, lang model.LanguageID) *mTagRepositoryMockGetAllUsed {
	if mmGetAllUsed.mock.funcGetAllUsed != nil {
		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
	}

	if mmGetAllUsed.defaultExpectation == nil {
		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{}
	}

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

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

	return mmGetAllUsed
}

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

	if mmGetAllUsed.defaultExpectation == nil {
		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{}
	}

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

	if mmGetAllUsed.defaultExpectation.paramPtrs == nil {
		mmGetAllUsed.defaultExpectation.paramPtrs = &TagRepositoryMockGetAllUsedParamPtrs{}
	}
	mmGetAllUsed.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGetAllUsed
}

// ExpectLangParam2 sets up expected param lang for TagRepository.GetAllUsed
func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) ExpectLangParam2(lang model.LanguageID) *mTagRepositoryMockGetAllUsed {
	if mmGetAllUsed.mock.funcGetAllUsed != nil {
		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
	}

	if mmGetAllUsed.defaultExpectation == nil {
		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{}
	}

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

	if mmGetAllUsed.defaultExpectation.paramPtrs == nil {
		mmGetAllUsed.defaultExpectation.paramPtrs = &TagRepositoryMockGetAllUsedParamPtrs{}
	}
	mmGetAllUsed.defaultExpectation.paramPtrs.lang = &lang

	return mmGetAllUsed
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.GetAllUsed
func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Inspect(f func(ctx context.Context, lang model.LanguageID)) *mTagRepositoryMockGetAllUsed {
	if mmGetAllUsed.mock.inspectFuncGetAllUsed != nil {
		mmGetAllUsed.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetAllUsed")
	}

	mmGetAllUsed.mock.inspectFuncGetAllUsed = f

	return mmGetAllUsed
}

// Return sets up results that will be returned by TagRepository.GetAllUsed
func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Return(ta1 []model.Tag, err error) *TagRepositoryMock {
	if mmGetAllUsed.mock.funcGetAllUsed != nil {
		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
	}

	if mmGetAllUsed.defaultExpectation == nil {
		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{mock: mmGetAllUsed.mock}
	}
	mmGetAllUsed.defaultExpectation.results = &TagRepositoryMockGetAllUsedResults{ta1, err}
	return mmGetAllUsed.mock
}

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

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

	mmGetAllUsed.mock.funcGetAllUsed = f
	return mmGetAllUsed.mock
}

// When sets expectation for the TagRepository.GetAllUsed which will trigger the result defined by the following
// Then helper
func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) When(ctx context.Context, lang model.LanguageID) *TagRepositoryMockGetAllUsedExpectation {
	if mmGetAllUsed.mock.funcGetAllUsed != nil {
		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
	}

	expectation := &TagRepositoryMockGetAllUsedExpectation{
		mock:   mmGetAllUsed.mock,
		params: &TagRepositoryMockGetAllUsedParams{ctx, lang},
	}
	mmGetAllUsed.expectations = append(mmGetAllUsed.expectations, expectation)
	return expectation
}

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

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

func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) invocationsDone() bool {
	if len(mmGetAllUsed.expectations) == 0 && mmGetAllUsed.defaultExpectation == nil && mmGetAllUsed.mock.funcGetAllUsed == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGetAllUsed.mock.afterGetAllUsedCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGetAllUsed.expectedInvocations)

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

// GetAllUsed implements handler.TagRepository
func (mmGetAllUsed *TagRepositoryMock) GetAllUsed(ctx context.Context, lang model.LanguageID) (ta1 []model.Tag, err error) {
	mm_atomic.AddUint64(&mmGetAllUsed.beforeGetAllUsedCounter, 1)
	defer mm_atomic.AddUint64(&mmGetAllUsed.afterGetAllUsedCounter, 1)

	if mmGetAllUsed.inspectFuncGetAllUsed != nil {
		mmGetAllUsed.inspectFuncGetAllUsed(ctx, lang)
	}

	mm_params := TagRepositoryMockGetAllUsedParams{ctx, lang}

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

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

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

		mm_got := TagRepositoryMockGetAllUsedParams{ctx, lang}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGetAllUsed.t.Errorf("TagRepositoryMock.GetAllUsed 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.lang != nil && !minimock.Equal(*mm_want_ptrs.lang, mm_got.lang) {
				mmGetAllUsed.t.Errorf("TagRepositoryMock.GetAllUsed got unexpected parameter lang, want: %#v, got: %#v%s\n", *mm_want_ptrs.lang, mm_got.lang, minimock.Diff(*mm_want_ptrs.lang, mm_got.lang))
			}

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

		mm_results := mmGetAllUsed.GetAllUsedMock.defaultExpectation.results
		if mm_results == nil {
			mmGetAllUsed.t.Fatal("No results are set for the TagRepositoryMock.GetAllUsed")
		}
		return (*mm_results).ta1, (*mm_results).err
	}
	if mmGetAllUsed.funcGetAllUsed != nil {
		return mmGetAllUsed.funcGetAllUsed(ctx, lang)
	}
	mmGetAllUsed.t.Fatalf("Unexpected call to TagRepositoryMock.GetAllUsed. %v %v", ctx, lang)
	return
}

// GetAllUsedAfterCounter returns a count of finished TagRepositoryMock.GetAllUsed invocations
func (mmGetAllUsed *TagRepositoryMock) GetAllUsedAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetAllUsed.afterGetAllUsedCounter)
}

// GetAllUsedBeforeCounter returns a count of TagRepositoryMock.GetAllUsed invocations
func (mmGetAllUsed *TagRepositoryMock) GetAllUsedBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetAllUsed.beforeGetAllUsedCounter)
}

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

	argCopy := make([]*TagRepositoryMockGetAllUsedParams, len(mmGetAllUsed.callArgs))
	copy(argCopy, mmGetAllUsed.callArgs)

	mmGetAllUsed.mutex.RUnlock()

	return argCopy
}

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

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

	return m.GetAllUsedMock.invocationsDone()
}

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

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

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

type mTagRepositoryMockGetByURL struct {
	optional           bool
	mock               *TagRepositoryMock
	defaultExpectation *TagRepositoryMockGetByURLExpectation
	expectations       []*TagRepositoryMockGetByURLExpectation

	callArgs []*TagRepositoryMockGetByURLParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// TagRepositoryMockGetByURLExpectation specifies expectation struct of the TagRepository.GetByURL
type TagRepositoryMockGetByURLExpectation struct {
	mock      *TagRepositoryMock
	params    *TagRepositoryMockGetByURLParams
	paramPtrs *TagRepositoryMockGetByURLParamPtrs
	results   *TagRepositoryMockGetByURLResults
	Counter   uint64
}

// TagRepositoryMockGetByURLParams contains parameters of the TagRepository.GetByURL
type TagRepositoryMockGetByURLParams struct {
	ctx context.Context
	tag string
}

// TagRepositoryMockGetByURLParamPtrs contains pointers to parameters of the TagRepository.GetByURL
type TagRepositoryMockGetByURLParamPtrs struct {
	ctx *context.Context
	tag *string
}

// TagRepositoryMockGetByURLResults contains results of the TagRepository.GetByURL
type TagRepositoryMockGetByURLResults struct {
	tp1 *model.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 (mmGetByURL *mTagRepositoryMockGetByURL) Optional() *mTagRepositoryMockGetByURL {
	mmGetByURL.optional = true
	return mmGetByURL
}

// Expect sets up expected params for TagRepository.GetByURL
func (mmGetByURL *mTagRepositoryMockGetByURL) Expect(ctx context.Context, tag string) *mTagRepositoryMockGetByURL {
	if mmGetByURL.mock.funcGetByURL != nil {
		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
	}

	if mmGetByURL.defaultExpectation == nil {
		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{}
	}

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

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

	return mmGetByURL
}

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

	if mmGetByURL.defaultExpectation == nil {
		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{}
	}

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

	if mmGetByURL.defaultExpectation.paramPtrs == nil {
		mmGetByURL.defaultExpectation.paramPtrs = &TagRepositoryMockGetByURLParamPtrs{}
	}
	mmGetByURL.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGetByURL
}

// ExpectTagParam2 sets up expected param tag for TagRepository.GetByURL
func (mmGetByURL *mTagRepositoryMockGetByURL) ExpectTagParam2(tag string) *mTagRepositoryMockGetByURL {
	if mmGetByURL.mock.funcGetByURL != nil {
		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
	}

	if mmGetByURL.defaultExpectation == nil {
		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{}
	}

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

	if mmGetByURL.defaultExpectation.paramPtrs == nil {
		mmGetByURL.defaultExpectation.paramPtrs = &TagRepositoryMockGetByURLParamPtrs{}
	}
	mmGetByURL.defaultExpectation.paramPtrs.tag = &tag

	return mmGetByURL
}

// Inspect accepts an inspector function that has same arguments as the TagRepository.GetByURL
func (mmGetByURL *mTagRepositoryMockGetByURL) Inspect(f func(ctx context.Context, tag string)) *mTagRepositoryMockGetByURL {
	if mmGetByURL.mock.inspectFuncGetByURL != nil {
		mmGetByURL.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetByURL")
	}

	mmGetByURL.mock.inspectFuncGetByURL = f

	return mmGetByURL
}

// Return sets up results that will be returned by TagRepository.GetByURL
func (mmGetByURL *mTagRepositoryMockGetByURL) Return(tp1 *model.Tag, err error) *TagRepositoryMock {
	if mmGetByURL.mock.funcGetByURL != nil {
		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
	}

	if mmGetByURL.defaultExpectation == nil {
		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
	}
	mmGetByURL.defaultExpectation.results = &TagRepositoryMockGetByURLResults{tp1, err}
	return mmGetByURL.mock
}

// Set uses given function f to mock the TagRepository.GetByURL method
func (mmGetByURL *mTagRepositoryMockGetByURL) Set(f func(ctx context.Context, tag string) (tp1 *model.Tag, err error)) *TagRepositoryMock {
	if mmGetByURL.defaultExpectation != nil {
		mmGetByURL.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetByURL method")
	}

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

	mmGetByURL.mock.funcGetByURL = f
	return mmGetByURL.mock
}

// When sets expectation for the TagRepository.GetByURL which will trigger the result defined by the following
// Then helper
func (mmGetByURL *mTagRepositoryMockGetByURL) When(ctx context.Context, tag string) *TagRepositoryMockGetByURLExpectation {
	if mmGetByURL.mock.funcGetByURL != nil {
		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
	}

	expectation := &TagRepositoryMockGetByURLExpectation{
		mock:   mmGetByURL.mock,
		params: &TagRepositoryMockGetByURLParams{ctx, tag},
	}
	mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
	return expectation
}

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

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

func (mmGetByURL *mTagRepositoryMockGetByURL) invocationsDone() bool {
	if len(mmGetByURL.expectations) == 0 && mmGetByURL.defaultExpectation == nil && mmGetByURL.mock.funcGetByURL == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGetByURL.mock.afterGetByURLCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGetByURL.expectedInvocations)

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

// GetByURL implements handler.TagRepository
func (mmGetByURL *TagRepositoryMock) GetByURL(ctx context.Context, tag string) (tp1 *model.Tag, err error) {
	mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
	defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)

	if mmGetByURL.inspectFuncGetByURL != nil {
		mmGetByURL.inspectFuncGetByURL(ctx, tag)
	}

	mm_params := TagRepositoryMockGetByURLParams{ctx, tag}

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

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

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

		mm_got := TagRepositoryMockGetByURLParams{ctx, tag}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGetByURL.t.Errorf("TagRepositoryMock.GetByURL 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.tag != nil && !minimock.Equal(*mm_want_ptrs.tag, mm_got.tag) {
				mmGetByURL.t.Errorf("TagRepositoryMock.GetByURL got unexpected parameter tag, want: %#v, got: %#v%s\n", *mm_want_ptrs.tag, mm_got.tag, minimock.Diff(*mm_want_ptrs.tag, mm_got.tag))
			}

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

		mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
		if mm_results == nil {
			mmGetByURL.t.Fatal("No results are set for the TagRepositoryMock.GetByURL")
		}
		return (*mm_results).tp1, (*mm_results).err
	}
	if mmGetByURL.funcGetByURL != nil {
		return mmGetByURL.funcGetByURL(ctx, tag)
	}
	mmGetByURL.t.Fatalf("Unexpected call to TagRepositoryMock.GetByURL. %v %v", ctx, tag)
	return
}

// GetByURLAfterCounter returns a count of finished TagRepositoryMock.GetByURL invocations
func (mmGetByURL *TagRepositoryMock) GetByURLAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
}

// GetByURLBeforeCounter returns a count of TagRepositoryMock.GetByURL invocations
func (mmGetByURL *TagRepositoryMock) GetByURLBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
}

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

	argCopy := make([]*TagRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
	copy(argCopy, mmGetByURL.callArgs)

	mmGetByURL.mutex.RUnlock()

	return argCopy
}

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

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

	return m.GetByURLMock.invocationsDone()
}

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

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

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

// 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.MinimockGetAllUsedInspect()

			m.MinimockGetByURLInspect()
		}
	})
}

// 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.MinimockGetAllUsedDone() &&
		m.MinimockGetByURLDone()
}
