Sha256: 9c4cf90d23d4bf4f54d0a93d300f21614a897bb96c2a76e39c36b827ca2c3917

Contents?: true

Size: 1.64 KB

Versions: 52

Compression:

Stored size: 1.64 KB

Contents

# encoding: UTF-8

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

include RedisMock::Helper

setup do
  init Redis.new(OPTIONS)
end

test "INFO" do |r|
  %w(last_save_time redis_version total_connections_received connected_clients total_commands_processed connected_slaves uptime_in_seconds used_memory uptime_in_days changes_since_last_save).each do |x|
    assert r.info.keys.include?(x)
  end
end

test "INFO COMMANDSTATS" do |r|
  # Only available on Redis >= 2.3.0
  next if r.info["redis_version"] < "2.3.0"

  r.config(:resetstat)
  r.ping

  result = r.info(:commandstats)
  assert "1" == result["ping"]["calls"]
end

test "MONITOR" do |r|
  log = []

  wire = Wire.new do
    Redis.new(OPTIONS).monitor do |line|
      log << line
      break if log.size == 3
    end
  end

  Wire.pass while log.empty? # Faster than sleep

  r.set "foo", "s1"

  wire.join

  assert log[-1][%q{(db 15) "set" "foo" "s1"}]
end

test "MONITOR returns value for break" do |r|
  result = r.monitor do |line|
    break line
  end

  assert result == "OK"
end

test "ECHO" do |r|
  assert "foo bar baz\n" == r.echo("foo bar baz\n")
end

test "DEBUG" do |r|
  r.set "foo", "s1"

  assert r.debug(:object, "foo").kind_of?(String)
end

test "OBJECT" do |r|
  r.lpush "list", "value"

  assert r.object(:refcount, "list") == 1
  assert r.object(:encoding, "list") == "ziplist"
  assert r.object(:idletime, "list").kind_of?(Fixnum)
end

test "SYNC" do |r|
  replies = {:sync => lambda { "+OK" }}

  redis_mock(replies) do
    redis = Redis.new(OPTIONS.merge(:port => 6380))

    assert "OK" == redis.sync
  end
end

Version data entries

52 entries across 52 versions & 6 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.7.5 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.7.4 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.7.3 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.7.2 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.7.1 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.7.0 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.9 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.8 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.7 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.6 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.5 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.4 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.3 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.2 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.1 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.6.0 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.5.17 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.5.16 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb
classiccms-0.5.15 vendor/bundle/gems/redis-2.2.2/test/remote_server_control_commands_test.rb