Sha256: b369ac45aa90e632952b8fd7a3931cae29e42312e1444a24a2a324e360fd258b

Contents?: true

Size: 1.32 KB

Versions: 54

Compression:

Stored size: 1.32 KB

Contents

# encoding: UTF-8

require File.expand_path("./helper", File.dirname(__FILE__))

setup do
  init Redis.new(OPTIONS)
end

# Every test shouldn't disconnect from the server. Also, when error replies are
# in play, the protocol should never get into an invalid state where there are
# pending replies in the connection. Calling INFO after every test ensures that
# the protocol is still in a valid state.
def test_with_reconnection_check(title)
  test(title) do |r|
    before = r.info["total_connections_received"]
    yield(r)
    after = r.info["total_connections_received"]
    assert before == after
  end
end

test_with_reconnection_check "Error reply for single command" do |r|
  begin
    r.unknown_command
  rescue => ex
  ensure
    assert ex.message =~ /unknown command/i
  end
end

test_with_reconnection_check "Raise first error reply in pipeline" do |r|
  begin
    r.pipelined do
      r.set("foo", "s1")
      r.incr("foo") # not an integer
      r.lpush("foo", "value") # wrong kind of value
    end
  rescue => ex
  ensure
    assert ex.message =~ /not an integer/i
  end
end

test_with_reconnection_check "Recover from raise in #call_loop" do |r|
  begin
    r.client.call_loop([:invalid_monitor]) do
      assert false # Should never be executed
    end
  rescue => ex
  ensure
    assert ex.message =~ /unknown command/i
  end
end

Version data entries

54 entries across 54 versions & 7 rubygems

Version Path
classiccms-0.3.5 vendor/bundle/gems/redis-2.2.2/test/error_replies_test.rb
classiccms-0.3.4 vendor/bundle/gems/redis-2.2.2/test/error_replies_test.rb
classiccms-0.3.3 vendor/bundle/gems/redis-2.2.2/test/error_replies_test.rb
classiccms-0.3.2 vendor/bundle/gems/redis-2.2.2/test/error_replies_test.rb
classiccms-0.3.1 vendor/bundle/gems/redis-2.2.2/test/error_replies_test.rb
classiccms-0.3.0 vendor/bundle/gems/redis-2.2.2/test/error_replies_test.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/redis-2.2.2/test/error_replies_test.rb
gorsuch-redis-3.0.0.rc1 test/error_replies_test.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/redis-2.2.2/test/error_replies_test.rb
redis-3.0.0.rc1 test/error_replies_test.rb
yam-redis-with-retries-2.2.2.1 test/error_replies_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/redis-2.2.2/test/error_replies_test.rb
redis-2.2.2 test/error_replies_test.rb
redis-2.2.1 test/error_replies_test.rb