@@ -20,6 +20,8 @@ func TestEval(t *testing.T) {
2020 succ ("EVAL" , "return redis.call('GET', 'nosuch')==nil" , 0 ),
2121 succ ("EVAL" , "local a = redis.call('MGET', 'bar'); return a[1] == false" , 0 ),
2222 succ ("EVAL" , "local a = redis.call('MGET', 'bar'); return a[1] == nil" , 0 ),
23+ succ ("EVAL" , "return redis.call('ZRANGE', 'q', 0, -1)" , 0 ),
24+ succ ("EVAL" , "return redis.call('LPOP', 'foo')" , 0 ),
2325
2426 // failure cases
2527 fail ("EVAL" ),
@@ -98,6 +100,7 @@ func TestLua(t *testing.T) {
98100 succ ("EVAL" , "return 3.9999+0.201" , 0 ),
99101 succ ("EVAL" , "return {{1}}" , 0 ),
100102 succ ("EVAL" , "return {1,{1,{1,'bar'}}}" , 0 ),
103+ succ ("EVAL" , "return nil" , 0 ),
101104 )
102105
103106 // special returns
@@ -277,7 +280,7 @@ func TestLuaCall(t *testing.T) {
277280 succ ("GET" , "res" ),
278281 )
279282
280- // call() with transaction commands
283+ // call() with non-allowed commands
281284 testCommands (t ,
282285 succ ("SET" , "foo" , 1 ),
283286
@@ -289,6 +292,42 @@ func TestLuaCall(t *testing.T) {
289292 "This Redis command is not allowed from scripts" ,
290293 "EVAL" , `redis.call("EXEC")` , 0 ,
291294 ),
295+ failWith (
296+ "This Redis command is not allowed from scripts" ,
297+ "EVAL" , `redis.call("EVAL", "redis.call(\"GET\", \"foo\")", 0)` , 0 ,
298+ ),
299+ failWith (
300+ "This Redis command is not allowed from scripts" ,
301+ "EVAL" , `redis.call("SCRIPT", "LOAD", "return 42")` , 0 ,
302+ ),
303+ failWith (
304+ "This Redis command is not allowed from scripts" ,
305+ "EVAL" , `redis.call("EVALSHA", "123", "0")` , 0 ,
306+ ),
307+ failWith (
308+ "This Redis command is not allowed from scripts" ,
309+ "EVAL" , `redis.call("AUTH", "foobar")` , 0 ,
310+ ),
311+ failWith (
312+ "This Redis command is not allowed from scripts" ,
313+ "EVAL" , `redis.call("WATCH", "foobar")` , 0 ,
314+ ),
315+ failWith (
316+ "This Redis command is not allowed from scripts" ,
317+ "EVAL" , `redis.call("SUBSCRIBE", "foo")` , 0 ,
318+ ),
319+ failWith (
320+ "This Redis command is not allowed from scripts" ,
321+ "EVAL" , `redis.call("UNSUBSCRIBE", "foo")` , 0 ,
322+ ),
323+ failWith (
324+ "This Redis command is not allowed from scripts" ,
325+ "EVAL" , `redis.call("PSUBSCRIBE", "foo")` , 0 ,
326+ ),
327+ failWith (
328+ "This Redis command is not allowed from scripts" ,
329+ "EVAL" , `redis.call("PUNSUBSCRIBE", "foo")` , 0 ,
330+ ),
292331 succ ("EVAL" , `redis.pcall("EXEC")` , 0 ),
293332 succ ("GET" , "foo" ),
294333 )
0 commit comments