39 lines
1001 B
Go
39 lines
1001 B
Go
// 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"`)
|
|
dataList := []RedisCmd{RedisCommandSet}
|
|
jsonData, err := json.Marshal(dataList)
|
|
So(err, ShouldBeNil)
|
|
So(string(jsonData), ShouldEqual, `["SET"]`)
|
|
})
|
|
Convey("redis cmd MarshalBinary", t, func() {
|
|
str, err := RedisCommandSet.MarshalBinary()
|
|
So(err, ShouldBeNil)
|
|
So(string(str), ShouldEqual, `SET`)
|
|
})
|
|
}
|