-
Notifications
You must be signed in to change notification settings - Fork 2
/
redis-info_test.go
58 lines (52 loc) · 1.02 KB
/
redis-info_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package redisinfo
import (
"encoding/json"
"fmt"
"reflect"
"testing"
"github.com/go-redis/redis"
)
var client *redis.Client
func connect_redis() {
client = redis.NewClient(&redis.Options{
Addr: "localhost:7777",
DB: 0,
})
}
func TestParse(t *testing.T) {
connect_redis()
tests := []struct {
name string
args string
want Client
}{
{
"test_Clients",
"clients",
Client{
ConnectedClients: "1",
ClientRecentMaxInputBuffer: "0",
ClientRecentMaxOutputBuffer: "0",
BlockedClients: "0",
TrackingClients: "0",
ClientsInTimeoutTable: "0",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
info, err := client.Info(tt.args).Result()
if err != nil {
fmt.Println(err)
}
var rinfo Info
got := Parse(info)
if err := json.Unmarshal(got, &rinfo); err != nil {
panic(err)
}
if !reflect.DeepEqual(rinfo.Client, tt.want) {
t.Errorf("Parse() = %v, want %v", rinfo.Client, tt.want)
}
})
}
}