diff options
author | Chris <ccbrown112@gmail.com> | 2018-02-28 14:07:11 -0600 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2018-02-28 12:07:11 -0800 |
commit | 600528e1cfb06978efe6ce325fe2e2e4bb964f78 (patch) | |
tree | 388b09a42bde68d279aae8274c5b1f364b219799 /utils/lru_test.go | |
parent | 2fba6fa7997066adfbe02e92cd22ea75018f4fe7 (diff) | |
download | chat-600528e1cfb06978efe6ce325fe2e2e4bb964f78.tar.gz chat-600528e1cfb06978efe6ce325fe2e2e4bb964f78.tar.bz2 chat-600528e1cfb06978efe6ce325fe2e2e4bb964f78.zip |
optimize lru purging (#8381)
Diffstat (limited to 'utils/lru_test.go')
-rw-r--r-- | utils/lru_test.go | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/utils/lru_test.go b/utils/lru_test.go index 987163cd3..4312515b9 100644 --- a/utils/lru_test.go +++ b/utils/lru_test.go @@ -11,14 +11,7 @@ import "testing" import "time" func TestLRU(t *testing.T) { - evictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - evictCounter += 1 - } - l, err := NewLruWithEvict(128, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } + l := NewLru(128) for i := 0; i < 256; i++ { l.Add(i, i) @@ -27,10 +20,6 @@ func TestLRU(t *testing.T) { t.Fatalf("bad len: %v", l.Len()) } - if evictCounter != 128 { - t.Fatalf("bad evict count: %v", evictCounter) - } - for i, k := range l.Keys() { if v, ok := l.Get(k); !ok || v != k || v != i+128 { t.Fatalf("bad key: %v", k) @@ -73,26 +62,6 @@ func TestLRU(t *testing.T) { } } -// test that Add return true/false if an eviction occurred -func TestLRUAdd(t *testing.T) { - evictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - evictCounter += 1 - } - - l, err := NewLruWithEvict(1, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } - - if l.Add(1, 1) || evictCounter != 0 { - t.Errorf("should not have an eviction") - } - if !l.Add(2, 2) || evictCounter != 1 { - t.Errorf("should have an eviction") - } -} - func TestLRUExpire(t *testing.T) { l := NewLru(128) |