]> git.saurik.com Git - redis.git/blobdiff - tests/unit/multi.tcl
Test: MULTI state is cleared after EXECABORT error.
[redis.git] / tests / unit / multi.tcl
index 9069b95bef8bc992fdcc4d266bcdf9328222e012..6f44767b502f90857dd5ddbd28ce9e4f259e2f20 100644 (file)
@@ -46,6 +46,45 @@ start_server {tags {"multi"}} {
         set _ $err
     } {*ERR WATCH*}
 
+    test {EXEC fails if there are errors while queueing commands #1} {
+        r del foo1 foo2
+        r multi
+        r set foo1 bar1
+        catch {r non-existing-command}
+        r set foo2 bar2
+        catch {r exec} e
+        assert_match {EXECABORT*} $e
+        list [r exists foo1] [r exists foo2]
+    } {0 0}
+
+    test {EXEC fails if there are errors while queueing commands #2} {
+        set rd [redis_deferring_client]
+        r del foo1 foo2
+        r multi
+        r set foo1 bar1
+        $rd config set maxmemory 1
+        catch {r lpush mylist myvalue}
+        $rd config set maxmemory 0
+        r set foo2 bar2
+        catch {r exec} e
+        assert_match {EXECABORT*} $e
+        assert  {[$rd read] eq {OK}}
+        assert  {[$rd read] eq {OK}}
+        $rd close
+        list [r exists foo1] [r exists foo2]
+    } {0 0}
+
+    test {If EXEC aborts, the client MULTI state is cleared} {
+        r del foo1 foo2
+        r multi
+        r set foo1 bar1
+        catch {r non-existing-command}
+        r set foo2 bar2
+        catch {r exec} e
+        assert_match {EXECABORT*} $e
+        r ping
+    } {PONG}
+
     test {EXEC works on WATCHed key not modified} {
         r watch x y z
         r watch k