]> git.saurik.com Git - redis.git/commitdiff
Add tests for OK on QUIT
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 15 Oct 2010 10:54:53 +0000 (12:54 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 15 Oct 2010 10:54:53 +0000 (12:54 +0200)
tests/test_helper.tcl
tests/unit/quit.tcl [new file with mode: 0644]

index a6c3e83355c01fa60c1db0e01910d47ecca0e872..4c207f643cf8abfc23b3817754b85fc73d732378 100644 (file)
@@ -115,6 +115,7 @@ proc execute_everything {} {
     execute_tests "unit/expire"
     execute_tests "unit/other"
     execute_tests "unit/cas"
+    execute_tests "unit/quit"
     execute_tests "integration/replication"
     execute_tests "integration/aof"
 #    execute_tests "integration/redis-cli"
diff --git a/tests/unit/quit.tcl b/tests/unit/quit.tcl
new file mode 100644 (file)
index 0000000..4cf440a
--- /dev/null
@@ -0,0 +1,40 @@
+start_server {tags {"quit"}} {
+    proc format_command {args} {
+        set cmd "*[llength $args]\r\n"
+        foreach a $args {
+            append cmd "$[string length $a]\r\n$a\r\n"
+        }
+        set _ $cmd
+    }
+
+    test "QUIT returns OK" {
+        reconnect
+        assert_equal OK [r quit]
+        assert_error * {r ping}
+    }
+
+    test "Pipelined commands after QUIT must not be executed" {
+        reconnect
+        r write [format_command quit]
+        r write [format_command set foo bar]
+        r flush
+        assert_equal OK [r read]
+        assert_error * {r read}
+
+        reconnect
+        assert_equal {} [r get foo]
+    }
+
+    test "Pipelined commands after QUIT that exceed read buffer size" {
+        reconnect
+        r write [format_command quit]
+        r write [format_command set foo [string repeat "x" 1024]]
+        r flush
+        assert_equal OK [r read]
+        assert_error * {r read}
+
+        reconnect
+        assert_equal {} [r get foo]
+
+    }
+}