From b4c3cc5a8643d8bf3688127c08ab7f006c7a05c9 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Wed, 27 Oct 2021 23:55:36 +0800 Subject: [PATCH] test(dao): remove dao test --- storage/dao/dao_test.go | 84 ----------------------------------------- 1 file changed, 84 deletions(-) diff --git a/storage/dao/dao_test.go b/storage/dao/dao_test.go index 438a4f9..99cc981 100644 --- a/storage/dao/dao_test.go +++ b/storage/dao/dao_test.go @@ -1,89 +1,5 @@ package dao import ( - "testing" - _ "gitee.com/timedb/wheatCache/conf" - "gitee.com/timedb/wheatCache/pkg/lru" - "gitee.com/timedb/wheatCache/pkg/proto" - "github.com/stretchr/testify/require" ) - -func mockData(t *testing.T, d *Dao) { - - values := []string{"1", "1.3", "abcdefg"} - - for _, val := range values { - key := &proto.BaseKey{ - Key: val, - } - _, err := d.Set(key, val) - require.NoError(t, err) - } - -} -func TestDao_Set(t *testing.T) { - lruCache := lru.NewLRUCache() - dao := NewDao(lruCache) - key := &proto.BaseKey{ - Key: "abc", - } - - res, err := dao.Set(key, "abc") - require.NoError(t, err) - require.Equal(t, res, "abc") - - res, err = dao.Get(key) - require.NoError(t, err) - require.Equal(t, res, "abc") -} - -func TestDao_Add(t *testing.T) { - lruCache := lru.NewLRUCache() - dao := NewDao(lruCache) - mockData(t, dao) - - resp, err := dao.Add(&proto.BaseKey{Key: "1"}, 2) - require.NoError(t, err) - require.Equal(t, resp, "3") - - resp, err = dao.Add(&proto.BaseKey{Key: "1.3"}, 2) - require.NoError(t, err) - require.Equal(t, resp, "3.30") - - _, err = dao.Add(&proto.BaseKey{Key: "abcdefg"}, 2) - require.Error(t, err) -} - -func TestDao_Reduce(t *testing.T) { - lruCache := lru.NewLRUCache() - dao := NewDao(lruCache) - mockData(t, dao) - - resp, err := dao.Reduce(&proto.BaseKey{Key: "1"}, 2) - require.NoError(t, err) - require.Equal(t, resp, "-1") - - resp, err = dao.Reduce(&proto.BaseKey{Key: "1.3"}, 2) - require.NoError(t, err) - require.Equal(t, resp, "-0.70") - - _, err = dao.Reduce(&proto.BaseKey{Key: "abcdefg"}, 2) - require.Error(t, err) -} - -func TestDao_Setbit(t *testing.T) { - lruCache := lru.NewLRUCache() - dao := NewDao(lruCache) - key := &proto.BaseKey{ - Key: "abc", - } - - err := dao.Setbit(key, true, 3089) - require.NoError(t, err) - - re, err := dao.GetBit(key, 3089) - require.NoError(t, err) - require.Equal(t, re, true) - -}