1 ! Copyright (C) 2009 Bruno Deferrari
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: tools.test redis.command-writer io.streams.string ;
4 IN: redis.command-writer.tests
7 [ "QUIT\r\n" ] [ [ quit ] with-string-writer ] unit-test
9 [ "PING\r\n" ] [ [ ping ] with-string-writer ] unit-test
11 [ "AUTH password\r\n" ] [ [ "password" auth ] with-string-writer ] unit-test
14 [ "SET key 3\r\nfoo\r\n" ] [ [ "foo" "key" set ] with-string-writer ] unit-test
16 [ "GET key\r\n" ] [ [ "key" get ] with-string-writer ] unit-test
18 [ "GETSET key 3\r\nfoo\r\n" ] [
19 [ "foo" "key" getset ] with-string-writer
22 [ "MGET key1 key2 key3\r\n" ] [
23 [ { "key1" "key2" "key3" } mget ] with-string-writer
26 [ "SETNX key 3\r\nfoo\r\n" ] [
27 [ "foo" "key" setnx ] with-string-writer
30 [ "INCR key\r\n" ] [ [ "key" incr ] with-string-writer ] unit-test
32 [ "INCRBY key 7\r\n" ] [ [ 7 "key" incrby ] with-string-writer ] unit-test
34 [ "DECR key\r\n" ] [ [ "key" decr ] with-string-writer ] unit-test
36 [ "DECRBY key 7\r\n" ] [ [ 7 "key" decrby ] with-string-writer ] unit-test
38 [ "EXISTS key\r\n" ] [ [ "key" exists ] with-string-writer ] unit-test
40 [ "DEL key\r\n" ] [ [ "key" del ] with-string-writer ] unit-test
42 [ "TYPE key\r\n" ] [ [ "key" type ] with-string-writer ] unit-test
45 [ "KEYS pat*\r\n" ] [ [ "pat*" keys ] with-string-writer ] unit-test
47 [ "RANDOMKEY\r\n" ] [ [ randomkey ] with-string-writer ] unit-test
49 [ "RENAME key newkey\r\n" ] [
50 [ "newkey" "key" rename ] with-string-writer
53 [ "RENAMENX key newkey\r\n" ] [
54 [ "newkey" "key" renamenx ] with-string-writer
57 [ "DBSIZE\r\n" ] [ [ dbsize ] with-string-writer ] unit-test
59 [ "EXPIRE key 7\r\n" ] [ [ 7 "key" expire ] with-string-writer ] unit-test
62 [ "RPUSH key 3\r\nfoo\r\n" ] [ [ "foo" "key" rpush ] with-string-writer ] unit-test
64 [ "LPUSH key 3\r\nfoo\r\n" ] [ [ "foo" "key" lpush ] with-string-writer ] unit-test
66 [ "LLEN key\r\n" ] [ [ "key" llen ] with-string-writer ] unit-test
68 [ "LRANGE key 5 9\r\n" ] [ [ 5 9 "key" lrange ] with-string-writer ] unit-test
70 [ "LTRIM key 5 9\r\n" ] [ [ 5 9 "key" ltrim ] with-string-writer ] unit-test
72 [ "LINDEX key 7\r\n" ] [ [ 7 "key" lindex ] with-string-writer ] unit-test
74 [ "LSET key 0 3\r\nfoo\r\n" ] [ [ "foo" 0 "key" lset ] with-string-writer ] unit-test
76 [ "LREM key 1 3\r\nfoo\r\n" ] [ [ "foo" 1 "key" lrem ] with-string-writer ] unit-test
78 [ "LPOP key\r\n" ] [ [ "key" lpop ] with-string-writer ] unit-test
80 [ "RPOP key\r\n" ] [ [ "key" rpop ] with-string-writer ] unit-test
83 [ "SADD key 3\r\nfoo\r\n" ] [ [ "foo" "key" sadd ] with-string-writer ] unit-test
85 [ "SREM key 3\r\nfoo\r\n" ] [ [ "foo" "key" srem ] with-string-writer ] unit-test
87 [ "SMOVE srckey dstkey 3\r\nfoo\r\n" ] [
88 [ "foo" "dstkey" "srckey" smove ] with-string-writer
91 [ "SCARD key\r\n" ] [ [ "key" scard ] with-string-writer ] unit-test
93 [ "SISMEMBER key 3\r\nfoo\r\n" ] [
94 [ "foo" "key" sismember ] with-string-writer
97 [ "SINTER key1 key2 key3\r\n" ] [
98 [ { "key1" "key2" "key3" } sinter ] with-string-writer
101 [ "SINTERSTORE dstkey key1 key2 key3\r\n" ] [
102 [ { "key1" "key2" "key3" } "dstkey" sinterstore ] with-string-writer
105 [ "SUNION key1 key2 key3\r\n" ] [
106 [ { "key1" "key2" "key3" } sunion ] with-string-writer
109 [ "SUNIONSTORE dstkey key1 key2 key3\r\n" ] [
110 [ { "key1" "key2" "key3" } "dstkey" sunionstore ] with-string-writer
113 [ "SMEMBERS key\r\n" ] [ [ "key" smembers ] with-string-writer ] unit-test
116 [ "SELECT 2\r\n" ] [ [ 2 select ] with-string-writer ] unit-test
118 [ "MOVE key 2\r\n" ] [ [ 2 "key" move ] with-string-writer ] unit-test
120 [ "FLUSHDB\r\n" ] [ [ flushdb ] with-string-writer ] unit-test
122 [ "FLUSHALL\r\n" ] [ [ flushall ] with-string-writer ] unit-test
126 #! Persistence control
127 [ "SAVE\r\n" ] [ [ save ] with-string-writer ] unit-test
129 [ "BGSAVE\r\n" ] [ [ bgsave ] with-string-writer ] unit-test
131 [ "LASTSAVE\r\n" ] [ [ lastsave ] with-string-writer ] unit-test
133 [ "SHUTDOWN\r\n" ] [ [ shutdown ] with-string-writer ] unit-test
135 #! Remote server control
136 [ "INFO\r\n" ] [ [ info ] with-string-writer ] unit-test
138 [ "MONITOR\r\n" ] [ [ monitor ] with-string-writer ] unit-test