From 4df5eb760ccb9839b741364aeaeaf7993096fad8 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 8 Oct 2020 22:39:07 +0800 Subject: [PATCH] add more tests --- core/stores/cache/cache_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/stores/cache/cache_test.go b/core/stores/cache/cache_test.go index 0480d2c0..26336c4d 100644 --- a/core/stores/cache/cache_test.go +++ b/core/stores/cache/cache_test.go @@ -227,6 +227,25 @@ func TestCache_Balance(t *testing.T) { assert.Equal(t, total/10, count) } +func TestCacheNoNode(t *testing.T) { + dispatcher := hash.NewConsistentHash() + c := cacheCluster{ + dispatcher: dispatcher, + errNotFound: errPlaceholder, + } + assert.NotNil(t, c.DelCache("foo")) + assert.NotNil(t, c.DelCache("foo", "bar", "any")) + assert.NotNil(t, c.GetCache("foo", nil)) + assert.NotNil(t, c.SetCache("foo", nil)) + assert.NotNil(t, c.SetCacheWithExpire("foo", nil, time.Second)) + assert.NotNil(t, c.Take(nil, "foo", func(v interface{}) error { + return nil + })) + assert.NotNil(t, c.TakeWithExpire(nil, "foo", func(v interface{}, duration time.Duration) error { + return nil + })) +} + func calcEntropy(m map[int]int, total int) float64 { var entropy float64