-
Notifications
You must be signed in to change notification settings - Fork 114
/
fake_clock.go
364 lines (331 loc) · 8.98 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
// Code generated by counterfeiter. DO NOT EDIT.
package fakes
import (
"sync"
"time"
"code.cloudfoundry.org/clock"
)
type FakeClock struct {
NowStub func() time.Time
nowMutex sync.RWMutex
nowArgsForCall []struct{}
nowReturns struct {
result1 time.Time
}
nowReturnsOnCall map[int]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
}
sinceReturnsOnCall map[int]struct {
result1 time.Duration
}
AfterStub func(d time.Duration) <-chan time.Time
afterMutex sync.RWMutex
afterArgsForCall []struct {
d time.Duration
}
afterReturns struct {
result1 <-chan time.Time
}
afterReturnsOnCall map[int]struct {
result1 <-chan time.Time
}
NewTimerStub func(d time.Duration) clock.Timer
newTimerMutex sync.RWMutex
newTimerArgsForCall []struct {
d time.Duration
}
newTimerReturns struct {
result1 clock.Timer
}
newTimerReturnsOnCall map[int]struct {
result1 clock.Timer
}
NewTickerStub func(d time.Duration) clock.Ticker
newTickerMutex sync.RWMutex
newTickerArgsForCall []struct {
d time.Duration
}
newTickerReturns struct {
result1 clock.Ticker
}
newTickerReturnsOnCall map[int]struct {
result1 clock.Ticker
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeClock) Now() time.Time {
fake.nowMutex.Lock()
ret, specificReturn := fake.nowReturnsOnCall[len(fake.nowArgsForCall)]
fake.nowArgsForCall = append(fake.nowArgsForCall, struct{}{})
fake.recordInvocation("Now", []interface{}{})
fake.nowMutex.Unlock()
if fake.NowStub != nil {
return fake.NowStub()
}
if specificReturn {
return ret.result1
}
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) NowReturnsOnCall(i int, result1 time.Time) {
fake.NowStub = nil
if fake.nowReturnsOnCall == nil {
fake.nowReturnsOnCall = make(map[int]struct {
result1 time.Time
})
}
fake.nowReturnsOnCall[i] = 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.recordInvocation("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()
ret, specificReturn := fake.sinceReturnsOnCall[len(fake.sinceArgsForCall)]
fake.sinceArgsForCall = append(fake.sinceArgsForCall, struct {
t time.Time
}{t})
fake.recordInvocation("Since", []interface{}{t})
fake.sinceMutex.Unlock()
if fake.SinceStub != nil {
return fake.SinceStub(t)
}
if specificReturn {
return ret.result1
}
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) SinceReturnsOnCall(i int, result1 time.Duration) {
fake.SinceStub = nil
if fake.sinceReturnsOnCall == nil {
fake.sinceReturnsOnCall = make(map[int]struct {
result1 time.Duration
})
}
fake.sinceReturnsOnCall[i] = struct {
result1 time.Duration
}{result1}
}
func (fake *FakeClock) After(d time.Duration) <-chan time.Time {
fake.afterMutex.Lock()
ret, specificReturn := fake.afterReturnsOnCall[len(fake.afterArgsForCall)]
fake.afterArgsForCall = append(fake.afterArgsForCall, struct {
d time.Duration
}{d})
fake.recordInvocation("After", []interface{}{d})
fake.afterMutex.Unlock()
if fake.AfterStub != nil {
return fake.AfterStub(d)
}
if specificReturn {
return ret.result1
}
return fake.afterReturns.result1
}
func (fake *FakeClock) AfterCallCount() int {
fake.afterMutex.RLock()
defer fake.afterMutex.RUnlock()
return len(fake.afterArgsForCall)
}
func (fake *FakeClock) AfterArgsForCall(i int) time.Duration {
fake.afterMutex.RLock()
defer fake.afterMutex.RUnlock()
return fake.afterArgsForCall[i].d
}
func (fake *FakeClock) AfterReturns(result1 <-chan time.Time) {
fake.AfterStub = nil
fake.afterReturns = struct {
result1 <-chan time.Time
}{result1}
}
func (fake *FakeClock) AfterReturnsOnCall(i int, result1 <-chan time.Time) {
fake.AfterStub = nil
if fake.afterReturnsOnCall == nil {
fake.afterReturnsOnCall = make(map[int]struct {
result1 <-chan time.Time
})
}
fake.afterReturnsOnCall[i] = struct {
result1 <-chan time.Time
}{result1}
}
func (fake *FakeClock) NewTimer(d time.Duration) clock.Timer {
fake.newTimerMutex.Lock()
ret, specificReturn := fake.newTimerReturnsOnCall[len(fake.newTimerArgsForCall)]
fake.newTimerArgsForCall = append(fake.newTimerArgsForCall, struct {
d time.Duration
}{d})
fake.recordInvocation("NewTimer", []interface{}{d})
fake.newTimerMutex.Unlock()
if fake.NewTimerStub != nil {
return fake.NewTimerStub(d)
}
if specificReturn {
return ret.result1
}
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) NewTimerReturnsOnCall(i int, result1 clock.Timer) {
fake.NewTimerStub = nil
if fake.newTimerReturnsOnCall == nil {
fake.newTimerReturnsOnCall = make(map[int]struct {
result1 clock.Timer
})
}
fake.newTimerReturnsOnCall[i] = struct {
result1 clock.Timer
}{result1}
}
func (fake *FakeClock) NewTicker(d time.Duration) clock.Ticker {
fake.newTickerMutex.Lock()
ret, specificReturn := fake.newTickerReturnsOnCall[len(fake.newTickerArgsForCall)]
fake.newTickerArgsForCall = append(fake.newTickerArgsForCall, struct {
d time.Duration
}{d})
fake.recordInvocation("NewTicker", []interface{}{d})
fake.newTickerMutex.Unlock()
if fake.NewTickerStub != nil {
return fake.NewTickerStub(d)
}
if specificReturn {
return ret.result1
}
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) NewTickerReturnsOnCall(i int, result1 clock.Ticker) {
fake.NewTickerStub = nil
if fake.newTickerReturnsOnCall == nil {
fake.newTickerReturnsOnCall = make(map[int]struct {
result1 clock.Ticker
})
}
fake.newTickerReturnsOnCall[i] = struct {
result1 clock.Ticker
}{result1}
}
func (fake *FakeClock) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.nowMutex.RLock()
defer fake.nowMutex.RUnlock()
fake.sleepMutex.RLock()
defer fake.sleepMutex.RUnlock()
fake.sinceMutex.RLock()
defer fake.sinceMutex.RUnlock()
fake.afterMutex.RLock()
defer fake.afterMutex.RUnlock()
fake.newTimerMutex.RLock()
defer fake.newTimerMutex.RUnlock()
fake.newTickerMutex.RLock()
defer fake.newTickerMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *FakeClock) 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 _ clock.Clock = new(FakeClock)