redis 4.1.0.beta1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -2
- data/README.md +45 -0
- data/lib/redis.rb +497 -20
- data/lib/redis/client.rb +14 -6
- data/lib/redis/cluster.rb +1 -0
- data/lib/redis/cluster/command_loader.rb +2 -0
- data/lib/redis/cluster/node_loader.rb +2 -0
- data/lib/redis/cluster/option.rb +1 -0
- data/lib/redis/cluster/slot_loader.rb +2 -0
- data/lib/redis/distributed.rb +3 -4
- data/lib/redis/version.rb +1 -1
- metadata +20 -243
- data/.gitignore +0 -19
- data/.travis.yml +0 -61
- data/.travis/Gemfile +0 -18
- data/.yardopts +0 -3
- data/Gemfile +0 -8
- data/benchmarking/logging.rb +0 -71
- data/benchmarking/pipeline.rb +0 -51
- data/benchmarking/speed.rb +0 -21
- data/benchmarking/suite.rb +0 -24
- data/benchmarking/worker.rb +0 -71
- data/bin/build +0 -71
- data/bors.toml +0 -14
- data/examples/basic.rb +0 -15
- data/examples/consistency.rb +0 -114
- data/examples/dist_redis.rb +0 -43
- data/examples/incr-decr.rb +0 -17
- data/examples/list.rb +0 -26
- data/examples/pubsub.rb +0 -37
- data/examples/sentinel.rb +0 -41
- data/examples/sentinel/start +0 -49
- data/examples/sets.rb +0 -36
- data/examples/unicorn/config.ru +0 -3
- data/examples/unicorn/unicorn.rb +0 -20
- data/makefile +0 -74
- data/redis.gemspec +0 -42
- data/test/bitpos_test.rb +0 -63
- data/test/blocking_commands_test.rb +0 -40
- data/test/client_test.rb +0 -76
- data/test/cluster_abnormal_state_test.rb +0 -38
- data/test/cluster_blocking_commands_test.rb +0 -15
- data/test/cluster_client_internals_test.rb +0 -77
- data/test/cluster_client_key_hash_tags_test.rb +0 -88
- data/test/cluster_client_options_test.rb +0 -147
- data/test/cluster_client_pipelining_test.rb +0 -59
- data/test/cluster_client_replicas_test.rb +0 -36
- data/test/cluster_client_slots_test.rb +0 -94
- data/test/cluster_client_transactions_test.rb +0 -71
- data/test/cluster_commands_on_cluster_test.rb +0 -165
- data/test/cluster_commands_on_connection_test.rb +0 -40
- data/test/cluster_commands_on_geo_test.rb +0 -74
- data/test/cluster_commands_on_hashes_test.rb +0 -11
- data/test/cluster_commands_on_hyper_log_log_test.rb +0 -17
- data/test/cluster_commands_on_keys_test.rb +0 -134
- data/test/cluster_commands_on_lists_test.rb +0 -15
- data/test/cluster_commands_on_pub_sub_test.rb +0 -101
- data/test/cluster_commands_on_scripting_test.rb +0 -56
- data/test/cluster_commands_on_server_test.rb +0 -221
- data/test/cluster_commands_on_sets_test.rb +0 -39
- data/test/cluster_commands_on_sorted_sets_test.rb +0 -35
- data/test/cluster_commands_on_streams_test.rb +0 -196
- data/test/cluster_commands_on_strings_test.rb +0 -15
- data/test/cluster_commands_on_transactions_test.rb +0 -41
- data/test/cluster_commands_on_value_types_test.rb +0 -14
- data/test/command_map_test.rb +0 -28
- data/test/commands_on_geo_test.rb +0 -116
- data/test/commands_on_hashes_test.rb +0 -7
- data/test/commands_on_hyper_log_log_test.rb +0 -7
- data/test/commands_on_lists_test.rb +0 -7
- data/test/commands_on_sets_test.rb +0 -7
- data/test/commands_on_sorted_sets_test.rb +0 -7
- data/test/commands_on_strings_test.rb +0 -7
- data/test/commands_on_value_types_test.rb +0 -207
- data/test/connection_handling_test.rb +0 -275
- data/test/connection_test.rb +0 -57
- data/test/distributed_blocking_commands_test.rb +0 -52
- data/test/distributed_commands_on_hashes_test.rb +0 -21
- data/test/distributed_commands_on_hyper_log_log_test.rb +0 -26
- data/test/distributed_commands_on_lists_test.rb +0 -19
- data/test/distributed_commands_on_sets_test.rb +0 -105
- data/test/distributed_commands_on_sorted_sets_test.rb +0 -59
- data/test/distributed_commands_on_strings_test.rb +0 -79
- data/test/distributed_commands_on_value_types_test.rb +0 -129
- data/test/distributed_commands_requiring_clustering_test.rb +0 -162
- data/test/distributed_connection_handling_test.rb +0 -21
- data/test/distributed_internals_test.rb +0 -68
- data/test/distributed_key_tags_test.rb +0 -50
- data/test/distributed_persistence_control_commands_test.rb +0 -24
- data/test/distributed_publish_subscribe_test.rb +0 -90
- data/test/distributed_remote_server_control_commands_test.rb +0 -64
- data/test/distributed_scripting_test.rb +0 -100
- data/test/distributed_sorting_test.rb +0 -18
- data/test/distributed_test.rb +0 -56
- data/test/distributed_transactions_test.rb +0 -30
- data/test/encoding_test.rb +0 -14
- data/test/error_replies_test.rb +0 -57
- data/test/fork_safety_test.rb +0 -60
- data/test/helper.rb +0 -344
- data/test/helper_test.rb +0 -22
- data/test/internals_test.rb +0 -395
- data/test/lint/blocking_commands.rb +0 -174
- data/test/lint/hashes.rb +0 -203
- data/test/lint/hyper_log_log.rb +0 -74
- data/test/lint/lists.rb +0 -159
- data/test/lint/sets.rb +0 -282
- data/test/lint/sorted_sets.rb +0 -497
- data/test/lint/strings.rb +0 -348
- data/test/lint/value_types.rb +0 -130
- data/test/persistence_control_commands_test.rb +0 -24
- data/test/pipelining_commands_test.rb +0 -246
- data/test/publish_subscribe_test.rb +0 -280
- data/test/remote_server_control_commands_test.rb +0 -175
- data/test/scanning_test.rb +0 -407
- data/test/scripting_test.rb +0 -76
- data/test/sentinel_command_test.rb +0 -78
- data/test/sentinel_test.rb +0 -253
- data/test/sorting_test.rb +0 -57
- data/test/ssl_test.rb +0 -69
- data/test/support/cluster/orchestrator.rb +0 -199
- data/test/support/connection/hiredis.rb +0 -1
- data/test/support/connection/ruby.rb +0 -1
- data/test/support/connection/synchrony.rb +0 -17
- data/test/support/redis_mock.rb +0 -130
- data/test/support/ssl/gen_certs.sh +0 -31
- data/test/support/ssl/trusted-ca.crt +0 -25
- data/test/support/ssl/trusted-ca.key +0 -27
- data/test/support/ssl/trusted-cert.crt +0 -81
- data/test/support/ssl/trusted-cert.key +0 -28
- data/test/support/ssl/untrusted-ca.crt +0 -26
- data/test/support/ssl/untrusted-ca.key +0 -27
- data/test/support/ssl/untrusted-cert.crt +0 -82
- data/test/support/ssl/untrusted-cert.key +0 -28
- data/test/support/wire/synchrony.rb +0 -24
- data/test/support/wire/thread.rb +0 -5
- data/test/synchrony_driver.rb +0 -85
- data/test/test.conf.erb +0 -9
- data/test/thread_safety_test.rb +0 -60
- data/test/transactions_test.rb +0 -272
- data/test/unknown_commands_test.rb +0 -12
- data/test/url_param_test.rb +0 -136
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
require_relative 'lint/sets'
|
5
|
-
|
6
|
-
# ruby -w -Itest test/cluster_commands_on_sets_test.rb
|
7
|
-
# @see https://redis.io/commands#set
|
8
|
-
class TestClusterCommandsOnSets < Test::Unit::TestCase
|
9
|
-
include Helper::Cluster
|
10
|
-
include Lint::Sets
|
11
|
-
|
12
|
-
def test_sdiff
|
13
|
-
assert_raise(Redis::CommandError) { super }
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_sdiffstore
|
17
|
-
assert_raise(Redis::CommandError) { super }
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_sinter
|
21
|
-
assert_raise(Redis::CommandError) { super }
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_sinterstore
|
25
|
-
assert_raise(Redis::CommandError) { super }
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_smove
|
29
|
-
assert_raise(Redis::CommandError) { super }
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_sunion
|
33
|
-
assert_raise(Redis::CommandError) { super }
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_sunionstore
|
37
|
-
assert_raise(Redis::CommandError) { super }
|
38
|
-
end
|
39
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
require_relative 'lint/sorted_sets'
|
5
|
-
|
6
|
-
# ruby -w -Itest test/cluster_commands_on_sorted_sets_test.rb
|
7
|
-
# @see https://redis.io/commands#sorted_set
|
8
|
-
class TestClusterCommandsOnSortedSets < Test::Unit::TestCase
|
9
|
-
include Helper::Cluster
|
10
|
-
include Lint::SortedSets
|
11
|
-
|
12
|
-
def test_zinterstore
|
13
|
-
assert_raise(Redis::CommandError) { super }
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_zinterstore_with_aggregate
|
17
|
-
assert_raise(Redis::CommandError) { super }
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_zinterstore_with_weights
|
21
|
-
assert_raise(Redis::CommandError) { super }
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_zunionstore
|
25
|
-
assert_raise(Redis::CommandError) { super }
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_zunionstore_with_aggregate
|
29
|
-
assert_raise(Redis::CommandError) { super }
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_zunionstore_with_weights
|
33
|
-
assert_raise(Redis::CommandError) { super }
|
34
|
-
end
|
35
|
-
end
|
@@ -1,196 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
|
5
|
-
# ruby -w -Itest test/cluster_commands_on_streams_test.rb
|
6
|
-
# @see https://redis.io/commands#stream
|
7
|
-
class TestClusterCommandsOnStreams < Test::Unit::TestCase
|
8
|
-
include Helper::Cluster
|
9
|
-
|
10
|
-
MIN_REDIS_VERSION = '4.9.0'
|
11
|
-
ENTRY_ID_FORMAT = /\d+-\d+/
|
12
|
-
|
13
|
-
def setup
|
14
|
-
super
|
15
|
-
add_some_entries_to_streams_without_hashtag
|
16
|
-
add_some_entries_to_streams_with_hashtag
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_some_entries_to_streams_without_hashtag
|
20
|
-
target_version(MIN_REDIS_VERSION) do
|
21
|
-
redis.xadd('stream1', '*', 'name', 'John', 'surname', 'Connor')
|
22
|
-
redis.xadd('stream1', '*', 'name', 'Sarah', 'surname', 'Connor')
|
23
|
-
redis.xadd('stream1', '*', 'name', 'Miles', 'surname', 'Dyson')
|
24
|
-
redis.xadd('stream1', '*', 'name', 'Peter', 'surname', 'Silberman')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def add_some_entries_to_streams_with_hashtag
|
29
|
-
target_version(MIN_REDIS_VERSION) do
|
30
|
-
redis.xadd('{stream}1', '*', 'name', 'John', 'surname', 'Connor')
|
31
|
-
redis.xadd('{stream}1', '*', 'name', 'Sarah', 'surname', 'Connor')
|
32
|
-
redis.xadd('{stream}1', '*', 'name', 'Miles', 'surname', 'Dyson')
|
33
|
-
redis.xadd('{stream}1', '*', 'name', 'Peter', 'surname', 'Silberman')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def assert_stream_entry(actual, expected_name, expected_surname)
|
38
|
-
actual_key = actual.keys.first
|
39
|
-
actual_values = actual[actual_key]
|
40
|
-
|
41
|
-
assert_match ENTRY_ID_FORMAT, actual_key
|
42
|
-
assert_equal expected_name, actual_values['name']
|
43
|
-
assert_equal expected_surname, actual_values['surname']
|
44
|
-
end
|
45
|
-
|
46
|
-
def assert_stream_pending(actual, expected_size_of_group, expected_consumer_name, expected_size_of_consumer)
|
47
|
-
assert_equal expected_size_of_group, actual[:size]
|
48
|
-
assert_match ENTRY_ID_FORMAT, actual[:min_entry_id]
|
49
|
-
assert_match ENTRY_ID_FORMAT, actual[:max_entry_id]
|
50
|
-
assert_equal({ expected_consumer_name => expected_size_of_consumer }, actual[:consumers])
|
51
|
-
end
|
52
|
-
|
53
|
-
# TODO: Remove this helper method when we implement streams interfaces
|
54
|
-
def hashify_stream_entries(reply)
|
55
|
-
reply.map do |entry_id, values|
|
56
|
-
[entry_id, Hash[values.each_slice(2).to_a]]
|
57
|
-
end.to_h
|
58
|
-
end
|
59
|
-
|
60
|
-
# TODO: Remove this helper method when we implement streams interfaces
|
61
|
-
def hashify_streams(reply)
|
62
|
-
reply.map do |stream_key, entries|
|
63
|
-
[stream_key, hashify_stream_entries(entries)]
|
64
|
-
end.to_h
|
65
|
-
end
|
66
|
-
|
67
|
-
# TODO: Remove this helper method when we implement streams interfaces
|
68
|
-
def hashify_stream_pendings(reply)
|
69
|
-
{
|
70
|
-
size: reply.first,
|
71
|
-
min_entry_id: reply[1],
|
72
|
-
max_entry_id: reply[2],
|
73
|
-
consumers: Hash[reply[3]]
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_xadd
|
78
|
-
target_version(MIN_REDIS_VERSION) do
|
79
|
-
assert_match ENTRY_ID_FORMAT, redis.xadd('mystream', '*', 'type', 'T-800', 'model', '101')
|
80
|
-
assert_match ENTRY_ID_FORMAT, redis.xadd('my{stream}', '*', 'type', 'T-1000')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_xrange
|
85
|
-
target_version(MIN_REDIS_VERSION) do
|
86
|
-
actual = redis.xrange('stream1', '-', '+', 'COUNT', 1)
|
87
|
-
actual = hashify_stream_entries(actual) # TODO: Remove this step when we implement streams interfaces
|
88
|
-
assert_stream_entry(actual, 'John', 'Connor')
|
89
|
-
|
90
|
-
actual = redis.xrange('{stream}1', '-', '+', 'COUNT', 1)
|
91
|
-
actual = hashify_stream_entries(actual) # TODO: Remove this step when we implement streams interfaces
|
92
|
-
assert_stream_entry(actual, 'John', 'Connor')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_xrevrange
|
97
|
-
target_version(MIN_REDIS_VERSION) do
|
98
|
-
actual = redis.xrevrange('stream1', '+', '-', 'COUNT', 1)
|
99
|
-
actual = hashify_stream_entries(actual) # TODO: Remove this step when we implement streams interfaces
|
100
|
-
assert_stream_entry(actual, 'Peter', 'Silberman')
|
101
|
-
|
102
|
-
actual = redis.xrevrange('{stream}1', '+', '-', 'COUNT', 1)
|
103
|
-
actual = hashify_stream_entries(actual) # TODO: Remove this step when we implement streams interfaces
|
104
|
-
assert_stream_entry(actual, 'Peter', 'Silberman')
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_xlen
|
109
|
-
target_version(MIN_REDIS_VERSION) do
|
110
|
-
assert_equal 4, redis.xlen('stream1')
|
111
|
-
assert_equal 4, redis.xlen('{stream}1')
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_xread
|
116
|
-
target_version(MIN_REDIS_VERSION) do
|
117
|
-
# non blocking without hashtag
|
118
|
-
actual = redis.xread('COUNT', 1, 'STREAMS', 'stream1', 0)
|
119
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
120
|
-
assert_equal 'stream1', actual.keys.first
|
121
|
-
assert_stream_entry(actual['stream1'], 'John', 'Connor')
|
122
|
-
|
123
|
-
# blocking without hashtag
|
124
|
-
actual = redis.xread('COUNT', 1, 'BLOCK', 1, 'STREAMS', 'stream1', 0)
|
125
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
126
|
-
assert_equal 'stream1', actual.keys.first
|
127
|
-
assert_stream_entry(actual['stream1'], 'John', 'Connor')
|
128
|
-
|
129
|
-
# non blocking with hashtag
|
130
|
-
actual = redis.xread('COUNT', 1, 'STREAMS', '{stream}1', 0)
|
131
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
132
|
-
assert_equal '{stream}1', actual.keys.first
|
133
|
-
assert_stream_entry(actual['{stream}1'], 'John', 'Connor')
|
134
|
-
|
135
|
-
# blocking with hashtag
|
136
|
-
actual = redis.xread('COUNT', 1, 'BLOCK', 1, 'STREAMS', '{stream}1', 0)
|
137
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
138
|
-
assert_equal '{stream}1', actual.keys.first
|
139
|
-
assert_stream_entry(actual['{stream}1'], 'John', 'Connor')
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_xreadgroup
|
144
|
-
target_version(MIN_REDIS_VERSION) do
|
145
|
-
# non blocking without hashtag
|
146
|
-
redis.xgroup('create', 'stream1', 'mygroup1', '$')
|
147
|
-
add_some_entries_to_streams_without_hashtag
|
148
|
-
actual = redis.xreadgroup('GROUP', 'mygroup1', 'T-1000', 'COUNT', 1, 'STREAMS', 'stream1', '>')
|
149
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
150
|
-
assert_equal 'stream1', actual.keys.first
|
151
|
-
assert_stream_entry(actual['stream1'], 'John', 'Connor')
|
152
|
-
|
153
|
-
# blocking without hashtag
|
154
|
-
redis.xgroup('create', 'stream1', 'mygroup2', '$')
|
155
|
-
add_some_entries_to_streams_without_hashtag
|
156
|
-
actual = redis.xreadgroup('GROUP', 'mygroup2', 'T-800', 'COUNT', 1, 'BLOCK', 1, 'STREAMS', 'stream1', '>')
|
157
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
158
|
-
assert_equal 'stream1', actual.keys.first
|
159
|
-
assert_stream_entry(actual['stream1'], 'John', 'Connor')
|
160
|
-
|
161
|
-
# non blocking with hashtag
|
162
|
-
redis.xgroup('create', '{stream}1', 'mygroup3', '$')
|
163
|
-
add_some_entries_to_streams_with_hashtag
|
164
|
-
actual = redis.xreadgroup('GROUP', 'mygroup3', 'T-1000', 'COUNT', 1, 'STREAMS', '{stream}1', '>')
|
165
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
166
|
-
assert_equal '{stream}1', actual.keys.first
|
167
|
-
assert_stream_entry(actual['{stream}1'], 'John', 'Connor')
|
168
|
-
|
169
|
-
# blocking with hashtag
|
170
|
-
redis.xgroup('create', '{stream}1', 'mygroup4', '$')
|
171
|
-
add_some_entries_to_streams_with_hashtag
|
172
|
-
actual = redis.xreadgroup('GROUP', 'mygroup4', 'T-800', 'COUNT', 1, 'BLOCK', 1, 'STREAMS', '{stream}1', '>')
|
173
|
-
actual = hashify_streams(actual) # TODO: Remove this step when we implement streams interfaces
|
174
|
-
assert_equal '{stream}1', actual.keys.first
|
175
|
-
assert_stream_entry(actual['{stream}1'], 'John', 'Connor')
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_xpending
|
180
|
-
target_version(MIN_REDIS_VERSION) do
|
181
|
-
redis.xgroup('create', 'stream1', 'mygroup1', '$')
|
182
|
-
add_some_entries_to_streams_without_hashtag
|
183
|
-
redis.xreadgroup('GROUP', 'mygroup1', 'T-800', 'COUNT', 1, 'STREAMS', 'stream1', '>')
|
184
|
-
actual = redis.xpending('stream1', 'mygroup1')
|
185
|
-
actual = hashify_stream_pendings(actual) # TODO: Remove this step when we implement streams interfaces
|
186
|
-
assert_stream_pending(actual, 1, 'T-800', '1')
|
187
|
-
|
188
|
-
redis.xgroup('create', '{stream}1', 'mygroup2', '$')
|
189
|
-
add_some_entries_to_streams_with_hashtag
|
190
|
-
redis.xreadgroup('GROUP', 'mygroup2', 'T-800', 'COUNT', 1, 'STREAMS', '{stream}1', '>')
|
191
|
-
actual = redis.xpending('{stream}1', 'mygroup2')
|
192
|
-
actual = hashify_stream_pendings(actual) # TODO: Remove this step when we implement streams interfaces
|
193
|
-
assert_stream_pending(actual, 1, 'T-800', '1')
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
require_relative 'lint/strings'
|
5
|
-
|
6
|
-
# ruby -w -Itest test/cluster_commands_on_strings_test.rb
|
7
|
-
# @see https://redis.io/commands#string
|
8
|
-
class TestClusterCommandsOnStrings < Test::Unit::TestCase
|
9
|
-
include Helper::Cluster
|
10
|
-
include Lint::Strings
|
11
|
-
|
12
|
-
def mock(*args, &block)
|
13
|
-
redis_cluster_mock(*args, &block)
|
14
|
-
end
|
15
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
|
5
|
-
# ruby -w -Itest test/cluster_commands_on_transactions_test.rb
|
6
|
-
# @see https://redis.io/commands#transactions
|
7
|
-
class TestClusterCommandsOnTransactions < Test::Unit::TestCase
|
8
|
-
include Helper::Cluster
|
9
|
-
|
10
|
-
def test_discard
|
11
|
-
assert_raise(Redis::Cluster::AmbiguousNodeError) do
|
12
|
-
redis.discard
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_exec
|
17
|
-
assert_raise(Redis::Cluster::AmbiguousNodeError) do
|
18
|
-
redis.exec
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_multi
|
23
|
-
assert_raise(Redis::Cluster::AmbiguousNodeError) do
|
24
|
-
redis.multi
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_unwatch
|
29
|
-
assert_raise(Redis::Cluster::AmbiguousNodeError) do
|
30
|
-
redis.unwatch
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_watch
|
35
|
-
assert_raise(Redis::CommandError, "CROSSSLOT Keys in request don't hash to the same slot") do
|
36
|
-
redis.watch('key1', 'key2')
|
37
|
-
end
|
38
|
-
|
39
|
-
assert_equal 'OK', redis.watch('{key}1', '{key}2')
|
40
|
-
end
|
41
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'helper'
|
4
|
-
require_relative 'lint/value_types'
|
5
|
-
|
6
|
-
# ruby -w -Itest test/cluster_commands_on_value_types_test.rb
|
7
|
-
class TestClusterCommandsOnValueTypes < Test::Unit::TestCase
|
8
|
-
include Helper::Cluster
|
9
|
-
include Lint::ValueTypes
|
10
|
-
|
11
|
-
def test_move
|
12
|
-
assert_raise(Redis::CommandError) { super }
|
13
|
-
end
|
14
|
-
end
|
data/test/command_map_test.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require_relative "helper"
|
2
|
-
|
3
|
-
class TestCommandMap < Test::Unit::TestCase
|
4
|
-
|
5
|
-
include Helper::Client
|
6
|
-
|
7
|
-
def test_override_existing_commands
|
8
|
-
r.set("counter", 1)
|
9
|
-
|
10
|
-
assert_equal 2, r.incr("counter")
|
11
|
-
|
12
|
-
r._client.command_map[:incr] = :decr
|
13
|
-
|
14
|
-
assert_equal 1, r.incr("counter")
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_override_non_existing_commands
|
18
|
-
r.set("key", "value")
|
19
|
-
|
20
|
-
assert_raise Redis::CommandError do
|
21
|
-
r.idontexist("key")
|
22
|
-
end
|
23
|
-
|
24
|
-
r._client.command_map[:idontexist] = :get
|
25
|
-
|
26
|
-
assert_equal "value", r.idontexist("key")
|
27
|
-
end
|
28
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require_relative "helper"
|
2
|
-
|
3
|
-
class TestCommandsGeo < Test::Unit::TestCase
|
4
|
-
include Helper::Client
|
5
|
-
|
6
|
-
def setup
|
7
|
-
super
|
8
|
-
|
9
|
-
target_version "3.2.0" do
|
10
|
-
added_items_count = r.geoadd("Sicily", 13.361389, 38.115556, "Palermo", 15.087269, 37.502669, "Catania")
|
11
|
-
assert_equal 2, added_items_count
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_georadius_with_sort
|
16
|
-
target_version "3.2.0" do
|
17
|
-
nearest_cities = r.georadius("Sicily", 15, 37, 200, 'km', sort: 'asc')
|
18
|
-
assert_equal %w(Catania Palermo), nearest_cities
|
19
|
-
|
20
|
-
farthest_cities = r.georadius("Sicily", 15, 37, 200, 'km', sort: 'desc')
|
21
|
-
assert_equal %w(Palermo Catania), farthest_cities
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_georadius_with_count
|
26
|
-
target_version "3.2.0" do
|
27
|
-
city = r.georadius("Sicily", 15, 37, 200, 'km', count: 1)
|
28
|
-
assert_equal %w(Catania), city
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_georadius_with_options_count_sort
|
33
|
-
target_version "3.2.0" do
|
34
|
-
city = r.georadius("Sicily", 15, 37, 200, 'km', sort: :desc, options: :WITHDIST, count: 1)
|
35
|
-
assert_equal [["Palermo", "190.4424"]], city
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_georadiusbymember_with_sort
|
40
|
-
target_version "3.2.0" do
|
41
|
-
nearest_cities = r.georadiusbymember("Sicily", "Catania", 200, 'km', sort: 'asc')
|
42
|
-
assert_equal %w(Catania Palermo), nearest_cities
|
43
|
-
|
44
|
-
farthest_cities = r.georadiusbymember("Sicily", "Catania", 200, 'km', sort: 'desc')
|
45
|
-
assert_equal %w(Palermo Catania), farthest_cities
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_georadiusbymember_with_count
|
50
|
-
target_version "3.2.0" do
|
51
|
-
city = r.georadiusbymember("Sicily", "Catania", 200, 'km', count: 1)
|
52
|
-
assert_equal %w(Catania), city
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_georadiusbymember_with_options_count_sort
|
57
|
-
target_version "3.2.0" do
|
58
|
-
city = r.georadiusbymember("Sicily", "Catania", 200, 'km', sort: :desc, options: :WITHDIST, count: 1)
|
59
|
-
assert_equal [["Palermo", "166.2742"]], city
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_geopos
|
64
|
-
target_version "3.2.0" do
|
65
|
-
location = r.geopos("Sicily", "Catania")
|
66
|
-
assert_equal [["15.08726745843887329", "37.50266842333162032"]], location
|
67
|
-
|
68
|
-
locations = r.geopos("Sicily", ["Palermo", "Catania"])
|
69
|
-
assert_equal [["13.36138933897018433", "38.11555639549629859"], ["15.08726745843887329", "37.50266842333162032"]], locations
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_geopos_nonexistant_location
|
74
|
-
target_version "3.2.0" do
|
75
|
-
location = r.geopos("Sicily", "Rome")
|
76
|
-
assert_equal [nil], location
|
77
|
-
|
78
|
-
locations = r.geopos("Sicily", ["Rome", "Catania"])
|
79
|
-
assert_equal [nil, ["15.08726745843887329", "37.50266842333162032"]], locations
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_geodist
|
84
|
-
target_version "3.2.0" do
|
85
|
-
distination_in_meters = r.geodist("Sicily", "Palermo", "Catania")
|
86
|
-
assert_equal "166274.1516", distination_in_meters
|
87
|
-
|
88
|
-
distination_in_feet = r.geodist("Sicily", "Palermo", "Catania", 'ft')
|
89
|
-
assert_equal "545518.8700", distination_in_feet
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_geodist_with_nonexistant_location
|
94
|
-
target_version "3.2.0" do
|
95
|
-
distination = r.geodist("Sicily", "Palermo", "Rome")
|
96
|
-
assert_equal nil, distination
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_geohash
|
101
|
-
target_version "3.2.0" do
|
102
|
-
geohash = r.geohash("Sicily", "Palermo")
|
103
|
-
assert_equal ["sqc8b49rny0"], geohash
|
104
|
-
|
105
|
-
geohashes = r.geohash("Sicily", ["Palermo", "Catania"])
|
106
|
-
assert_equal %w(sqc8b49rny0 sqdtr74hyu0), geohashes
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_geohash_with_nonexistant_location
|
111
|
-
target_version "3.2.0" do
|
112
|
-
geohashes = r.geohash("Sicily", ["Palermo", "Rome"])
|
113
|
-
assert_equal ["sqc8b49rny0", nil], geohashes
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|