aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg/cache/cache_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/pkg/cache/cache_test.go')
-rw-r--r--plugin/pkg/cache/cache_test.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/plugin/pkg/cache/cache_test.go b/plugin/pkg/cache/cache_test.go
index 2714967a6..e9e0a30a3 100644
--- a/plugin/pkg/cache/cache_test.go
+++ b/plugin/pkg/cache/cache_test.go
@@ -1,6 +1,8 @@
package cache
-import "testing"
+import (
+ "testing"
+)
func TestCacheAddAndGet(t *testing.T) {
const N = shardSize * 4
@@ -53,6 +55,25 @@ func TestCacheSharding(t *testing.T) {
}
}
+func TestCacheWalk(t *testing.T) {
+ c := New(10)
+ exp := make([]int, 10*2)
+ for i := 0; i < 10*2; i++ {
+ c.Add(uint64(i), 1)
+ exp[i] = 1
+ }
+ got := make([]int, 10*2)
+ c.Walk(func(items map[uint64]interface{}, key uint64) bool {
+ got[key] = items[key].(int)
+ return true
+ })
+ for i := range exp {
+ if exp[i] != got[i] {
+ t.Errorf("Expected %d, got %d", exp[i], got[i])
+ }
+ }
+}
+
func BenchmarkCache(b *testing.B) {
b.ReportAllocs()