// Code generated by counterfeiter. DO NOT EDIT.
package fakes

import (
	"context"
	"sync"
	"time"

	"github.com/weaveworks/eksctl/pkg/credentials"
)

type FakeFlock struct {
	TryLockContextStub        func(context.Context, time.Duration) (bool, error)
	tryLockContextMutex       sync.RWMutex
	tryLockContextArgsForCall []struct {
		arg1 context.Context
		arg2 time.Duration
	}
	tryLockContextReturns struct {
		result1 bool
		result2 error
	}
	tryLockContextReturnsOnCall map[int]struct {
		result1 bool
		result2 error
	}
	TryRLockContextStub        func(context.Context, time.Duration) (bool, error)
	tryRLockContextMutex       sync.RWMutex
	tryRLockContextArgsForCall []struct {
		arg1 context.Context
		arg2 time.Duration
	}
	tryRLockContextReturns struct {
		result1 bool
		result2 error
	}
	tryRLockContextReturnsOnCall map[int]struct {
		result1 bool
		result2 error
	}
	UnlockStub        func() error
	unlockMutex       sync.RWMutex
	unlockArgsForCall []struct {
	}
	unlockReturns struct {
		result1 error
	}
	unlockReturnsOnCall map[int]struct {
		result1 error
	}
	invocations      map[string][][]interface{}
	invocationsMutex sync.RWMutex
}

func (fake *FakeFlock) TryLockContext(arg1 context.Context, arg2 time.Duration) (bool, error) {
	fake.tryLockContextMutex.Lock()
	ret, specificReturn := fake.tryLockContextReturnsOnCall[len(fake.tryLockContextArgsForCall)]
	fake.tryLockContextArgsForCall = append(fake.tryLockContextArgsForCall, struct {
		arg1 context.Context
		arg2 time.Duration
	}{arg1, arg2})
	stub := fake.TryLockContextStub
	fakeReturns := fake.tryLockContextReturns
	fake.recordInvocation("TryLockContext", []interface{}{arg1, arg2})
	fake.tryLockContextMutex.Unlock()
	if stub != nil {
		return stub(arg1, arg2)
	}
	if specificReturn {
		return ret.result1, ret.result2
	}
	return fakeReturns.result1, fakeReturns.result2
}

func (fake *FakeFlock) TryLockContextCallCount() int {
	fake.tryLockContextMutex.RLock()
	defer fake.tryLockContextMutex.RUnlock()
	return len(fake.tryLockContextArgsForCall)
}

func (fake *FakeFlock) TryLockContextCalls(stub func(context.Context, time.Duration) (bool, error)) {
	fake.tryLockContextMutex.Lock()
	defer fake.tryLockContextMutex.Unlock()
	fake.TryLockContextStub = stub
}

func (fake *FakeFlock) TryLockContextArgsForCall(i int) (context.Context, time.Duration) {
	fake.tryLockContextMutex.RLock()
	defer fake.tryLockContextMutex.RUnlock()
	argsForCall := fake.tryLockContextArgsForCall[i]
	return argsForCall.arg1, argsForCall.arg2
}

func (fake *FakeFlock) TryLockContextReturns(result1 bool, result2 error) {
	fake.tryLockContextMutex.Lock()
	defer fake.tryLockContextMutex.Unlock()
	fake.TryLockContextStub = nil
	fake.tryLockContextReturns = struct {
		result1 bool
		result2 error
	}{result1, result2}
}

func (fake *FakeFlock) TryLockContextReturnsOnCall(i int, result1 bool, result2 error) {
	fake.tryLockContextMutex.Lock()
	defer fake.tryLockContextMutex.Unlock()
	fake.TryLockContextStub = nil
	if fake.tryLockContextReturnsOnCall == nil {
		fake.tryLockContextReturnsOnCall = make(map[int]struct {
			result1 bool
			result2 error
		})
	}
	fake.tryLockContextReturnsOnCall[i] = struct {
		result1 bool
		result2 error
	}{result1, result2}
}

func (fake *FakeFlock) TryRLockContext(arg1 context.Context, arg2 time.Duration) (bool, error) {
	fake.tryRLockContextMutex.Lock()
	ret, specificReturn := fake.tryRLockContextReturnsOnCall[len(fake.tryRLockContextArgsForCall)]
	fake.tryRLockContextArgsForCall = append(fake.tryRLockContextArgsForCall, struct {
		arg1 context.Context
		arg2 time.Duration
	}{arg1, arg2})
	stub := fake.TryRLockContextStub
	fakeReturns := fake.tryRLockContextReturns
	fake.recordInvocation("TryRLockContext", []interface{}{arg1, arg2})
	fake.tryRLockContextMutex.Unlock()
	if stub != nil {
		return stub(arg1, arg2)
	}
	if specificReturn {
		return ret.result1, ret.result2
	}
	return fakeReturns.result1, fakeReturns.result2
}

