Sha256: fd1a194219926013f2eab3755903665bec002d8165be20437c227321eb889835

Contents?: true

Size: 1.79 KB

Versions: 21

Compression:

Stored size: 1.79 KB

Contents

# encoding: UTF-8

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

class TestDistributedCommandsOnValueTypes < Test::Unit::TestCase

  include Helper::Distributed
  include Lint::ValueTypes

  def test_del
    r.set "foo", "s1"
    r.set "bar", "s2"
    r.set "baz", "s3"

    assert_equal ["bar", "baz", "foo"], r.keys("*").sort

    assert_equal 1, r.del("foo")

    assert_equal ["bar", "baz"], r.keys("*").sort

    assert_equal 2, r.del("bar", "baz")

    assert_equal [], r.keys("*").sort
  end

  def test_del_with_array_argument
    r.set "foo", "s1"
    r.set "bar", "s2"
    r.set "baz", "s3"

    assert_equal ["bar", "baz", "foo"], r.keys("*").sort

    assert_equal 1, r.del(["foo"])

    assert_equal ["bar", "baz"], r.keys("*").sort

    assert_equal 2, r.del(["bar", "baz"])

    assert_equal [], r.keys("*").sort
  end

  def test_randomkey
    assert_raise Redis::Distributed::CannotDistribute do
      r.randomkey
    end
  end

  def test_rename
    assert_raise Redis::Distributed::CannotDistribute do
      r.set("foo", "s1")
      r.rename "foo", "bar"
    end

    assert_equal "s1", r.get("foo")
    assert_equal nil, r.get("bar")
  end

  def test_renamenx
    assert_raise Redis::Distributed::CannotDistribute do
      r.set("foo", "s1")
      r.rename "foo", "bar"
    end

    assert_equal "s1", r.get("foo")
    assert_equal nil , r.get("bar")
  end

  def test_dbsize
    assert_equal [0], r.dbsize

    r.set("foo", "s1")

    assert_equal [1], r.dbsize
  end

  def test_flushdb
    r.set("foo", "s1")
    r.set("bar", "s2")

    assert_equal [2], r.dbsize

    r.flushdb

    assert_equal [0], r.dbsize
  end

  def test_migrate
    r.set("foo", "s1")

    assert_raise Redis::Distributed::CannotDistribute do
      r.migrate("foo", {})
    end
  end
end

Version data entries

21 entries across 20 versions & 7 rubygems

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