test/command.rb in ohm-1.4.0 vs test/command.rb in ohm-2.0.0.alpha1

- old
+ new

@@ -1,57 +1,55 @@ require_relative "helper" scope do setup do - redis = Redis.connect - redis.flushdb + redis = Redic.new + redis.call("FLUSHDB") - # require 'logger' - # redis.client.logger = Logger.new(STDOUT) - nest = Nest.new("User:tmp", redis) + nido = Nido.new("User:tmp") - [1, 2, 3].each { |i| redis.sadd("A", i) } - [1, 4, 5].each { |i| redis.sadd("B", i) } + [1, 2, 3].each { |i| redis.call("SADD", "A", i) } + [1, 4, 5].each { |i| redis.call("SADD", "B", i) } - [10, 11, 12].each { |i| redis.sadd("C", i) } - [11, 12, 13].each { |i| redis.sadd("D", i) } - [12, 13, 14].each { |i| redis.sadd("E", i) } + [10, 11, 12].each { |i| redis.call("SADD", "C", i) } + [11, 12, 13].each { |i| redis.call("SADD", "D", i) } + [12, 13, 14].each { |i| redis.call("SADD", "E", i) } - [10, 11, 12].each { |i| redis.sadd("F", i) } - [11, 12, 13].each { |i| redis.sadd("G", i) } - [12, 13, 14].each { |i| redis.sadd("H", i) } + [10, 11, 12].each { |i| redis.call("SADD", "F", i) } + [11, 12, 13].each { |i| redis.call("SADD", "G", i) } + [12, 13, 14].each { |i| redis.call("SADD", "H", i) } - [redis, nest] + [redis, nido] end test "special condition: single argument returns that arg" do assert_equal "A", Ohm::Command[:sinterstore, "A"] end - test "full stack test" do |redis, nest| + test "full stack test" do |redis, nido| cmd1 = Ohm::Command[:sinterstore, "A", "B"] - res = cmd1.call(nest, redis) - assert_equal ["1"], res.smembers + res = cmd1.call(nido, redis) + assert_equal ["1"], redis.call("SMEMBERS", res) cmd1.clean - assert ! res.exists + assert_equal 0, redis.call("EXISTS", res) cmd2 = Ohm::Command[:sinterstore, "C", "D", "E"] cmd3 = Ohm::Command[:sunionstore, cmd1, cmd2] - res = cmd3.call(nest, redis) - assert_equal ["1", "12"], res.smembers + res = cmd3.call(nido, redis) + assert_equal ["1", "12"], redis.call("SMEMBERS", res) cmd3.clean - assert redis.keys(nest["*"]).empty? + assert redis.call("KEYS", nido["*"]).empty? cmd4 = Ohm::Command[:sinterstore, "F", "G", "H"] cmd5 = Ohm::Command[:sdiffstore, cmd3, cmd4] - res = cmd5.call(nest, redis) - assert_equal ["1"], res.smembers + res = cmd5.call(nido, redis) + assert_equal ["1"], redis.call("SMEMBERS", res) cmd5.clean - assert redis.keys(nest["*"]).empty? + assert redis.call("KEYS", nido["*"]).empty? end end