redis 3.3.5 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -2
  3. data/README.md +77 -76
  4. data/lib/redis.rb +779 -63
  5. data/lib/redis/client.rb +41 -20
  6. data/lib/redis/cluster.rb +286 -0
  7. data/lib/redis/cluster/command.rb +81 -0
  8. data/lib/redis/cluster/command_loader.rb +34 -0
  9. data/lib/redis/cluster/key_slot_converter.rb +72 -0
  10. data/lib/redis/cluster/node.rb +104 -0
  11. data/lib/redis/cluster/node_key.rb +35 -0
  12. data/lib/redis/cluster/node_loader.rb +37 -0
  13. data/lib/redis/cluster/option.rb +77 -0
  14. data/lib/redis/cluster/slot.rb +69 -0
  15. data/lib/redis/cluster/slot_loader.rb +49 -0
  16. data/lib/redis/connection.rb +2 -2
  17. data/lib/redis/connection/command_helper.rb +2 -8
  18. data/lib/redis/connection/hiredis.rb +2 -2
  19. data/lib/redis/connection/ruby.rb +13 -30
  20. data/lib/redis/connection/synchrony.rb +12 -4
  21. data/lib/redis/distributed.rb +32 -12
  22. data/lib/redis/errors.rb +46 -0
  23. data/lib/redis/hash_ring.rb +20 -64
  24. data/lib/redis/pipeline.rb +9 -7
  25. data/lib/redis/version.rb +1 -1
  26. metadata +53 -196
  27. data/.gitignore +0 -16
  28. data/.travis.yml +0 -89
  29. data/.travis/Gemfile +0 -11
  30. data/.yardopts +0 -3
  31. data/Gemfile +0 -4
  32. data/Rakefile +0 -87
  33. data/benchmarking/logging.rb +0 -71
  34. data/benchmarking/pipeline.rb +0 -51
  35. data/benchmarking/speed.rb +0 -21
  36. data/benchmarking/suite.rb +0 -24
  37. data/benchmarking/worker.rb +0 -71
  38. data/examples/basic.rb +0 -15
  39. data/examples/consistency.rb +0 -114
  40. data/examples/dist_redis.rb +0 -43
  41. data/examples/incr-decr.rb +0 -17
  42. data/examples/list.rb +0 -26
  43. data/examples/pubsub.rb +0 -37
  44. data/examples/sentinel.rb +0 -41
  45. data/examples/sentinel/start +0 -49
  46. data/examples/sets.rb +0 -36
  47. data/examples/unicorn/config.ru +0 -3
  48. data/examples/unicorn/unicorn.rb +0 -20
  49. data/redis.gemspec +0 -44
  50. data/test/bitpos_test.rb +0 -69
  51. data/test/blocking_commands_test.rb +0 -42
  52. data/test/client_test.rb +0 -59
  53. data/test/command_map_test.rb +0 -30
  54. data/test/commands_on_hashes_test.rb +0 -21
  55. data/test/commands_on_hyper_log_log_test.rb +0 -21
  56. data/test/commands_on_lists_test.rb +0 -20
  57. data/test/commands_on_sets_test.rb +0 -77
  58. data/test/commands_on_sorted_sets_test.rb +0 -137
  59. data/test/commands_on_strings_test.rb +0 -101
  60. data/test/commands_on_value_types_test.rb +0 -133
  61. data/test/connection_handling_test.rb +0 -277
  62. data/test/connection_test.rb +0 -57
  63. data/test/distributed_blocking_commands_test.rb +0 -46
  64. data/test/distributed_commands_on_hashes_test.rb +0 -10
  65. data/test/distributed_commands_on_hyper_log_log_test.rb +0 -33
  66. data/test/distributed_commands_on_lists_test.rb +0 -22
  67. data/test/distributed_commands_on_sets_test.rb +0 -83
  68. data/test/distributed_commands_on_sorted_sets_test.rb +0 -18
  69. data/test/distributed_commands_on_strings_test.rb +0 -59
  70. data/test/distributed_commands_on_value_types_test.rb +0 -95
  71. data/test/distributed_commands_requiring_clustering_test.rb +0 -164
  72. data/test/distributed_connection_handling_test.rb +0 -23
  73. data/test/distributed_internals_test.rb +0 -79
  74. data/test/distributed_key_tags_test.rb +0 -52
  75. data/test/distributed_persistence_control_commands_test.rb +0 -26
  76. data/test/distributed_publish_subscribe_test.rb +0 -92
  77. data/test/distributed_remote_server_control_commands_test.rb +0 -66
  78. data/test/distributed_scripting_test.rb +0 -102
  79. data/test/distributed_sorting_test.rb +0 -20
  80. data/test/distributed_test.rb +0 -58
  81. data/test/distributed_transactions_test.rb +0 -32
  82. data/test/encoding_test.rb +0 -18
  83. data/test/error_replies_test.rb +0 -59
  84. data/test/fork_safety_test.rb +0 -65
  85. data/test/helper.rb +0 -232
  86. data/test/helper_test.rb +0 -24
  87. data/test/internals_test.rb +0 -417
  88. data/test/lint/blocking_commands.rb +0 -150
  89. data/test/lint/hashes.rb +0 -162
  90. data/test/lint/hyper_log_log.rb +0 -60
  91. data/test/lint/lists.rb +0 -143
  92. data/test/lint/sets.rb +0 -140
  93. data/test/lint/sorted_sets.rb +0 -316
  94. data/test/lint/strings.rb +0 -260
  95. data/test/lint/value_types.rb +0 -122
  96. data/test/persistence_control_commands_test.rb +0 -26
  97. data/test/pipelining_commands_test.rb +0 -242
  98. data/test/publish_subscribe_test.rb +0 -282
  99. data/test/remote_server_control_commands_test.rb +0 -118
  100. data/test/scanning_test.rb +0 -413
  101. data/test/scripting_test.rb +0 -78
  102. data/test/sentinel_command_test.rb +0 -80
  103. data/test/sentinel_test.rb +0 -255
  104. data/test/sorting_test.rb +0 -59
  105. data/test/ssl_test.rb +0 -73
  106. data/test/support/connection/hiredis.rb +0 -1
  107. data/test/support/connection/ruby.rb +0 -1
  108. data/test/support/connection/synchrony.rb +0 -17
  109. data/test/support/redis_mock.rb +0 -130
  110. data/test/support/ssl/gen_certs.sh +0 -31
  111. data/test/support/ssl/trusted-ca.crt +0 -25
  112. data/test/support/ssl/trusted-ca.key +0 -27
  113. data/test/support/ssl/trusted-cert.crt +0 -81
  114. data/test/support/ssl/trusted-cert.key +0 -28
  115. data/test/support/ssl/untrusted-ca.crt +0 -26
  116. data/test/support/ssl/untrusted-ca.key +0 -27
  117. data/test/support/ssl/untrusted-cert.crt +0 -82
  118. data/test/support/ssl/untrusted-cert.key +0 -28
  119. data/test/support/wire/synchrony.rb +0 -24
  120. data/test/support/wire/thread.rb +0 -5
  121. data/test/synchrony_driver.rb +0 -88
  122. data/test/test.conf.erb +0 -9
  123. data/test/thread_safety_test.rb +0 -62
  124. data/test/transactions_test.rb +0 -264
  125. data/test/unknown_commands_test.rb +0 -14
  126. data/test/url_param_test.rb +0 -138
