Sha256: 6af549b20354848f2e0bd446fcd1689fdf8a7849b19d14e98199f1fd8c0a0adf

Contents?: true

Size: 1.47 KB

Versions: 23

Compression:

Stored size: 1.47 KB

Contents

# encoding: UTF-8

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

class TestErrorReplies < Test::Unit::TestCase

  include Helper::Client

  # 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 with_reconnection_check
    before = r.info["total_connections_received"]
    yield(r)
    after = r.info["total_connections_received"]
  ensure
    assert_equal before, after
  end

  def test_error_reply_for_single_command
    with_reconnection_check do
      begin
        r.unknown_command
      rescue => ex
      ensure
        assert ex.message =~ /unknown command/i
      end
    end
  end

  def test_raise_first_error_reply_in_pipeline
    with_reconnection_check do
      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
  end

  def test_recover_from_raise_in__call_loop
    with_reconnection_check do
      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
  end
end

Version data entries

23 entries across 22 versions & 8 rubygems

Version Path
finsync_redis-3.3.5 test/error_replies_test.rb
redis-3.3.5 test/error_replies_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/error_replies_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/error_replies_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/error_replies_test.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/error_replies_test.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/redis-3.3.3/test/error_replies_test.rb
redis-3.3.3 test/error_replies_test.rb
abaci-0.3.0 vendor/bundle/gems/redis-3.3.1/test/error_replies_test.rb
abaci-0.3.0 vendor/bundle/gems/redis-3.3.2/test/error_replies_test.rb
redis-3.3.2 test/error_replies_test.rb
redis-3.3.1 test/error_replies_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/redis-3.3.0/test/error_replies_test.rb
redis-3.3.0 test/error_replies_test.rb
discourse-redis-3.2.2 test/error_replies_test.rb
redis-3.2.2 test/error_replies_test.rb
redis-3.2.1 test/error_replies_test.rb
redis-3.2.0 test/error_replies_test.rb
redis2-namespaced-3.0.7.1 test/error_replies_test.rb
redis2-namespaced-3.0.7 test/error_replies_test.rb