@@ -56,14 +56,19 @@ func TestCacheOptions(t *testing.T) {
56
56
assert .Equal (t , maxOffset , o .offset )
57
57
})
58
58
59
+ t .Run ("with refresh duration" , func (t * testing.T ) {
60
+ o := newOptions (WithRefreshDuration (time .Second ))
61
+ assert .Equal (t , time .Second , o .refreshDuration )
62
+ })
63
+
59
64
t .Run ("with refresh concurrency" , func (t * testing.T ) {
60
65
o := newOptions (WithRefreshConcurrency (16 ))
61
66
assert .Equal (t , defaultNotFoundExpiry , o .notFoundExpiry )
62
67
assert .Equal (t , 16 , o .refreshConcurrency )
63
68
assert .Equal (t , defaultCodec , o .codec )
64
69
})
65
70
66
- t .Run ("with mockDecode " , func (t * testing.T ) {
71
+ t .Run ("with mock decode " , func (t * testing.T ) {
67
72
o := newOptions (WithCodec (json .Name ))
68
73
assert .Equal (t , defaultNotFoundExpiry , o .notFoundExpiry )
69
74
assert .Equal (t , defaultRefreshConcurrency , o .refreshConcurrency )
@@ -103,3 +108,28 @@ func TestCacheOptions(t *testing.T) {
103
108
assert .NotNil (t , o .eventHandler )
104
109
})
105
110
}
111
+
112
+ func TestCacheOptionsRefreshDuration (t * testing.T ) {
113
+ tests := []struct {
114
+ input time.Duration
115
+ expect time.Duration
116
+ }{
117
+ {
118
+ input : 0 ,
119
+ expect : 0 ,
120
+ },
121
+ {
122
+ input : time .Millisecond ,
123
+ expect : minEffectRefreshDuration ,
124
+ },
125
+ {
126
+ input : time .Minute ,
127
+ expect : time .Minute ,
128
+ },
129
+ }
130
+
131
+ for _ , v := range tests {
132
+ o := newOptions (WithRefreshDuration (v .input ))
133
+ assert .Equal (t , v .expect , o .refreshDuration )
134
+ }
135
+ }
0 commit comments