Skip to content

Commit

Permalink
feat: test by real redis
Browse files Browse the repository at this point in the history
  • Loading branch information
xgzlucario committed Nov 10, 2024
1 parent 3cf6621 commit 6e18415
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ build:
go build -o rotom -ldflags "-s -w -X main.buildTime=$(shell date +%y%m%d_%H%M%S%z)"

build-docker:
docker build --build-arg BUILD_TIME=$(shell date +%y%m%d_%H%M%S%z) -t rotom .
docker build --build-arg BUILD_TIME=$(shell date +%y%m%d_%H%M%S%z) -t rotom .

run-redis:
docker run --rm -p 6379:6379 --name redis-test redis
15 changes: 8 additions & 7 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"
"time"

"github.com/alicebob/miniredis/v2"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
)
Expand All @@ -33,19 +32,21 @@ func startup() {

const (
testTypeRotom = "rotom"
testTypeMiniRedis = "miniredis"
testTypeRealRedis = "realRedis"
)

func TestCommand(t *testing.T) {
t.Run(testTypeMiniRedis, func(t *testing.T) {
s := miniredis.RunT(t)
t.Run(testTypeRealRedis, func(t *testing.T) {
// NOTES: run redis first!
rdb := redis.NewClient(&redis.Options{
Addr: s.Addr(),
Addr: ":6379",
})
sleepFn := func(dur time.Duration) {
s.FastForward(dur)
time.Sleep(dur)
}
testCommand(t, testTypeMiniRedis, rdb, sleepFn)
rdb.FlushDB(context.Background())
testCommand(t, testTypeRealRedis, rdb, sleepFn)
rdb.FlushDB(context.Background())
})
t.Run(testTypeRotom, func(t *testing.T) {
go startup()
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/xgzlucario/rotom
go 1.23

require (
github.com/alicebob/miniredis/v2 v2.33.0
github.com/bytedance/sonic v1.12.4
github.com/chen3feng/stl4go v0.1.1
github.com/cockroachdb/swiss v0.0.0-20240612210725-f4de07ae6964
Expand All @@ -19,7 +18,6 @@ require (
)

require (
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
github.com/aclements/go-perfevent v0.0.0-20240301234650-f7843625020f h1:JjxwchlOepwsUWcQwD2mLUAGE9aCp0/ehy6yCHFBOvo=
github.com/aclements/go-perfevent v0.0.0-20240301234650-f7843625020f/go.mod h1:tMDTce/yLLN/SK8gMOxQfnyeMeCg8KGzp0D1cbECEeo=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA=
github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
Expand Down

0 comments on commit 6e18415

Please sign in to comment.