From 3c0e0386e1c82572b40a677847d0f3fd075d6f1e Mon Sep 17 00:00:00 2001 From: d1slike Date: Tue, 26 Jul 2022 21:40:19 +0300 Subject: [PATCH] MSP-437 implement test redis client --- tests/redis.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/redis.go diff --git a/tests/redis.go b/tests/redis.go new file mode 100644 index 0000000..3c71b14 --- /dev/null +++ b/tests/redis.go @@ -0,0 +1,25 @@ +package tests + +import ( + "fmt" + + "github.com/go-redis/redis/v8" + "github.com/integration-system/isp-kit/test" +) + +type Redis struct { + address string + redis.UniversalClient +} + +func NewRedis(test *test.Test) Redis { + redisHost := test.Config().Optional().String("REDIS_HOST", "localhost") + redisPort := test.Config().Optional().String("REDIS_PORT", "6379") + addr := fmt.Sprintf("%s:%s", redisHost, redisPort) + cli := redis.NewClient(&redis.Options{Addr: addr}) + return Redis{UniversalClient: cli, address: addr} +} + +func (r Redis) Address() string { + return r.address +}