Sha256: d2f92f3f0a0c06f9cc4e015be75ff1f16a3a280b634a324c1bfd4375acf69a4d

Contents?: true

Size: 975 Bytes

Versions: 23

Compression:

Stored size: 975 Bytes

Contents

# encoding: UTF-8

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

class TestBlockingCommands < Test::Unit::TestCase

  include Helper::Client
  include Lint::BlockingCommands

  def assert_takes_longer_than_client_timeout
    timeout = OPTIONS[:timeout]
    delay = timeout * 2

    mock(:delay => delay) do |r|
      t1 = Time.now
      yield(r)
      t2 = Time.now

      assert timeout == r.client.timeout
      assert delay <= (t2 - t1)
    end
  end

  def test_blpop_disable_client_timeout
    assert_takes_longer_than_client_timeout do |r|
      assert_equal ["foo", "0"], r.blpop("foo")
    end
  end

  def test_brpop_disable_client_timeout
    assert_takes_longer_than_client_timeout do |r|
      assert_equal ["foo", "0"], r.brpop("foo")
    end
  end

  def test_brpoplpush_disable_client_timeout
    assert_takes_longer_than_client_timeout do |r|
      assert_equal "0", r.brpoplpush("foo", "bar")
    end
  end
end

Version data entries

23 entries across 22 versions & 8 rubygems

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