package mocks

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

//go:generate minimock -i learngo-pockets/habits/internal/habit.habitLister -o ./mocks/habit_lister_mock.go -n HabitListerMock

import (
	"context"
	mm_habit "learngo-pockets/habits/internal/habit"
	"sync"
	mm_atomic "sync/atomic"
	mm_time "time"

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

// HabitListerMock implements habit.habitLister
type HabitListerMock struct {
	t minimock.Tester

	funcFindAll          func(ctx context.Context) (ha1 []mm_habit.Habit, err error)
	inspectFuncFindAll   func(ctx context.Context)
	afterFindAllCounter  uint64
	beforeFindAllCounter uint64
	FindAllMock          mHabitListerMockFindAll
}

// NewHabitListerMock returns a mock for habit.habitLister
func NewHabitListerMock(t minimock.Tester) *HabitListerMock {
	m := &HabitListerMock{t: t}
	if controller, ok := t.(minimock.MockController); ok {
		controller.RegisterMocker(m)
	}

	m.FindAllMock = mHabitListerMockFindAll{mock: m}
	m.FindAllMock.callArgs = []*HabitListerMockFindAllParams{}

	return m
}

type mHabitListerMockFindAll struct {
	mock               *HabitListerMock
	defaultExpectation *HabitListerMockFindAllExpectation
	expectations       []*HabitListerMockFindAllExpectation

	callArgs []*HabitListerMockFindAllParams
	mutex    sync.RWMutex
}

// HabitListerMockFindAllExpectation specifies expectation struct of the habitLister.FindAll
type HabitListerMockFindAllExpectation struct {
	mock    *HabitListerMock
	params  *HabitListerMockFindAllParams
	results *HabitListerMockFindAllResults
	Counter uint64
}

// HabitListerMockFindAllParams contains parameters of the habitLister.FindAll
type HabitListerMockFindAllParams struct {
	ctx context.Context
}

// HabitListerMockFindAllResults contains results of the habitLister.FindAll
type HabitListerMockFindAllResults struct {
	ha1 []mm_habit.Habit
	err error
}

// Expect sets up expected params for habitLister.FindAll
func (mmFindAll *mHabitListerMockFindAll) Expect(ctx context.Context) *mHabitListerMockFindAll {
	if mmFindAll.mock.funcFindAll != nil {
		mmFindAll.mock.t.Fatalf("HabitListerMock.FindAll mock is already set by Set")
	}

	if mmFindAll.defaultExpectation == nil {
		mmFindAll.defaultExpectation = &HabitListerMockFindAllExpectation{}
	}

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

	return mmFindAll
}

// Inspect accepts an inspector function that has same arguments as the habitLister.FindAll
func (mmFindAll *mHabitListerMockFindAll) Inspect(f func(ctx context.Context)) *mHabitListerMockFindAll {
	if mmFindAll.mock.inspectFuncFindAll != nil {
		mmFindAll.mock.t.Fatalf("Inspect function is already set for HabitListerMock.FindAll")
	}

	mmFindAll.mock.inspectFuncFindAll = f

	return mmFindAll
}

// Return sets up results that will be returned by habitLister.FindAll
func (mmFindAll *mHabitListerMockFindAll) Return(ha1 []mm_habit.Habit, err error) *HabitListerMock {
	if mmFindAll.mock.funcFindAll != nil {
		mmFindAll.mock.t.Fatalf("HabitListerMock.FindAll mock is already set by Set")
	}

	if mmFindAll.defaultExpectation == nil {
		mmFindAll.defaultExpectation = &HabitListerMockFindAllExpectation{mock: mmFindAll.mock}
	}
	mmFindAll.defaultExpectation.results = &HabitListerMockFindAllResults{ha1, err}
	return mmFindAll.mock
}

// Set uses given function f to mock the habitLister.FindAll method
func (mmFindAll *mHabitListerMockFindAll) Set(f func(ctx context.Context) (ha1 []mm_habit.Habit, err error)) *HabitListerMock {
	if mmFindAll.defaultExpectation != nil {
		mmFindAll.mock.t.Fatalf("Default expectation is already set for the habitLister.FindAll method")
	}

	if len(mmFindAll.expectations) > 0 {
		mmFindAll.mock.t.Fatalf("Some expectations are already set for the habitLister.FindAll method")
	}

	mmFindAll.mock.funcFindAll = f
	return mmFindAll.mock
}

// When sets expectation for the habitLister.FindAll which will trigger the result defined by the following
// Then helper
func (mmFindAll *mHabitListerMockFindAll) When(ctx context.Context) *HabitListerMockFindAllExpectation {
	if mmFindAll.mock.funcFindAll != nil {
		mmFindAll.mock.t.Fatalf("HabitListerMock.FindAll mock is already set by Set")
	}

	expectation := &HabitListerMockFindAllExpectation{
		mock:   mmFindAll.mock,
		params: &HabitListerMockFindAllParams{ctx},
	}
	mmFindAll.expectations = append(mmFindAll.expectations, expectation)
	return expectation
}

// Then sets up habitLister.FindAll return parameters for the expectation previously defined by the When method
func (e *HabitListerMockFindAllExpectation) Then(ha1 []mm_habit.Habit, err error) *HabitListerMock {
	e.results = &HabitListerMockFindAllResults{ha1, err}
	return e.mock
}

// FindAll implements habit.habitLister
func (mmFindAll *HabitListerMock) FindAll(ctx context.Context) (ha1 []mm_habit.Habit, err error) {
	mm_atomic.AddUint64(&mmFindAll.beforeFindAllCounter, 1)
	defer mm_atomic.AddUint64(&mmFindAll.afterFindAllCounter, 1)

	if mmFindAll.inspectFuncFindAll != nil {
		mmFindAll.inspectFuncFindAll(ctx)
	}

	mm_params := &HabitListerMockFindAllParams{ctx}

	// Record call args
	mmFindAll.FindAllMock.mutex.Lock()
	mmFindAll.FindAllMock.callArgs = append(mmFindAll.FindAllMock.callArgs, mm_params)
	mmFindAll.FindAllMock.mutex.Unlock()

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

	if mmFindAll.FindAllMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmFindAll.FindAllMock.defaultExpectation.Counter, 1)
		mm_want := mmFindAll.FindAllMock.defaultExpectation.params
		mm_got := HabitListerMockFindAllParams{ctx}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmFindAll.t.Errorf("HabitListerMock.FindAll got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmFindAll.FindAllMock.defaultExpectation.results
		if mm_results == nil {
			mmFindAll.t.Fatal("No results are set for the HabitListerMock.FindAll")
		}
		return (*mm_results).ha1, (*mm_results).err
	}
	if mmFindAll.funcFindAll != nil {
		return mmFindAll.funcFindAll(ctx)
	}
	mmFindAll.t.Fatalf("Unexpected call to HabitListerMock.FindAll. %v", ctx)
	return
}

// FindAllAfterCounter returns a count of finished HabitListerMock.FindAll invocations
func (mmFindAll *HabitListerMock) FindAllAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmFindAll.afterFindAllCounter)
}

// FindAllBeforeCounter returns a count of HabitListerMock.FindAll invocations
func (mmFindAll *HabitListerMock) FindAllBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmFindAll.beforeFindAllCounter)
}

// Calls returns a list of arguments used in each call to HabitListerMock.FindAll.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmFindAll *mHabitListerMockFindAll) Calls() []*HabitListerMockFindAllParams {
	mmFindAll.mutex.RLock()

	argCopy := make([]*HabitListerMockFindAllParams, len(mmFindAll.callArgs))
	copy(argCopy, mmFindAll.callArgs)

	mmFindAll.mutex.RUnlock()

	return argCopy
}

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

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

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

// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *HabitListerMock) MinimockFinish() {
	if !m.minimockDone() {
		m.MinimockFindAllInspect()
		m.t.FailNow()
	}
}

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