-
Notifications
You must be signed in to change notification settings - Fork 220
/
cmd_info_test.go
51 lines (42 loc) · 1016 Bytes
/
cmd_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
package miniredis
import (
"testing"
"time"
"github.com/alicebob/miniredis/v2/proto"
)
func TestMiniredis_cmdInfo(t *testing.T) {
s, c := runWithClient(t)
t.Run("Invalid section name", func(t *testing.T) {
mustDo(t, c,
"INFO", "invalid_or_unsupported_section_name",
proto.Error("section (invalid_or_unsupported_section_name) is not supported"),
)
})
t.Run("No section name in args", func(t *testing.T) {
mustDo(t, c,
"INFO",
proto.String("# Clients\nconnected_clients:1\r\n"),
)
})
t.Run("Success", func(t *testing.T) {
mustDo(t, c,
"INFO", "clients",
proto.String("# Clients\nconnected_clients:1\r\n"),
)
c2, err := proto.Dial(s.Addr())
ok(t, err)
mustDo(t, c2,
"INFO", "clients",
proto.String("# Clients\nconnected_clients:2\r\n"),
)
c2.Close()
time.Sleep(10 * time.Millisecond)
c3, err := proto.Dial(s.Addr())
ok(t, err)
defer c3.Close()
mustDo(t, c3,
"INFO", "clients",
proto.String("# Clients\nconnected_clients:2\r\n"),
)
})
}