You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/core/stores/redis/redistest/redistest.go

21 lines
490 B
Go

4 years ago
package redistest
import (
"testing"
4 years ago
"github.com/alicebob/miniredis/v2"
"github.com/zeromicro/go-zero/core/stores/redis"
4 years ago
)
// 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
4 years ago
}