summaryrefslogtreecommitdiff
path: root/tests/unit/introspection.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/introspection.tcl')
-rw-r--r--tests/unit/introspection.tcl33
1 files changed, 33 insertions, 0 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}
}