修复RedisCommand BUG + 增加单元测试
This commit is contained in:
parent
653843dc02
commit
299edfcc9a
12
go.mod
12
go.mod
@ -1,3 +1,13 @@
|
||||
module git.zhangdeman.cn/zhangdeman/consts
|
||||
|
||||
go 1.19
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.24.2
|
||||
|
||||
require github.com/smartystreets/goconvey v1.8.1
|
||||
|
||||
require (
|
||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||
github.com/jtolds/gls v4.20.0+incompatible // indirect
|
||||
github.com/smarty/assertions v1.15.0 // indirect
|
||||
)
|
||||
|
8
go.sum
Normal file
8
go.sum
Normal file
@ -0,0 +1,8 @@
|
||||
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
||||
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
|
||||
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
|
||||
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
|
||||
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
|
2
redis.go
2
redis.go
@ -17,7 +17,7 @@ func (rc *RedisCmd) MarshalJSON() ([]byte, error) {
|
||||
return []byte(rc.String()), nil
|
||||
}
|
||||
|
||||
const (
|
||||
var (
|
||||
RedisCommandExists RedisCmd = "EXISTS"
|
||||
RedisCommandTTL RedisCmd = "TTL"
|
||||
RedisCommandSet RedisCmd = "SET"
|
||||
|
29
redis_test.go
Normal file
29
redis_test.go
Normal 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`)
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user