forked from alicebob/miniredis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_info_test.go
More file actions
78 lines (66 loc) · 1.77 KB
/
cmd_info_test.go
File metadata and controls
78 lines (66 loc) · 1.77 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package miniredis
import (
"testing"
"time"
"github.com/alicebob/miniredis/v2/proto"
)
func TestMiniredis_cmdInfo(t *testing.T) {
t.Run("Invalid section name", func(t *testing.T) {
_, c := runWithClient(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) {
_, c := runWithClient(t)
mustDo(t, c,
"INFO",
proto.String("# Clients\nconnected_clients:1\r\n# Stats\ntotal_connections_received:1\r\ntotal_commands_processed:1\r\n"),
)
})
t.Run("Success for clients section", func(t *testing.T) {
s, c := runWithClient(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"),
)
})
t.Run("Success for stats section", func(t *testing.T) {
s, c := runWithClient(t)
mustDo(t, c,
"INFO", "stats",
proto.String("# Stats\ntotal_connections_received:1\r\ntotal_commands_processed:1\r\n"),
)
c2, err := proto.Dial(s.Addr())
ok(t, err)
mustDo(t, c2,
"INFO", "stats",
proto.String("# Stats\ntotal_connections_received:2\r\ntotal_commands_processed: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", "stats",
proto.String("# Stats\ntotal_connections_received:3\r\ntotal_commands_processed:3\r\n"),
)
})
}