fix issue in gredis unit test cases
@@ -10,6 +10,9 @@ import (
"testing"
"time"
+ "github.com/gogf/gf/os/gtime"
+ "github.com/gogf/gf/util/gconv"
+
"github.com/gogf/gf/database/gredis"
"github.com/gogf/gf/test/gtest"
redis2 "github.com/gomodule/redigo/redis"
@@ -88,13 +91,18 @@ func Test_Conn(t *testing.T) {
conn := redis.Conn()
defer conn.Close()
- r, err := conn.Do("GET", "k")
+ key := gconv.String(gtime.Nanosecond())
+ value := []byte("v")
+ r, err := conn.Do("SET", key, value)
gtest.Assert(err, nil)
- gtest.Assert(r, []byte("v"))
- _, err = conn.Do("DEL", "k")
+ r, err = conn.Do("GET", key)
gtest.Assert(err, nil)
- r, err = conn.Do("GET", "k")
+ gtest.Assert(r, value)
+
+ _, err = conn.Do("DEL", key)
+ gtest.Assert(err, nil)
+ r, err = conn.Do("GET", key)
gtest.Assert(err, nil)
gtest.Assert(r, nil)
})
