-
Notifications
You must be signed in to change notification settings - Fork 199
/
timeCacherStub.go
59 lines (48 loc) · 1009 Bytes
/
timeCacherStub.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
package testscommon
import "time"
// TimeCacheStub -
type TimeCacheStub struct {
AddCalled func(key string) error
UpsertCalled func(key string, span time.Duration) error
HasCalled func(key string) bool
SweepCalled func()
LenCalled func() int
}
// Add -
func (tcs *TimeCacheStub) Add(key string) error {
if tcs.AddCalled != nil {
return tcs.AddCalled(key)
}
return nil
}
// Upsert -
func (tcs *TimeCacheStub) Upsert(key string, span time.Duration) error {
if tcs.UpsertCalled != nil {
return tcs.UpsertCalled(key, span)
}
return nil
}
// Has -
func (tcs *TimeCacheStub) Has(key string) bool {
if tcs.HasCalled != nil {
return tcs.HasCalled(key)
}
return false
}
// Sweep -
func (tcs *TimeCacheStub) Sweep() {
if tcs.SweepCalled != nil {
tcs.SweepCalled()
}
}
// Len -
func (tcs *TimeCacheStub) Len() int {
if tcs.LenCalled != nil {
return tcs.LenCalled()
}
return 10
}
// IsInterfaceNil -
func (tcs *TimeCacheStub) IsInterfaceNil() bool {
return tcs == nil
}