forked from alicebob/miniredis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_test.go
68 lines (58 loc) · 1.65 KB
/
server_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
59
60
61
62
63
64
65
66
67
68
package main
import (
"testing"
)
func TestServer(t *testing.T) {
skip(t)
testRaw(t, func(c *client) {
c.Do("SET", "foo", "bar")
c.Do("SET", "baz", "bak")
c.Do("XADD", "planets", "123-456", "name", "Earth")
c.Do("DBSIZE")
c.Do("SELECT", "2")
c.Do("DBSIZE")
c.Do("SET", "baz", "bak")
c.Do("SELECT", "0")
c.Do("FLUSHDB")
c.Do("DBSIZE")
c.Do("SELECT", "2")
c.Do("DBSIZE")
c.Do("FLUSHALL")
c.Do("DBSIZE")
c.Do("FLUSHDB", "aSyNc")
c.Do("FLUSHALL", "AsYnC")
// Failure cases
c.Error("wrong number", "DBSIZE", "foo")
c.Error("syntax error", "FLUSHDB", "foo")
c.Error("syntax error", "FLUSHALL", "foo")
c.Error("syntax error", "FLUSHDB", "ASYNC", "foo")
c.Error("syntax error", "FLUSHDB", "ASYNC", "ASYNC")
c.Error("syntax error", "FLUSHALL", "ASYNC", "foo")
})
testRaw(t, func(c *client) {
c.Do("SET", "plain", "hello")
c.DoLoosely("MEMORY", "USAGE", "plain")
c.Do("LPUSH", "alist", "hello", "42")
c.DoLoosely("MEMORY", "USAGE", "alist")
c.Do("HSET", "ahash", "key", "value")
c.DoLoosely("MEMORY", "USAGE", "ahash")
c.Do("ZADD", "asset", "0", "line")
c.DoLoosely("MEMORY", "USAGE", "asset")
c.Do("PFADD", "ahll", "123")
c.DoLoosely("MEMORY", "USAGE", "ahll")
c.Do("XADD", "astream", "0-1", "name", "Mercury")
c.DoLoosely("MEMORY", "USAGE", "astream")
c.DoLoosely("MEMORY", "USAGE", "nosuch")
c.Error("Try MEMORY HELP", "MEMORY", "FOO")
c.Error("wrong number of arguments", "MEMORY", "USAGE")
c.Error("syntax error", "MEMORY", "USAGE", "too", "many")
})
}
func TestServerTLS(t *testing.T) {
skip(t)
testTLS(t, func(c *client) {
c.Do("PING", "foo")
c.Do("SET", "foo", "bar")
c.Do("GET", "foo")
})
}