diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/introspection.tcl | 33 | ||||
-rw-r--r-- | tests/unit/pubsub.tcl | 12 | ||||
-rw-r--r-- | tests/unit/scripting.tcl | 2 | ||||
-rw-r--r-- | tests/unit/slowlog.tcl | 12 |
4 files changed, 57 insertions, 2 deletions
diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index 9db0395a2..a6c2130f5 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -19,4 +19,37 @@ start_server {tags {"introspection"}} { assert_match {*eval*} [$rd read] assert_match {*lua*"set"*"foo"*"bar"*} [$rd read] } + + test {CLIENT GETNAME should return NIL if name is not assigned} { + r client getname + } {} + + test {CLIENT LIST shows empty fields for unassigned names} { + r client list + } {*name= *} + + test {CLIENT SETNAME does not accept spaces} { + catch {r client setname "foo bar"} e + set e + } {ERR*} + + test {CLIENT SETNAME can assign a name to this connection} { + assert_equal [r client setname myname] {OK} + r client list + } {*name=myname*} + + test {CLIENT SETNAME can change the name of an existing connection} { + assert_equal [r client setname someothername] {OK} + r client list + } {*name=someothername*} + + test {After CLIENT SETNAME, connection can still be closed} { + set rd [redis_deferring_client] + $rd client setname foobar + assert_equal [$rd read] "OK" + assert_match {*foobar*} [r client list] + $rd close + # Now the client should no longer be listed + string match {*foobar*} [r client list] + } {0} } diff --git a/tests/unit/pubsub.tcl b/tests/unit/pubsub.tcl index c8b547b4f..769151600 100644 --- a/tests/unit/pubsub.tcl +++ b/tests/unit/pubsub.tcl @@ -192,4 +192,14 @@ start_server {tags {"pubsub"}} { # clean up clients $rd1 close } -}
\ No newline at end of file + + test "PUNSUBSCRIBE and UNSUBSCRIBE should always reply." { + # Make sure we are not subscribed to any channel at all. + r punsubscribe + r unsubscribe + # Now check if the commands still reply correctly. + set reply1 [r punsubscribe] + set reply2 [r unsubscribe] + concat $reply1 $reply2 + } {punsubscribe {} 0 unsubscribe {} 0} +} diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 4333fb64e..64cf00d55 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -34,7 +34,7 @@ start_server {tags {"scripting"}} { r eval {return {1,2,3,'ciao',{1,2}}} 0 } {1 2 3 ciao {1 2}} - test {EVAL - Are the KEYS and ARGS arrays populated correctly?} { + test {EVAL - Are the KEYS and ARGV arrays populated correctly?} { r eval {return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}} 2 a b c d } {a b c d} diff --git a/tests/unit/slowlog.tcl b/tests/unit/slowlog.tcl index e15ddf5ff..bc1e70d85 100644 --- a/tests/unit/slowlog.tcl +++ b/tests/unit/slowlog.tcl @@ -55,4 +55,16 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { set e [lindex [r slowlog get] 0] lindex $e 4 } {sadd set foo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... (1 more bytes)}} + + test {SLOWLOG - EXEC is not logged, just executed commands} { + r config set slowlog-log-slower-than 100000 + r slowlog reset + assert_equal [r slowlog len] 0 + r multi + r debug sleep 0.2 + r exec + assert_equal [r slowlog len] 1 + set e [lindex [r slowlog get] 0] + assert_equal [lindex $e 4] {debug sleep 0.2} + } } |