func (fake *FakeFlock) TryRLockContextCallCount() int {
	fake.tryRLockContextMutex.RLock()
	defer fake.tryRLockContextMutex.RUnlock()
	return len(fake.tryRLockContextArgsForCall)
}

func (fake *FakeFlock) TryRLockContextCalls(stub func(context.Context, time.Duration) (bool, error)) {
	fake.tryRLockContextMutex.Lock()
	defer fake.tryRLockContextMutex.Unlock()
	fake.TryRLockContextStub = stub
}

func (fake *FakeFlock) TryRLockContextArgsForCall(i int) (context.Context, time.Duration) {
	fake.tryRLockContextMutex.RLock()
	defer fake.tryRLockContextMutex.RUnlock()
	argsForCall := fake.tryRLockContextArgsForCall[i]
	return argsForCall.arg1, argsForCall.arg2
}

func (fake *FakeFlock) TryRLockContextReturns(result1 bool, result2 error) {
	fake.tryRLockContextMutex.Lock()
	defer fake.tryRLockContextMutex.Unlock()
	fake.TryRLockContextStub = nil
	fake.tryRLockContextReturns = struct {
		result1 bool
		result2 error
	}{result1, result2}
}

func (fake *FakeFlock) TryRLockContextReturnsOnCall(i int, result1 bool, result2 error) {
	fake.tryRLockContextMutex.Lock()
	defer fake.tryRLockContextMutex.Unlock()
	fake.TryRLockContextStub = nil
	if fake.tryRLockContextReturnsOnCall == nil {
		fake.tryRLockContextReturnsOnCall = make(map[int]struct {
			result1 bool
			result2 error
		})
	}
	fake.tryRLockContextReturnsOnCall[i] = struct {
		result1 bool
		result2 error
	}{result1, result2}
}

func (fake *FakeFlock) Unlock() error {
	fake.unlockMutex.Lock()
	ret, specificReturn := fake.unlockReturnsOnCall[len(fake.unlockArgsForCall)]
	fake.unlockArgsForCall = append(fake.unlockArgsForCall, struct {
	}{})
	stub := fake.UnlockStub
	fakeReturns := fake.unlockReturns
	fake.recordInvocation("Unlock", []interface{}{})
	fake.unlockMutex.Unlock()
	if stub != nil {
		return stub()
	}
	if specificReturn {
		return ret.result1
	}
	return fakeReturns.result1
}

func (fake *FakeFlock) UnlockCallCount() int {
	fake.unlockMutex.RLock()
	defer fake.unlockMutex.RUnlock()
	return len(fake.unlockArgsForCall)
}

func (fake *FakeFlock) UnlockCalls(stub func() error) {
	fake.unlockMutex.Lock()
	defer fake.unlockMutex.Unlock()
	fake.UnlockStub = stub
}

func (fake *FakeFlock) UnlockReturns(result1 error) {
	fake.unlockMutex.Lock()
	defer fake.unlockMutex.Unlock()
	fake.UnlockStub = nil
	fake.unlockReturns = struct {
		result1 error
	}{result1}
}

func (fake *FakeFlock) UnlockReturnsOnCall(i int, result1 error) {
	fake.unlockMutex.Lock()
	defer fake.unlockMutex.Unlock()
	fake.UnlockStub = nil
	if fake.unlockReturnsOnCall == nil {
		fake.unlockReturnsOnCall = make(map[int]struct {
			result1 error
		})
	}
	fake.unlockReturnsOnCall[i] = struct {
		result1 error
	}{result1}
}

func (fake *FakeFlock) Invocations() map[string][][]interface{} {
	fake.invocationsMutex.RLock()
	defer fake.invocationsMutex.RUnlock()
	fake.tryLockContextMutex.RLock()
	defer fake.tryLockContextMutex.RUnlock()
	fake.tryRLockContextMutex.RLock()
	defer fake.tryRLockContextMutex.RUnlock()
	fake.unlockMutex.RLock()
	defer fake.unlockMutex.RUnlock()
	copiedInvocations := map[string][][]interface{}{}
	for key, value := range fake.invocations {
		copiedInvocations[key] = value
	}
	return copiedInvocations
}

func (fake *FakeFlock) recordInvocation(key string, args []interface{}) {
	fake.invocationsMutex.Lock()
	defer fake.invocationsMutex.Unlock()
	if fake.invocations == nil {
		fake.invocations = map[string][][]interface{}{}
	}
	if fake.invocations[key] == nil {
		fake.invocations[key] = [][]interface{}{}
	}
	fake.invocations[key] = append(fake.invocations[key], args)
}

var _ credentials.Flock = new(FakeFlock)
