]> git.saurik.com Git - redis.git/blobdiff - test-redis.tcl
Minimal support for subscribe/psubscribe in redis-cli
[redis.git] / test-redis.tcl
index 22e19bab64e3f3ca1aa5ebed2d33e087b3770dba..26b7f12a7e3f29c0e4f4e39c96b426c9857d4ce1 100644 (file)
@@ -935,6 +935,15 @@ proc main {} {
         lsort [array names myset]
     } {a b c}
 
+    test {SORT ALPHA against integer encoded strings} {
+        $r del mylist
+        $r lpush mylist 2
+        $r lpush mylist 1
+        $r lpush mylist 3
+        $r lpush mylist 10
+        $r sort mylist alpha
+    } {1 10 2 3}
+
     test {Create a random list and a random set} {
         set tosort {}
         array set seenrand {}
@@ -972,6 +981,24 @@ proc main {} {
         $r sort tosort {BY wobj_*->weight}
     } $res
 
+    test {SORT with GET (key+hash) with sanity check of each element (list)} {
+        set err {}
+        set l1 [$r sort tosort GET # GET weight_*]
+        set l2 [$r sort tosort GET # GET wobj_*->weight]
+        foreach {id1 w1} $l1 {id2 w2} $l2 {
+            set realweight [$r get weight_$id1]
+            if {$id1 != $id2} {
+                set err "ID mismatch $id1 != $id2"
+                break
+            }
+            if {$realweight != $w1 || $realweight != $w2} {
+                set err "Weights mismatch! w1: $w1 w2: $w2 real: $realweight"
+                break
+            }
+        }
+        set _ $err
+    } {}
+
     test {SORT with BY, but against the newly created set} {
         $r sort tosort-set {BY weight_*}
     } $res
@@ -1914,6 +1941,30 @@ proc main {} {
         $r ttl x
     } {1[345]}
 
+    test {SETEX - Set + Expire combo operation. Check for TTL} {
+        $r setex x 12 test
+        $r ttl x
+    } {1[012]}
+
+    test {SETEX - Check value} {
+        $r get x
+    } {test}
+
+    test {SETEX - Overwrite old key} {
+        $r setex y 1 foo
+        $r get y
+    } {foo}
+
+    test {SETEX - Wait for the key to expire} {
+        after 3000
+        $r get y
+    } {}
+
+    test {SETEX - Wrong time parameter} {
+        catch {$r setex z -10 foo} e
+        set _ $e
+    } {*invalid expire*}
+
     test {ZSETs skiplist implementation backlink consistency test} {
         set diff 0
         set elements 10000