Skip to content

Commit

Permalink
fix: run ci test with miniredis
Browse files Browse the repository at this point in the history
  • Loading branch information
xgzlucario committed Nov 12, 2024
1 parent 6e18415 commit 4bb31c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
26 changes: 19 additions & 7 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"github.com/alicebob/miniredis/v2"
"math/rand/v2"
"os"
"sync"
Expand Down Expand Up @@ -32,22 +33,33 @@ func startup() {

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

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

require (
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/alicebob/miniredis/v2 v2.33.0 // 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: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
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-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/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 4bb31c3

Please sign in to comment.