Files
go-zero/core/stores/redis/redistest/redistest.go

21 lines
490 B
Go
Raw Normal View History

2020-11-02 17:51:33 +08:00
package redistest
import (
"testing"
2020-11-02 17:51:33 +08:00
"github.com/alicebob/miniredis/v2"
"github.com/zeromicro/go-zero/core/stores/redis"
2020-11-02 17:51:33 +08:00
)
2022-11-04 21:55:17 +08:00
// CreateRedis returns an in process redis.Redis.
func CreateRedis(t *testing.T) *redis.Redis {
r, _ := CreateRedisWithClean(t)
return r
}
// CreateRedisWithClean returns an in process redis.Redis and a clean function.
func CreateRedisWithClean(t *testing.T) (r *redis.Redis, clean func()) {
mr := miniredis.RunT(t)
return redis.New(mr.Addr()), mr.Close
2020-11-02 17:51:33 +08:00
}