From 5e3880a492efd6c305d7bde5be44c1de72e15cb0 Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Mon, 25 Apr 2016 16:49:57 +0300 Subject: various cleanups and minor fixes --- tests/support/test.tcl | 6 ------ tests/unit/bitops.tcl | 2 +- tests/unit/other.tcl | 1 + tests/unit/scripting.tcl | 27 ++++++++++++++------------- 4 files changed, 16 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/support/test.tcl b/tests/support/test.tcl index 31371c567..d60eb3c47 100644 --- a/tests/support/test.tcl +++ b/tests/support/test.tcl @@ -37,13 +37,7 @@ proc assert_error {pattern code} { } proc assert_encoding {enc key} { - # Swapped out values don't have an encoding, so make sure that - # the value is swapped in before checking the encoding. set dbg [r debug object $key] - while {[string match "* swapped at:*" $dbg]} { - r debug swapin $key - set dbg [r debug object $key] - } assert_match "* encoding:$enc *" $dbg } diff --git a/tests/unit/bitops.tcl b/tests/unit/bitops.tcl index 309a5d460..30aa832c7 100644 --- a/tests/unit/bitops.tcl +++ b/tests/unit/bitops.tcl @@ -88,7 +88,7 @@ start_server {tags {"bitops"}} { } {ERR*syntax*} test {BITCOUNT regression test for github issue #582} { - r del str + r del foo r setbit foo 0 1 if {[catch {r bitcount foo 0 4294967296} e]} { assert_match {*ERR*out of range*} $e diff --git a/tests/unit/other.tcl b/tests/unit/other.tcl index a53f3f5c8..2f5773930 100644 --- a/tests/unit/other.tcl +++ b/tests/unit/other.tcl @@ -194,6 +194,7 @@ start_server {tags {"other"}} { } test {APPEND basics} { + r del foo list [r append foo bar] [r get foo] \ [r append foo 100] [r get foo] } {3 bar 6 bar100} diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 0efe86ad6..07553b1d6 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -62,18 +62,19 @@ start_server {tags {"scripting"}} { } {NOSCRIPT*} test {EVAL - Redis integer -> Lua type conversion} { + r set x 0 r eval { - local foo = redis.pcall('incr','x') + local foo = redis.pcall('incr',KEYS[1]) return {type(foo),foo} - } 0 + } 1 x } {number 1} test {EVAL - Redis bulk -> Lua type conversion} { r set mykey myval r eval { - local foo = redis.pcall('get','mykey') + local foo = redis.pcall('get',KEYS[1]) return {type(foo),foo} - } 0 + } 1 mykey } {string myval} test {EVAL - Redis multi bulk -> Lua type conversion} { @@ -82,39 +83,39 @@ start_server {tags {"scripting"}} { r rpush mylist b r rpush mylist c r eval { - local foo = redis.pcall('lrange','mylist',0,-1) + local foo = redis.pcall('lrange',KEYS[1],0,-1) return {type(foo),foo[1],foo[2],foo[3],# foo} - } 0 + } 1 mylist } {table a b c 3} test {EVAL - Redis status reply -> Lua type conversion} { r eval { - local foo = redis.pcall('set','mykey','myval') + local foo = redis.pcall('set',KEYS[1],'myval') return {type(foo),foo['ok']} - } 0 + } 1 mykey } {table OK} test {EVAL - Redis error reply -> Lua type conversion} { r set mykey myval r eval { - local foo = redis.pcall('incr','mykey') + local foo = redis.pcall('incr',KEYS[1]) return {type(foo),foo['err']} - } 0 + } 1 mykey } {table {ERR value is not an integer or out of range}} test {EVAL - Redis nil bulk reply -> Lua type conversion} { r del mykey r eval { - local foo = redis.pcall('get','mykey') + local foo = redis.pcall('get',KEYS[1]) return {type(foo),foo == false} - } 0 + } 1 mykey } {boolean 1} test {EVAL - Is the Lua client using the currently selected DB?} { r set mykey "this is DB 9" r select 10 r set mykey "this is DB 10" - r eval {return redis.pcall('get','mykey')} 0 + r eval {return redis.pcall('get',KEYS[1])} 1 mykey } {this is DB 10} test {EVAL - SELECT inside Lua should not affect the caller} { -- cgit v1.2.1