@@ -21,16 +21,18 @@ import (
2121)
2222
2323const (
24- testCacheName = "test"
25- testCacheType = lru
26- testCacheShardings = 16
24+ testCacheName = "test"
25+ testCacheType = lru
26+ testCacheShardings = 16
27+ testCacheGCDuration = 10 * time .Minute
2728)
2829
2930func newTestReportableCache () (* reportableCache , * Reporter ) {
3031 conf := newDefaultConfig ()
3132 conf .cacheName = testCacheName
3233 conf .cacheType = testCacheType
3334 conf .shardings = testCacheShardings
35+ conf .gcDuration = testCacheGCDuration
3436 conf .maxEntries = maxTestEntries
3537
3638 cache , reporter := report (conf , newStandardCache (conf ))
@@ -241,6 +243,18 @@ func TestReporterCacheShardings(t *testing.T) {
241243 }
242244}
243245
246+ // go test -v -cover -run=^TestReporterCacheGC$
247+ func TestReporterCacheGC (t * testing.T ) {
248+ _ , reporter := newTestReportableCache ()
249+ if reporter .CacheGC () != reporter .conf .gcDuration {
250+ t .Errorf ("CacheGC %d is wrong compared with conf" , reporter .CacheGC ())
251+ }
252+
253+ if reporter .CacheGC () != testCacheGCDuration {
254+ t .Errorf ("CacheGC %d is wrong" , reporter .CacheGC ())
255+ }
256+ }
257+
244258// go test -v -cover -run=^TestReporterCacheSize$
245259func TestReporterCacheSize (t * testing.T ) {
246260 cache , reporter := newTestReportableCache ()
0 commit comments