add map conversion support for result of HGetAll for package gredis

This commit is contained in:
John 2020-03-08 23:16:06 +08:00
parent 5acce82e63
commit 042a6f12f5

View File

@ -210,6 +210,11 @@ func Test_Error(t *testing.T) {
func Test_Bool(t *testing.T) {
gtest.Case(t, func() {
redis := gredis.New(config)
defer func() {
redis.Do("DEL", "key-true")
redis.Do("DEL", "key-false")
}()
_, err := redis.Do("SET", "key-true", true)
gtest.Assert(err, nil)
@ -230,6 +235,8 @@ func Test_Int(t *testing.T) {
gtest.Case(t, func() {
redis := gredis.New(config)
key := guuid.New()
defer redis.Do("DEL", key)
_, err := redis.Do("SET", key, 1)
gtest.Assert(err, nil)
@ -243,6 +250,8 @@ func Test_HSet(t *testing.T) {
gtest.Case(t, func() {
redis := gredis.New(config)
key := guuid.New()
defer redis.Do("DEL", key)
_, err := redis.Do("HSET", key, "name", "john")
gtest.Assert(err, nil)
@ -251,3 +260,24 @@ func Test_HSet(t *testing.T) {
gtest.Assert(r.Strings(), g.ArrayStr{"name", "john"})
})
}
func Test_HGetAll(t *testing.T) {
gtest.Case(t, func() {
var err error
redis := gredis.New(config)
key := guuid.New()
defer redis.Do("DEL", key)
_, err = redis.Do("HSET", key, "id", "100")
gtest.Assert(err, nil)
_, err = redis.Do("HSET", key, "name", "john")
gtest.Assert(err, nil)
r, err := redis.DoVar("HGETALL", key)
gtest.Assert(err, nil)
gtest.Assert(r.Map(), g.MapStrAny{
"id": 100,
"name": "john",
})
})
}