test/internals_test.rb in redis-3.0.5 vs test/internals_test.rb in redis-3.0.6
- old
+ new
@@ -1,8 +1,8 @@
# encoding: UTF-8
-require "helper"
+require File.expand_path("helper", File.dirname(__FILE__))
class TestInternals < Test::Unit::TestCase
include Helper::Client
@@ -107,10 +107,21 @@
assert_nothing_raised do
Redis.new(OPTIONS.merge(:timeout => 0))
end
end
+ def test_id_inside_multi
+ redis = Redis.new(OPTIONS)
+ id = nil
+
+ redis.multi do
+ id = redis.id
+ end
+
+ assert_equal id, "redis://127.0.0.1:6381/15"
+ end
+
driver(:ruby) do
def test_tcp_keepalive
keepalive = {:time => 20, :intvl => 10, :probes => 5}
redis = Redis.new(OPTIONS.merge(:tcp_keepalive => keepalive))
@@ -126,19 +137,19 @@
end
end
end
def test_time
- return if version < "2.5.4"
+ target_version "2.5.4" do
+ # Test that the difference between the time that Ruby reports and the time
+ # that Redis reports is minimal (prevents the test from being racy).
+ rv = r.time
- # Test that the difference between the time that Ruby reports and the time
- # that Redis reports is minimal (prevents the test from being racy).
- rv = r.time
+ redis_usec = rv[0] * 1_000_000 + rv[1]
+ ruby_usec = Integer(Time.now.to_f * 1_000_000)
- redis_usec = rv[0] * 1_000_000 + rv[1]
- ruby_usec = Integer(Time.now.to_f * 1_000_000)
-
- assert 500_000 > (ruby_usec - redis_usec).abs
+ assert 500_000 > (ruby_usec - redis_usec).abs
+ end
end
def test_connection_timeout
assert_raise Redis::CannotConnectError do
Redis.new(OPTIONS.merge(:host => "10.255.255.254", :timeout => 0.1)).ping