gopkg/middleware/redis/redis_test.go

54 lines
1.2 KiB
Go
Raw Permalink Normal View History

2021-02-27 22:48:20 +08:00
// Package redis...
//
// Description : redis...
//
2021-07-25 19:05:59 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-02-27 22:48:20 +08:00
//
// Date : 2021-02-27 10:14 下午
package redis
import (
"fmt"
"testing"
2021-02-27 23:27:21 +08:00
"github.com/stretchr/testify/assert"
2021-02-27 22:48:20 +08:00
redisInstance "github.com/go-redis/redis/v8"
)
// TestCommandProxy ...
//
2021-07-25 19:05:59 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-02-27 22:48:20 +08:00
//
// Date : 10:22 下午 2021/2/27
func TestCommandProxy(t *testing.T) {
instance, err := NewClient(map[string]Options{
2021-03-01 22:44:38 +08:00
"test_redis": {
2021-02-27 22:48:20 +08:00
Conf: &redisInstance.Options{
Addr: "127.0.0.1:6379",
},
Logger: &LoggerConfig{
LoggerPath: "/tmp/test-log",
LoggerFile: "test-pkg-redis-client.log",
LoggerLevel: 0,
ConsoleOutput: true,
Encoder: nil,
SplitConfig: nil,
},
LoggerFieldConfig: nil,
},
2021-02-27 23:27:21 +08:00
}, nil)
2021-02-27 22:48:20 +08:00
if nil != err {
panic(err.Error())
}
2021-02-27 23:27:21 +08:00
r, cmdErr := instance.CommandProxy(nil, "test_redis", "set", "command_proxy", "hello world")
2021-11-27 16:27:48 +08:00
c, _ := instance.GetRedisClient("test_redis")
fmt.Println(GetRedisServerInfo(c.Instance))
fmt.Println(GetCommandInfo(c.Instance))
fmt.Println(GetKeyspace(c.Instance))
fmt.Println(GetCluster(c.Instance))
fmt.Println(GetErrorStats(c.Instance))
2021-02-27 23:27:21 +08:00
assert.Nil(t, cmdErr, "命令执行成功")
assert.Equal(t, "OK", fmt.Sprintf("%v", r))
2021-02-27 22:48:20 +08:00
}