From ab9d4cb1e3de4379afb175e092ff4aa44d4f72cc Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 18 Dec 2009 06:45:26 -0500 Subject: [PATCH] LTRIM now returns +OK against non existing keys. More tests in test-redis.tcl --- redis.c | 2 +- test-redis.tcl | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/redis.c b/redis.c index 52443129..dde1630d 100644 --- a/redis.c +++ b/redis.c @@ -3631,7 +3631,7 @@ static void ltrimCommand(redisClient *c) { o = lookupKeyWrite(c->db,c->argv[1]); if (o == NULL) { - addReply(c,shared.nokeyerr); + addReply(c,shared.ok); } else { if (o->type != REDIS_LIST) { addReply(c,shared.wrongtypeerr); diff --git a/test-redis.tcl b/test-redis.tcl index d7b42135..3983ee3b 100644 --- a/test-redis.tcl +++ b/test-redis.tcl @@ -126,7 +126,19 @@ proc createComplexDataset {r ops} { for {set j 0} {$j < $ops} {incr j} { set k [randomKey] set v [randomValue] - set d [expr {rand()}] + randpath { + set d [expr {rand()}] + } { + set d [expr {rand()}] + } { + set d [expr {rand()}] + } { + set d [expr {rand()}] + } { + set d [expr {rand()}] + } { + randpath {set d +inf} {set d -inf} + } set t [$r type $k] if {$t eq {none}} { @@ -308,6 +320,11 @@ proc main {server port} { $r incrby novar 17179869184 } {34359738368} + test {INCR against key with spaces (no integer encoded)} { + $r set novar " 11 " + $r incr novar + } {12} + test {DECRBY over 32bit value with over 32bit increment, negative res} { $r set novar 17179869184 $r decrby novar 17179869185 @@ -370,7 +387,8 @@ proc main {server port} { append res [$r lindex mylist 0] append res [$r lindex mylist 1] append res [$r lindex mylist 2] - } {3bac} + list $res [$r lindex mylist 100] + } {3bac {}} test {DEL a list} { $r del mylist @@ -423,11 +441,19 @@ proc main {server port} { format $err } {ERR*} + test {LLEN against non existing key} { + $r llen not-a-key + } {0} + test {LINDEX against non-list value error} { catch {$r lindex mylist 0} err format $err } {ERR*} + test {LINDEX against non existing key} { + $r lindex not-a-key 10 + } {} + test {LPUSH against non-list value error} { catch {$r lpush mylist 0} err format $err -- 2.45.2