Sha256: 60e63c958140bd2faa6ec86b4dfd4a83db42a78b354b2e9e5b54da83c6c55d7b

Contents?: true

Size: 933 Bytes

Versions: 11

Compression:

Stored size: 933 Bytes

Contents

# encoding: UTF-8

require "helper"
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

11 entries across 11 versions & 3 rubygems

Version Path
redis-3.0.5 test/blocking_commands_test.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/redis-3.0.4/test/blocking_commands_test.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/redis-3.0.4/test/blocking_commands_test.rb
redis-3.0.4 test/blocking_commands_test.rb
redis-3.0.3 test/blocking_commands_test.rb
remq-0.0.4 vendor/bundle/gems/redis-3.0.2/test/blocking_commands_test.rb
remq-0.0.3 vendor/bundle/gems/redis-3.0.2/test/blocking_commands_test.rb
redis-3.0.2 test/blocking_commands_test.rb
redis-3.0.1 test/blocking_commands_test.rb
redis-3.0.0 test/blocking_commands_test.rb
redis-3.0.0.rc2 test/blocking_commands_test.rb