Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
449286a5
Commit
449286a5
authored
May 24, 2011
by
antirez
Browse files
Scripting tests added
parent
e927a246
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/test_helper.tcl
View file @
449286a5
...
...
@@ -127,6 +127,7 @@ proc execute_everything {} {
execute_tests
"integration/aof"
# execute_tests
"integration/redis-cli"
execute_tests
"unit/pubsub"
execute_tests
"unit/scripting"
return
;
# No diskstore tests for now...
# run tests with diskstore enabled
...
...
tests/unit/scripting.tcl
0 → 100644
View file @
449286a5
start_server
{
tags
{
"scripting"
}}
{
test
{
EVAL - Does Lua interpreter replies to our requests?
}
{
r eval
{
return 'hello'
}
0
}
{
hello
}
test
{
EVAL - Lua integer -> Redis protocol type conversion
}
{
r eval
{
return 100.5
}
0
}
{
100
}
test
{
EVAL - Lua string -> Redis protocol type conversion
}
{
r eval
{
return 'hello world'
}
0
}
{
hello world
}
test
{
EVAL - Lua true boolean -> Redis protocol type conversion
}
{
r eval
{
return true
}
0
}
{
1
}
test
{
EVAL - Lua false boolean -> Redis protocol type conversion
}
{
r eval
{
return false
}
0
}
{}
test
{
EVAL - Lua status code reply -> Redis protocol type conversion
}
{
r eval
{
return
{
ok='fine'
}}
0
}
{
fine
}
test
{
EVAL - Lua error reply -> Redis protocol type conversion
}
{
catch
{
r eval
{
return
{
err='this is an error'
}}
0
}
e
set _ $e
}
{
this is an error
}
test
{
EVAL - Lua table -> Redis protocol type conversion
}
{
r eval
{
return
{
1,2,3,'ciao',
{
1,2
}}}
0
}
{
1 2 3 ciao
{
1 2
}}
test
{
EVAL - Are the KEYS and ARGS arrays populated correctly?
}
{
r eval
{
return
{
KEYS
[
1
]
,KEYS
[
2
]
,ARGV
[
1
]
,ARGV
[
2
]}}
2 a b c d
}
{
a b c d
}
test
{
EVAL - is Lua able to call Redis API?
}
{
r set mykey myval
r eval
{
return redis.call
(
'get','mykey'
)}
0
}
{
myval
}
test
{
EVALSHA - Can we call a SHA1 if already defined?
}
{
r evalsha 9bd632c7d33e571e9f24556ebed26c3479a87129 0
}
{
myval
}
test
{
EVALSHA - Do we get an error on non defined SHA1?
}
{
catch
{
r evalsha ffffffffffffffffffffffffffffffffffffffff 0
}
e
set _ $e
}
{
NOSCRIPT*
}
test
{
EVAL - Redis integer -> Lua type conversion
}
{
r eval
{
local foo = redis.call
(
'incr','x'
)
return
{
type
(
foo
)
,foo
}
}
0
}
{
number 1
}
test
{
EVAL - Redis bulk -> Lua type conversion
}
{
r set mykey myval
r eval
{
local foo = redis.call
(
'get','mykey'
)
return
{
type
(
foo
)
,foo
}
}
0
}
{
string myval
}
test
{
EVAL - Redis multi bulk -> Lua type conversion
}
{
r del mylist
r rpush mylist a
r rpush mylist b
r rpush mylist c
r eval
{
local foo = redis.call
(
'lrange','mylist',0,-1
)
return
{
type
(
foo
)
,foo
[
1
]
,foo
[
2
]
,foo
[
3
]
,# foo
}
}
0
}
{
table a b c 3
}
test
{
EVAL - Redis status reply -> Lua type conversion
}
{
r eval
{
local foo = redis.call
(
'set','mykey','myval'
)
return
{
type
(
foo
)
,foo
[
'ok'
]}
}
0
}
{
table OK
}
test
{
EVAL - Redis error reply -> Lua type conversion
}
{
r set mykey myval
r eval
{
local foo = redis.call
(
'incr','mykey'
)
return
{
type
(
foo
)
,foo
[
'err'
]}
}
0
}
{
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.call
(
'get','mykey'
)
return
{
type
(
foo
)
,foo == false
}
}
0
}
{
boolean 1
}
test
{
EVAL - Is Lua affecting 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.call
(
'get','mykey'
)}
0
}
{
this is DB 10
}
test
{
EVAL - Is Lua seleced DB retained?
}
{
r eval
{
return redis.call
(
'select','9'
)}
0
r get mykey
}
{
this is DB 9
}
test
{
EVAL - Script can't run more than configured time limit
}
{
r config set lua-time-limit 1
catch
{
r eval
{
local i = 0
while true do i=i+1 end
}
0
}
e
set _ $e
}
{
*execution time*
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment