test/lint/lists.rb in redis-3.0.0.rc2 vs test/lint/lists.rb in redis-3.0.0

- old
+ new

@@ -1,9 +1,34 @@ module Lint module Lists + def test_lpush + r.lpush "foo", "s1" + r.lpush "foo", "s2" + + assert_equal 2, r.llen("foo") + assert_equal "s2", r.lpop("foo") + end + + def test_variadic_lpush + return if version < "2.3.9" # 2.4-rc6 + + assert_equal 3, r.lpush("foo", ["s1", "s2", "s3"]) + assert_equal 3, r.llen("foo") + assert_equal "s3", r.lpop("foo") + end + + def test_lpushx + r.lpushx "foo", "s1" + r.lpush "foo", "s2" + r.lpushx "foo", "s3" + + assert_equal 2, r.llen("foo") + assert_equal ["s3", "s2"], r.lrange("foo", 0, -1) + end + def test_rpush r.rpush "foo", "s1" r.rpush "foo", "s2" assert_equal 2, r.llen("foo") @@ -16,26 +41,19 @@ assert_equal 3, r.rpush("foo", ["s1", "s2", "s3"]) assert_equal 3, r.llen("foo") assert_equal "s3", r.rpop("foo") end - def test_lpush - r.lpush "foo", "s1" - r.lpush "foo", "s2" + def test_rpushx + r.rpushx "foo", "s1" + r.rpush "foo", "s2" + r.rpushx "foo", "s3" assert_equal 2, r.llen("foo") - assert_equal "s2", r.lpop("foo") + assert_equal ["s2", "s3"], r.lrange("foo", 0, -1) end - def test_variadic_lpush - return if version < "2.3.9" # 2.4-rc6 - - assert_equal 3, r.lpush("foo", ["s1", "s2", "s3"]) - assert_equal 3, r.llen("foo") - assert_equal "s3", r.lpop("foo") - end - def test_llen r.rpush "foo", "s1" r.rpush "foo", "s2" assert_equal 2, r.llen("foo") @@ -106,8 +124,20 @@ r.rpush "foo", "s2" assert_equal 2, r.llen("foo") assert_equal "s2", r.rpop("foo") assert_equal 1, r.llen("foo") + end + + def test_linsert + r.rpush "foo", "s1" + r.rpush "foo", "s3" + r.linsert "foo", :before, "s3", "s2" + + assert_equal ["s1", "s2", "s3"], r.lrange("foo", 0, -1) + + assert_raise(Redis::CommandError) do + r.linsert "foo", :anywhere, "s3", "s2" + end end end end