forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_clock.go
216 lines (192 loc) · 5.21 KB
/
fake_clock.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// This file was generated by counterfeiter
package fakes
import (
"sync"
"time"
"github.com/pivotal-golang/clock"
)
type FakeClock struct {
NowStub func() time.Time
nowMutex sync.RWMutex
nowArgsForCall []struct{}
nowReturns struct {
result1 time.Time
}
SleepStub func(d time.Duration)
sleepMutex sync.RWMutex
sleepArgsForCall []struct {
d time.Duration
}
SinceStub func(t time.Time) time.Duration
sinceMutex sync.RWMutex
sinceArgsForCall []struct {
t time.Time
}
sinceReturns struct {
result1 time.Duration
}
NewTimerStub func(d time.Duration) clock.Timer
newTimerMutex sync.RWMutex
newTimerArgsForCall []struct {
d time.Duration
}
newTimerReturns struct {
result1 clock.Timer
}
NewTickerStub func(d time.Duration) clock.Ticker
newTickerMutex sync.RWMutex
newTickerArgsForCall []struct {
d time.Duration
}
newTickerReturns struct {
result1 clock.Ticker
}
invocations map[string][][]interface{}
}
func (fake *FakeClock) Now() time.Time {
fake.nowMutex.Lock()
fake.nowArgsForCall = append(fake.nowArgsForCall, struct{}{})
fake.guard("Now")
fake.invocations["Now"] = append(fake.invocations["Now"], []interface{}{})
fake.nowMutex.Unlock()
if fake.NowStub != nil {
return fake.NowStub()
} else {
return fake.nowReturns.result1
}
}
func (fake *FakeClock) NowCallCount() int {
fake.nowMutex.RLock()
defer fake.nowMutex.RUnlock()
return len(fake.nowArgsForCall)
}
func (fake *FakeClock) NowReturns(result1 time.Time) {
fake.NowStub = nil
fake.nowReturns = struct {
result1 time.Time
}{result1}
}
func (fake *FakeClock) Sleep(d time.Duration) {
fake.sleepMutex.Lock()
fake.sleepArgsForCall = append(fake.sleepArgsForCall, struct {
d time.Duration
}{d})
fake.guard("Sleep")
fake.invocations["Sleep"] = append(fake.invocations["Sleep"], []interface{}{d})
fake.sleepMutex.Unlock()
if fake.SleepStub != nil {
fake.SleepStub(d)
}
}
func (fake *FakeClock) SleepCallCount() int {
fake.sleepMutex.RLock()
defer fake.sleepMutex.RUnlock()
return len(fake.sleepArgsForCall)
}
func (fake *FakeClock) SleepArgsForCall(i int) time.Duration {
fake.sleepMutex.RLock()
defer fake.sleepMutex.RUnlock()
return fake.sleepArgsForCall[i].d
}
func (fake *FakeClock) Since(t time.Time) time.Duration {
fake.sinceMutex.Lock()
fake.sinceArgsForCall = append(fake.sinceArgsForCall, struct {
t time.Time
}{t})
fake.guard("Since")
fake.invocations["Since"] = append(fake.invocations["Since"], []interface{}{t})
fake.sinceMutex.Unlock()
if fake.SinceStub != nil {
return fake.SinceStub(t)
} else {
return fake.sinceReturns.result1
}
}
func (fake *FakeClock) SinceCallCount() int {
fake.sinceMutex.RLock()
defer fake.sinceMutex.RUnlock()
return len(fake.sinceArgsForCall)
}
func (fake *FakeClock) SinceArgsForCall(i int) time.Time {
fake.sinceMutex.RLock()
defer fake.sinceMutex.RUnlock()
return fake.sinceArgsForCall[i].t
}
func (fake *FakeClock) SinceReturns(result1 time.Duration) {
fake.SinceStub = nil
fake.sinceReturns = struct {
result1 time.Duration
}{result1}
}
func (fake *FakeClock) NewTimer(d time.Duration) clock.Timer {
fake.newTimerMutex.Lock()
fake.newTimerArgsForCall = append(fake.newTimerArgsForCall, struct {
d time.Duration
}{d})
fake.guard("NewTimer")
fake.invocations["NewTimer"] = append(fake.invocations["NewTimer"], []interface{}{d})
fake.newTimerMutex.Unlock()
if fake.NewTimerStub != nil {
return fake.NewTimerStub(d)
} else {
return fake.newTimerReturns.result1
}
}
func (fake *FakeClock) NewTimerCallCount() int {
fake.newTimerMutex.RLock()
defer fake.newTimerMutex.RUnlock()
return len(fake.newTimerArgsForCall)
}
func (fake *FakeClock) NewTimerArgsForCall(i int) time.Duration {
fake.newTimerMutex.RLock()
defer fake.newTimerMutex.RUnlock()
return fake.newTimerArgsForCall[i].d
}
func (fake *FakeClock) NewTimerReturns(result1 clock.Timer) {
fake.NewTimerStub = nil
fake.newTimerReturns = struct {
result1 clock.Timer
}{result1}
}
func (fake *FakeClock) NewTicker(d time.Duration) clock.Ticker {
fake.newTickerMutex.Lock()
fake.newTickerArgsForCall = append(fake.newTickerArgsForCall, struct {
d time.Duration
}{d})
fake.guard("NewTicker")
fake.invocations["NewTicker"] = append(fake.invocations["NewTicker"], []interface{}{d})
fake.newTickerMutex.Unlock()
if fake.NewTickerStub != nil {
return fake.NewTickerStub(d)
} else {
return fake.newTickerReturns.result1
}
}
func (fake *FakeClock) NewTickerCallCount() int {
fake.newTickerMutex.RLock()
defer fake.newTickerMutex.RUnlock()
return len(fake.newTickerArgsForCall)
}
func (fake *FakeClock) NewTickerArgsForCall(i int) time.Duration {
fake.newTickerMutex.RLock()
defer fake.newTickerMutex.RUnlock()
return fake.newTickerArgsForCall[i].d
}
func (fake *FakeClock) NewTickerReturns(result1 clock.Ticker) {
fake.NewTickerStub = nil
fake.newTickerReturns = struct {
result1 clock.Ticker
}{result1}
}
func (fake *FakeClock) Invocations() map[string][][]interface{} {
return fake.invocations
}
func (fake *FakeClock) guard(key string) {
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
}
var _ clock.Clock = new(FakeClock)