forked from alicebob/miniredis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_cluster_test.go
49 lines (43 loc) · 917 Bytes
/
cmd_cluster_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
package miniredis
import (
"strconv"
"testing"
"github.com/alicebob/miniredis/v2/proto"
)
// Test CLUSTER *.
func TestCluster(t *testing.T) {
s := RunT(t)
c, err := proto.Dial(s.Addr())
ok(t, err)
defer c.Close()
t.Run("slots", func(t *testing.T) {
port, err := strconv.Atoi(s.Port())
ok(t, err)
mustDo(t, c,
"CLUSTER", "SLOTS",
proto.Array(
proto.Array(
proto.Int(0),
proto.Int(16383),
proto.Array(
proto.String(s.Host()),
proto.Int(port),
proto.String("09dbe9720cda62f7865eabc5fd8857c5d2678366"),
),
),
),
)
})
t.Run("nodes", func(t *testing.T) {
mustDo(t, c,
"CLUSTER", "NODES",
proto.String("e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 127.0.0.1:7000@7000 myself,master - 0 0 1 connected 0-16383"),
)
})
t.Run("keyslot", func(t *testing.T) {
mustDo(t, c,
"CLUSTER", "keyslot", "{test_key}",
proto.Int(163),
)
})
}