-
Notifications
You must be signed in to change notification settings - Fork 0
/
sleeper.go
65 lines (58 loc) · 1.6 KB
/
sleeper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Code generated by counterfeiter. DO NOT EDIT.
package mocks
import (
"sync"
"time"
)
type Sleeper struct {
SleepStub func(time.Duration)
sleepMutex sync.RWMutex
sleepArgsForCall []struct {
arg1 time.Duration
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *Sleeper) Sleep(arg1 time.Duration) {
fake.sleepMutex.Lock()
fake.sleepArgsForCall = append(fake.sleepArgsForCall, struct {
arg1 time.Duration
}{arg1})
fake.recordInvocation("Sleep", []interface{}{arg1})
fake.sleepMutex.Unlock()
if fake.SleepStub != nil {
fake.SleepStub(arg1)
}
}
func (fake *Sleeper) SleepCallCount() int {
fake.sleepMutex.RLock()
defer fake.sleepMutex.RUnlock()
return len(fake.sleepArgsForCall)
}
func (fake *Sleeper) SleepArgsForCall(i int) time.Duration {
fake.sleepMutex.RLock()
defer fake.sleepMutex.RUnlock()
return fake.sleepArgsForCall[i].arg1
}
func (fake *Sleeper) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.sleepMutex.RLock()
defer fake.sleepMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *Sleeper) 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)
}