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

package mocks

//go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/thing.FileRepository -o file_repository_minimock.go -n FileRepositoryMock -p mocks

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

	"github.com/gojuno/minimock/v3"
)

// FileRepositoryMock implements thing.FileRepository
type FileRepositoryMock struct {
	t          minimock.Tester
	finishOnce sync.Once

	funcDelete          func(path string) (err error)
	inspectFuncDelete   func(path string)
	afterDeleteCounter  uint64
	beforeDeleteCounter uint64
	DeleteMock          mFileRepositoryMockDelete
}

// NewFileRepositoryMock returns a mock for thing.FileRepository
func NewFileRepositoryMock(t minimock.Tester) *FileRepositoryMock {
	m := &FileRepositoryMock{t: t}

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

	m.DeleteMock = mFileRepositoryMockDelete{mock: m}
	m.DeleteMock.callArgs = []*FileRepositoryMockDeleteParams{}

	t.Cleanup(m.MinimockFinish)

	return m
}

type mFileRepositoryMockDelete struct {
	optional           bool
	mock               *FileRepositoryMock
	defaultExpectation *FileRepositoryMockDeleteExpectation
	expectations       []*FileRepositoryMockDeleteExpectation

	callArgs []*FileRepositoryMockDeleteParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// FileRepositoryMockDeleteExpectation specifies expectation struct of the FileRepository.Delete
type FileRepositoryMockDeleteExpectation struct {
	mock      *FileRepositoryMock
	params    *FileRepositoryMockDeleteParams
	paramPtrs *FileRepositoryMockDeleteParamPtrs
	results   *FileRepositoryMockDeleteResults
	Counter   uint64
}

// FileRepositoryMockDeleteParams contains parameters of the FileRepository.Delete
type FileRepositoryMockDeleteParams struct {
	path string
}

// FileRepositoryMockDeleteParamPtrs contains pointers to parameters of the FileRepository.Delete
type FileRepositoryMockDeleteParamPtrs struct {
	path *string
}

// FileRepositoryMockDeleteResults contains results of the FileRepository.Delete
type FileRepositoryMockDeleteResults struct {
	err error
}

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

// Expect sets up expected params for FileRepository.Delete
func (mmDelete *mFileRepositoryMockDelete) Expect(path string) *mFileRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Set")
	}

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

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

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

// ExpectPathParam1 sets up expected param path for FileRepository.Delete
func (mmDelete *mFileRepositoryMockDelete) ExpectPathParam1(path string) *mFileRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Set")
	}

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

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

	if mmDelete.defaultExpectation.paramPtrs == nil {
		mmDelete.defaultExpectation.paramPtrs = &FileRepositoryMockDeleteParamPtrs{}
	}
	mmDelete.defaultExpectation.paramPtrs.path = &path

	return mmDelete
}

// Inspect accepts an inspector function that has same arguments as the FileRepository.Delete
func (mmDelete *mFileRepositoryMockDelete) Inspect(f func(path string)) *mFileRepositoryMockDelete {
	if mmDelete.mock.inspectFuncDelete != nil {
		mmDelete.mock.t.Fatalf("Inspect function is already set for FileRepositoryMock.Delete")
	}

	mmDelete.mock.inspectFuncDelete = f

	return mmDelete
}

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

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &FileRepositoryMockDeleteExpectation{mock: mmDelete.mock}
	}
	mmDelete.defaultExpectation.results = &FileRepositoryMockDeleteResults{err}
	return mmDelete.mock
}

// Set uses given function f to mock the FileRepository.Delete method
func (mmDelete *mFileRepositoryMockDelete) Set(f func(path string) (err error)) *FileRepositoryMock {
	if mmDelete.defaultExpectation != nil {
		mmDelete.mock.t.Fatalf("Default expectation is already set for the FileRepository.Delete method")
	}

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

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

// When sets expectation for the FileRepository.Delete which will trigger the result defined by the following
// Then helper
func (mmDelete *mFileRepositoryMockDelete) When(path string) *FileRepositoryMockDeleteExpectation {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Set")
	}

	expectation := &FileRepositoryMockDeleteExpectation{
		mock:   mmDelete.mock,
		params: &FileRepositoryMockDeleteParams{path},
	}
	mmDelete.expectations = append(mmDelete.expectations, expectation)
	return expectation
}

// Then sets up FileRepository.Delete return parameters for the expectation previously defined by the When method
func (e *FileRepositoryMockDeleteExpectation) Then(err error) *FileRepositoryMock {
	e.results = &FileRepositoryMockDeleteResults{err}
	return e.mock
}

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

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

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

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

// Delete implements thing.FileRepository
func (mmDelete *FileRepositoryMock) Delete(path string) (err error) {
	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)

	if mmDelete.inspectFuncDelete != nil {
		mmDelete.inspectFuncDelete(path)
	}

	mm_params := FileRepositoryMockDeleteParams{path}

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

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

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

		mm_got := FileRepositoryMockDeleteParams{path}

		if mm_want_ptrs != nil {

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

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

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

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

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

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

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

	return m.DeleteMock.invocationsDone()
}

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

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

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

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

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