修复RedisCommand BUG + 增加单元测试

This commit is contained in:
2025-04-20 13:40:39 +08:00
parent 653843dc02
commit 299edfcc9a
4 changed files with 49 additions and 2 deletions

29
redis_test.go Normal file
View File

@ -0,0 +1,29 @@
// Package consts ...
//
// Description : consts ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2025-04-20 13:29
package consts
import (
"encoding/json"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
// RedisCmd_String 序列换 RedisCmd
func TestRedisCmd_String(t *testing.T) {
Convey("redis cmd字符串值", t, func() {
byteData, err := json.Marshal(RedisCommandSet)
So(err, ShouldBeNil)
So(RedisCommandSet.String(), ShouldEqual, "SET")
So(string(byteData), ShouldEqual, `"SET"`)
})
Convey("redis cmd MarshalJSON", t, func() {
str, err := RedisCommandSet.MarshalJSON()
So(err, ShouldBeNil)
So(string(str), ShouldEqual, `SET`)
})
}