@@ -1,21 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/hyper_log_log"
5
-
6
- class TestCommandsOnHyperLogLog < Test::Unit::TestCase
7
-
8
- include Helper::Client
9
- include Lint::HyperLogLog
10
-
11
- def test_pfmerge
12
- target_version "2.8.9" do
13
- r.pfadd "foo", "s1"
14
- r.pfadd "bar", "s2"
15
-
16
- assert_equal true, r.pfmerge("res", "foo", "bar")
17
- assert_equal 2, r.pfcount("res")
18
- end
19
- end
20
-
21
- end
@@ -1,20 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/lists"
5
-
6
- class TestCommandsOnLists < Test::Unit::TestCase
7
-
8
- include Helper::Client
9
- include Lint::Lists
10
-
11
- def test_rpoplpush
12
- r.rpush "foo", "s1"
13
- r.rpush "foo", "s2"
14
-
15
- assert_equal "s2", r.rpoplpush("foo", "bar")
16
- assert_equal ["s2"], r.lrange("bar", 0, -1)
17
- assert_equal "s1", r.rpoplpush("foo", "bar")
18
- assert_equal ["s1", "s2"], r.lrange("bar", 0, -1)
19
- end
20
- end
@@ -1,77 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/sets"
5
-
6
- class TestCommandsOnSets < Test::Unit::TestCase
7
-
8
- include Helper::Client
9
- include Lint::Sets
10
-
11
- def test_smove
12
- r.sadd "foo", "s1"
13
- r.sadd "bar", "s2"
14
-
15
- assert r.smove("foo", "bar", "s1")
16
- assert r.sismember("bar", "s1")
17
- end
18
-
19
- def test_sinter
20
- r.sadd "foo", "s1"
21
- r.sadd "foo", "s2"
22
- r.sadd "bar", "s2"
23
-
24
- assert_equal ["s2"], r.sinter("foo", "bar")
25
- end
26
-
27
- def test_sinterstore
28
- r.sadd "foo", "s1"
29
- r.sadd "foo", "s2"
30
- r.sadd "bar", "s2"
31
-
32
- r.sinterstore("baz", "foo", "bar")
33
-
34
- assert_equal ["s2"], r.smembers("baz")
35
- end
36
-
37
- def test_sunion
38
- r.sadd "foo", "s1"
39
- r.sadd "foo", "s2"
40
- r.sadd "bar", "s2"
41
- r.sadd "bar", "s3"
42
-
43
- assert_equal ["s1", "s2", "s3"], r.sunion("foo", "bar").sort
44
- end
45
-
46
- def test_sunionstore
47
- r.sadd "foo", "s1"
48
- r.sadd "foo", "s2"
49
- r.sadd "bar", "s2"
50
- r.sadd "bar", "s3"
51
-
52
- r.sunionstore("baz", "foo", "bar")
53
-
54
- assert_equal ["s1", "s2", "s3"], r.smembers("baz").sort
55
- end
56
-
57
- def test_sdiff
58
- r.sadd "foo", "s1"
59
- r.sadd "foo", "s2"
60
- r.sadd "bar", "s2"
61
- r.sadd "bar", "s3"
62
-
63
- assert_equal ["s1"], r.sdiff("foo", "bar")
64
- assert_equal ["s3"], r.sdiff("bar", "foo")
65
- end
66
-
67
- def test_sdiffstore
68
- r.sadd "foo", "s1"
69
- r.sadd "foo", "s2"
70
- r.sadd "bar", "s2"
71
- r.sadd "bar", "s3"
72
-
73
- r.sdiffstore("baz", "foo", "bar")
74
-
75
- assert_equal ["s1"], r.smembers("baz")
76
- end
77
- end
@@ -1,137 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/sorted_sets"
5
-
6
- class TestCommandsOnSortedSets < Test::Unit::TestCase
7
-
8
- include Helper::Client
9
- include Lint::SortedSets
10
-
11
- def test_zrangebylex
12
- target_version "2.8.9" do
13
- r.zadd "foo", 0, "aaren"
14
- r.zadd "foo", 0, "abagael"
15
- r.zadd "foo", 0, "abby"
16
- r.zadd "foo", 0, "abbygail"
17
-
18
- assert_equal ["aaren", "abagael", "abby", "abbygail"], r.zrangebylex("foo", "[a", "[a\xff")
19
- assert_equal ["aaren", "abagael"], r.zrangebylex("foo", "[a", "[a\xff", :limit => [0, 2])
20
- assert_equal ["abby", "abbygail"], r.zrangebylex("foo", "(abb", "(abb\xff")
21
- assert_equal ["abbygail"], r.zrangebylex("foo", "(abby", "(abby\xff")
22
- end
23
- end
24
-
25
- def test_zrevrangebylex
26
- target_version "2.9.9" do
27
- r.zadd "foo", 0, "aaren"
28
- r.zadd "foo", 0, "abagael"
29
- r.zadd "foo", 0, "abby"
30
- r.zadd "foo", 0, "abbygail"
31
-
32
- assert_equal ["abbygail", "abby", "abagael", "aaren"], r.zrevrangebylex("foo", "[a\xff", "[a")
33
- assert_equal ["abbygail", "abby"], r.zrevrangebylex("foo", "[a\xff", "[a", :limit => [0, 2])
34
- assert_equal ["abbygail", "abby"], r.zrevrangebylex("foo", "(abb\xff", "(abb")
35
- assert_equal ["abbygail"], r.zrevrangebylex("foo", "(abby\xff", "(abby")
36
- end
37
- end
38
-
39
- def test_zcount
40
- r.zadd "foo", 1, "s1"
41
- r.zadd "foo", 2, "s2"
42
- r.zadd "foo", 3, "s3"
43
-
44
- assert_equal 2, r.zcount("foo", 2, 3)
45
- end
46
-
47
- def test_zunionstore
48
- r.zadd "foo", 1, "s1"
49
- r.zadd "bar", 2, "s2"
50
- r.zadd "foo", 3, "s3"
51
- r.zadd "bar", 4, "s4"
52
-
53
- assert_equal 4, r.zunionstore("foobar", ["foo", "bar"])
54
- assert_equal ["s1", "s2", "s3", "s4"], r.zrange("foobar", 0, -1)
55
- end
56
-
57
- def test_zunionstore_with_weights
58
- r.zadd "foo", 1, "s1"
59
- r.zadd "foo", 3, "s3"
60
- r.zadd "bar", 20, "s2"
61
- r.zadd "bar", 40, "s4"
62
-
63
- assert_equal 4, r.zunionstore("foobar", ["foo", "bar"])
64
- assert_equal ["s1", "s3", "s2", "s4"], r.zrange("foobar", 0, -1)
65
-
66
- assert_equal 4, r.zunionstore("foobar", ["foo", "bar"], :weights => [10, 1])
67
- assert_equal ["s1", "s2", "s3", "s4"], r.zrange("foobar", 0, -1)
68
- end
69
-
70
- def test_zunionstore_with_aggregate
71
- r.zadd "foo", 1, "s1"
72
- r.zadd "foo", 2, "s2"
73
- r.zadd "bar", 4, "s2"
74
- r.zadd "bar", 3, "s3"
75
-
76
- assert_equal 3, r.zunionstore("foobar", ["foo", "bar"])
77
- assert_equal ["s1", "s3", "s2"], r.zrange("foobar", 0, -1)
78
-
79
- assert_equal 3, r.zunionstore("foobar", ["foo", "bar"], :aggregate => :min)
80
- assert_equal ["s1", "s2", "s3"], r.zrange("foobar", 0, -1)
81
-
82
- assert_equal 3, r.zunionstore("foobar", ["foo", "bar"], :aggregate => :max)
83
- assert_equal ["s1", "s3", "s2"], r.zrange("foobar", 0, -1)
84
- end
85
-
86
- def test_zinterstore
87
- r.zadd "foo", 1, "s1"
88
- r.zadd "bar", 2, "s1"
89
- r.zadd "foo", 3, "s3"
90
- r.zadd "bar", 4, "s4"
91
-
92
- assert_equal 1, r.zinterstore("foobar", ["foo", "bar"])
93
- assert_equal ["s1"], r.zrange("foobar", 0, -1)
94
- end
95
-
96
- def test_zinterstore_with_weights
97
- r.zadd "foo", 1, "s1"
98
- r.zadd "foo", 2, "s2"
99
- r.zadd "foo", 3, "s3"
100
- r.zadd "bar", 20, "s2"
101
- r.zadd "bar", 30, "s3"
102
- r.zadd "bar", 40, "s4"
103
-
104
- assert_equal 2, r.zinterstore("foobar", ["foo", "bar"])
105
- assert_equal ["s2", "s3"], r.zrange("foobar", 0, -1)
106
-
107
- assert_equal 2, r.zinterstore("foobar", ["foo", "bar"], :weights => [10, 1])
108
- assert_equal ["s2", "s3"], r.zrange("foobar", 0, -1)
109
-
110
- assert_equal 40.0, r.zscore("foobar", "s2")
111
- assert_equal 60.0, r.zscore("foobar", "s3")
112
- end
113
-
114
- def test_zinterstore_with_aggregate
115
- r.zadd "foo", 1, "s1"
116
- r.zadd "foo", 2, "s2"
117
- r.zadd "foo", 3, "s3"
118
- r.zadd "bar", 20, "s2"
119
- r.zadd "bar", 30, "s3"
120
- r.zadd "bar", 40, "s4"
121
-
122
- assert_equal 2, r.zinterstore("foobar", ["foo", "bar"])
123
- assert_equal ["s2", "s3"], r.zrange("foobar", 0, -1)
124
- assert_equal 22.0, r.zscore("foobar", "s2")
125
- assert_equal 33.0, r.zscore("foobar", "s3")
126
-
127
- assert_equal 2, r.zinterstore("foobar", ["foo", "bar"], :aggregate => :min)
128
- assert_equal ["s2", "s3"], r.zrange("foobar", 0, -1)
129
- assert_equal 2.0, r.zscore("foobar", "s2")
130
- assert_equal 3.0, r.zscore("foobar", "s3")
131
-
132
- assert_equal 2, r.zinterstore("foobar", ["foo", "bar"], :aggregate => :max)
133
- assert_equal ["s2", "s3"], r.zrange("foobar", 0, -1)
134
- assert_equal 20.0, r.zscore("foobar", "s2")
135
- assert_equal 30.0, r.zscore("foobar", "s3")
136
- end
137
- end
@@ -1,101 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/strings"
5
-
6
- class TestCommandsOnStrings < Test::Unit::TestCase
7
-
8
- include Helper::Client
9
- include Lint::Strings
10
-
11
- def test_mget
12
- r.set("foo", "s1")
13
- r.set("bar", "s2")
14
-
15
- assert_equal ["s1", "s2"] , r.mget("foo", "bar")
16
- assert_equal ["s1", "s2", nil], r.mget("foo", "bar", "baz")
17
- end
18
-
19
- def test_mget_mapped
20
- r.set("foo", "s1")
21
- r.set("bar", "s2")
22
-
23
- response = r.mapped_mget("foo", "bar")
24
-
25
- assert_equal "s1", response["foo"]
26
- assert_equal "s2", response["bar"]
27
-
28
- response = r.mapped_mget("foo", "bar", "baz")
29
-
30
- assert_equal "s1", response["foo"]
31
- assert_equal "s2", response["bar"]
32
- assert_equal nil , response["baz"]
33
- end
34
-
35
- def test_mapped_mget_in_a_pipeline_returns_hash
36
- r.set("foo", "s1")
37
- r.set("bar", "s2")
38
-
39
- result = r.pipelined do
40
- r.mapped_mget("foo", "bar")
41
- end
42
-
43
- assert_equal result[0], { "foo" => "s1", "bar" => "s2" }
44
- end
45
-
46
- def test_mset
47
- r.mset(:foo, "s1", :bar, "s2")
48
-
49
- assert_equal "s1", r.get("foo")
50
- assert_equal "s2", r.get("bar")
51
- end
52
-
53
- def test_mset_mapped
54
- r.mapped_mset(:foo => "s1", :bar => "s2")
55
-
56
- assert_equal "s1", r.get("foo")
57
- assert_equal "s2", r.get("bar")
58
- end
59
-
60
- def test_msetnx
61
- r.set("foo", "s1")
62
- assert_equal false, r.msetnx(:foo, "s2", :bar, "s3")
63
- assert_equal "s1", r.get("foo")
64
- assert_equal nil, r.get("bar")
65
-
66
- r.del("foo")
67
- assert_equal true, r.msetnx(:foo, "s2", :bar, "s3")
68
- assert_equal "s2", r.get("foo")
69
- assert_equal "s3", r.get("bar")
70
- end
71
-
72
- def test_msetnx_mapped
73
- r.set("foo", "s1")
74
- assert_equal false, r.mapped_msetnx(:foo => "s2", :bar => "s3")
75
- assert_equal "s1", r.get("foo")
76
- assert_equal nil, r.get("bar")
77
-
78
- r.del("foo")
79
- assert_equal true, r.mapped_msetnx(:foo => "s2", :bar => "s3")
80
- assert_equal "s2", r.get("foo")
81
- assert_equal "s3", r.get("bar")
82
- end
83
-
84
- def test_bitop
85
- try_encoding("UTF-8") do
86
- target_version "2.5.10" do
87
- r.set("foo", "a")
88
- r.set("bar", "b")
89
-
90
- r.bitop(:and, "foo&bar", "foo", "bar")
91
- assert_equal "\x60", r.get("foo&bar")
92
- r.bitop(:or, "foo|bar", "foo", "bar")
93
- assert_equal "\x63", r.get("foo|bar")
94
- r.bitop(:xor, "foo^bar", "foo", "bar")
95
- assert_equal "\x03", r.get("foo^bar")
96
- r.bitop(:not, "~foo", "foo")
97
- assert_equal "\x9E", r.get("~foo")
98
- end
99
- end
100
- end
101
- end
@@ -1,133 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/value_types"
5
-
6
- class TestCommandsOnValueTypes < Test::Unit::TestCase
7
-
8
- include Helper::Client
9
- include Lint::ValueTypes
10
-
11
- def test_del
12
- r.set "foo", "s1"
13
- r.set "bar", "s2"
14
- r.set "baz", "s3"
15
-
16
- assert_equal ["bar", "baz", "foo"], r.keys("*").sort
17
-
18
- assert_equal 1, r.del("foo")
19
-
20
- assert_equal ["bar", "baz"], r.keys("*").sort
21
-
22
- assert_equal 2, r.del("bar", "baz")
23
-
24
- assert_equal [], r.keys("*").sort
25
- end
26
-
27
- def test_del_with_array_argument
28
- r.set "foo", "s1"
29
- r.set "bar", "s2"
30
- r.set "baz", "s3"
31
-
32
- assert_equal ["bar", "baz", "foo"], r.keys("*").sort
33
-
34
- assert_equal 1, r.del(["foo"])
35
-
36
- assert_equal ["bar", "baz"], r.keys("*").sort
37
-
38
- assert_equal 2, r.del(["bar", "baz"])
39
-
40
- assert_equal [], r.keys("*").sort
41
- end
42
-
43
- def test_randomkey
44
- assert r.randomkey.to_s.empty?
45
-
46
- r.set("foo", "s1")
47
-
48
- assert_equal "foo", r.randomkey
49
-
50
- r.set("bar", "s2")
51
-
52
- 4.times do
53
- assert ["foo", "bar"].include?(r.randomkey)
54
- end
55
- end
56
-
57
- def test_rename
58
- r.set("foo", "s1")
59
- r.rename "foo", "bar"
60
-
61
- assert_equal "s1", r.get("bar")
62
- assert_equal nil, r.get("foo")
63
- end
64
-
65
- def test_renamenx
66
- r.set("foo", "s1")
67
- r.set("bar", "s2")
68
-
69
- assert_equal false, r.renamenx("foo", "bar")
70
-
71
- assert_equal "s1", r.get("foo")
72
- assert_equal "s2", r.get("bar")
73
- end
74
-
75
- def test_dbsize
76
- assert_equal 0, r.dbsize
77
-
78
- r.set("foo", "s1")
79
-
80
- assert_equal 1, r.dbsize
81
- end
82
-
83
- def test_flushdb
84
- r.set("foo", "s1")
85
- r.set("bar", "s2")
86
-
87
- assert_equal 2, r.dbsize
88
-
89
- r.flushdb
90
-
91
- assert_equal 0, r.dbsize
92
- end
93
-
94
- def test_flushall
95
- redis_mock(:flushall => lambda { "+FLUSHALL" }) do |redis|
96
- assert_equal "FLUSHALL", redis.flushall
97
- end
98
- end
99
-
100
- def test_migrate
101
- redis_mock(:migrate => lambda { |*args| args }) do |redis|
102
- options = { :host => "127.0.0.1", :port => 1234 }
103
-
104
- ex = assert_raise(RuntimeError) do
105
- redis.migrate("foo", options.reject { |key, _| key == :host })
106
- end
107
- assert ex.message =~ /host not specified/
108
-
109
- ex = assert_raise(RuntimeError) do
110
- redis.migrate("foo", options.reject { |key, _| key == :port })
111
- end
112
- assert ex.message =~ /port not specified/
113
-
114
- default_db = redis.client.db.to_i
115
- default_timeout = redis.client.timeout.to_i
116
-
117
- # Test defaults
118
- actual = redis.migrate("foo", options)
119
- expected = ["127.0.0.1", "1234", "foo", default_db.to_s, default_timeout.to_s]
120
- assert_equal expected, actual
121
-
122
- # Test db override
123
- actual = redis.migrate("foo", options.merge(:db => default_db + 1))
124
- expected = ["127.0.0.1", "1234", "foo", (default_db + 1).to_s, default_timeout.to_s]
125
- assert_equal expected, actual
126
-
127
- # Test timeout override
128
- actual = redis.migrate("foo", options.merge(:timeout => default_timeout + 1))
129
- expected = ["127.0.0.1", "1234", "foo", default_db.to_s, (default_timeout + 1).to_s]
130
- assert_equal expected, actual
131
- end
132
- end
133
- end