Skip to content

Commit 221fa47

Browse files
committed
Assume Redis 5+
Even 5.0 is EOL, and it's the oldest version we test against, so no point keeping all these version checks.
1 parent fba954d commit 221fa47

28 files changed

+834
-1122
lines changed

test/cluster/client_key_hash_tags_test.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ def test_whether_the_command_effect_is_readonly_or_not
8888
assert_equal false, described_class.should_send_to_master?([:get])
8989
assert_equal true, described_class.should_send_to_slave?([:get])
9090

91-
target_version('3.2.0') do
92-
assert_equal false, described_class.should_send_to_master?([:info])
93-
assert_equal false, described_class.should_send_to_slave?([:info])
94-
end
91+
assert_equal false, described_class.should_send_to_master?([:info])
92+
assert_equal false, described_class.should_send_to_slave?([:info])
9593
end
9694

9795
def test_cannot_build_details_from_bad_urls

test/cluster/commands_on_geo_test.rb

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,54 @@
77
class TestClusterCommandsOnGeo < Minitest::Test
88
include Helper::Cluster
99

10-
MIN_REDIS_VERSION = '3.2.0'
11-
1210
def add_sicily
1311
redis.geoadd('Sicily',
1412
13.361389, 38.115556, 'Palermo',
1513
15.087269, 37.502669, 'Catania')
1614
end
1715

1816
def test_geoadd
19-
target_version(MIN_REDIS_VERSION) do
20-
assert_equal 2, add_sicily
21-
end
17+
assert_equal 2, add_sicily
2218
end
2319

2420
def test_geohash
25-
target_version(MIN_REDIS_VERSION) do
26-
add_sicily
27-
assert_equal %w[sqc8b49rny0 sqdtr74hyu0], redis.geohash('Sicily', %w[Palermo Catania])
28-
end
21+
add_sicily
22+
assert_equal %w[sqc8b49rny0 sqdtr74hyu0], redis.geohash('Sicily', %w[Palermo Catania])
2923
end
3024

3125
def test_geopos
32-
target_version(MIN_REDIS_VERSION) do
33-
add_sicily
34-
expected = [%w[13.36138933897018433 38.11555639549629859],
35-
%w[15.08726745843887329 37.50266842333162032],
36-
nil]
37-
assert_equal expected, redis.geopos('Sicily', %w[Palermo Catania NonExisting])
38-
end
26+
add_sicily
27+
expected = [%w[13.36138933897018433 38.11555639549629859],
28+
%w[15.08726745843887329 37.50266842333162032],
29+
nil]
30+
assert_equal expected, redis.geopos('Sicily', %w[Palermo Catania NonExisting])
3931
end
4032

4133
def test_geodist
42-
target_version(MIN_REDIS_VERSION) do
43-
add_sicily
44-
assert_equal '166274.1516', redis.geodist('Sicily', 'Palermo', 'Catania')
45-
assert_equal '166.2742', redis.geodist('Sicily', 'Palermo', 'Catania', 'km')
46-
assert_equal '103.3182', redis.geodist('Sicily', 'Palermo', 'Catania', 'mi')
47-
end
34+
add_sicily
35+
assert_equal '166274.1516', redis.geodist('Sicily', 'Palermo', 'Catania')
36+
assert_equal '166.2742', redis.geodist('Sicily', 'Palermo', 'Catania', 'km')
37+
assert_equal '103.3182', redis.geodist('Sicily', 'Palermo', 'Catania', 'mi')
4838
end
4939

5040
def test_georadius
51-
target_version(MIN_REDIS_VERSION) do
52-
add_sicily
41+
add_sicily
5342

54-
expected = [%w[Palermo 190.4424], %w[Catania 56.4413]]
55-
assert_equal expected, redis.georadius('Sicily', 15, 37, 200, 'km', 'WITHDIST')
43+
expected = [%w[Palermo 190.4424], %w[Catania 56.4413]]
44+
assert_equal expected, redis.georadius('Sicily', 15, 37, 200, 'km', 'WITHDIST')
5645

57-
expected = [['Palermo', %w[13.36138933897018433 38.11555639549629859]],
58-
['Catania', %w[15.08726745843887329 37.50266842333162032]]]
59-
assert_equal expected, redis.georadius('Sicily', 15, 37, 200, 'km', 'WITHCOORD')
46+
expected = [['Palermo', %w[13.36138933897018433 38.11555639549629859]],
47+
['Catania', %w[15.08726745843887329 37.50266842333162032]]]
48+
assert_equal expected, redis.georadius('Sicily', 15, 37, 200, 'km', 'WITHCOORD')
6049

61-
expected = [['Palermo', '190.4424', %w[13.36138933897018433 38.11555639549629859]],
62-
['Catania', '56.4413', %w[15.08726745843887329 37.50266842333162032]]]
63-
assert_equal expected, redis.georadius('Sicily', 15, 37, 200, 'km', 'WITHDIST', 'WITHCOORD')
64-
end
50+
expected = [['Palermo', '190.4424', %w[13.36138933897018433 38.11555639549629859]],
51+
['Catania', '56.4413', %w[15.08726745843887329 37.50266842333162032]]]
52+
assert_equal expected, redis.georadius('Sicily', 15, 37, 200, 'km', 'WITHDIST', 'WITHCOORD')
6553
end
6654

6755
def test_georadiusbymember
68-
target_version(MIN_REDIS_VERSION) do
69-
redis.geoadd('Sicily', 13.583333, 37.316667, 'Agrigento')
70-
add_sicily
71-
assert_equal %w[Agrigento Palermo], redis.georadiusbymember('Sicily', 'Agrigento', 100, 'km')
72-
end
56+
redis.geoadd('Sicily', 13.583333, 37.316667, 'Agrigento')
57+
add_sicily
58+
assert_equal %w[Agrigento Palermo], redis.georadiusbymember('Sicily', 'Agrigento', 100, 'km')
7359
end
7460
end

test/cluster/commands_on_keys_test.rb

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def test_migrate
4747
def test_object
4848
redis.lpush('mylist', 'Hello World')
4949
assert_equal 1, redis.object('refcount', 'mylist')
50-
expected_encoding = version < '3.2.0' ? 'ziplist' : 'quicklist'
51-
assert_equal expected_encoding, redis.object('encoding', 'mylist')
50+
assert_equal 'quicklist', redis.object('encoding', 'mylist')
5251
assert(redis.object('idletime', 'mylist') >= 0)
5352

5453
redis.set('foo', 1000)
@@ -93,29 +92,25 @@ def test_sort
9392
end
9493

9594
def test_touch
96-
target_version('3.2.1') do
97-
set_some_keys
98-
assert_equal 1, redis.touch('key1')
99-
assert_equal 1, redis.touch('key2')
100-
if version < '6'
101-
assert_equal 1, redis.touch('key1', 'key2')
102-
else
103-
assert_raises(Redis::CommandError, "CROSSSLOT Keys in request don't hash to the same slot") do
104-
redis.touch('key1', 'key2')
105-
end
95+
set_some_keys
96+
assert_equal 1, redis.touch('key1')
97+
assert_equal 1, redis.touch('key2')
98+
if version < '6'
99+
assert_equal 1, redis.touch('key1', 'key2')
100+
else
101+
assert_raises(Redis::CommandError, "CROSSSLOT Keys in request don't hash to the same slot") do
102+
redis.touch('key1', 'key2')
106103
end
107-
assert_equal 2, redis.touch('{key}1', '{key}2')
108104
end
105+
assert_equal 2, redis.touch('{key}1', '{key}2')
109106
end
110107

111108
def test_unlink
112-
target_version('4.0.0') do
113-
set_some_keys
114-
assert_raises(Redis::CommandError, "CROSSSLOT Keys in request don't hash to the same slot") do
115-
redis.unlink('key1', 'key2', 'key3')
116-
end
117-
assert_equal 2, redis.unlink('{key}1', '{key}2', '{key}3')
109+
set_some_keys
110+
assert_raises(Redis::CommandError, "CROSSSLOT Keys in request don't hash to the same slot") do
111+
redis.unlink('key1', 'key2', 'key3')
118112
end
113+
assert_equal 2, redis.unlink('{key}1', '{key}2', '{key}3')
119114
end
120115

121116
def test_wait

test/cluster/commands_on_scripting_test.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ def test_evalsha
2828
end
2929

3030
def test_script_debug
31-
target_version('3.2.0') do
32-
assert_equal 'OK', redis.script(:debug, 'yes')
33-
assert_equal 'OK', redis.script(:debug, 'no')
34-
end
31+
assert_equal 'OK', redis.script(:debug, 'yes')
32+
assert_equal 'OK', redis.script(:debug, 'no')
3533
end
3634

3735
def test_script_exists

test/cluster/commands_on_server_test.rb

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def test_client_pause
5959
end
6060

6161
def test_client_reply
62-
target_version('3.2.0') do
63-
assert_equal 'OK', redis.client(:reply, 'ON')
64-
end
62+
assert_equal 'OK', redis.client(:reply, 'ON')
6563
end
6664

6765
def test_client_setname
@@ -143,40 +141,28 @@ def test_lastsave
143141
end
144142

145143
def test_memory_doctor
146-
target_version('4.0.0') do
147-
assert_instance_of String, redis.memory(:doctor)
148-
end
144+
assert_instance_of String, redis.memory(:doctor)
149145
end
150146

151147
def test_memory_help
152-
target_version('4.0.0') do
153-
assert_instance_of Array, redis.memory(:help)
154-
end
148+
assert_instance_of Array, redis.memory(:help)
155149
end
156150

157151
def test_memory_malloc_stats
158-
target_version('4.0.0') do
159-
assert_instance_of String, redis.memory('malloc-stats')
160-
end
152+
assert_instance_of String, redis.memory('malloc-stats')
161153
end
162154

163155
def test_memory_purge
164-
target_version('4.0.0') do
165-
assert_equal 'OK', redis.memory(:purge)
166-
end
156+
assert_equal 'OK', redis.memory(:purge)
167157
end
168158

169159
def test_memory_stats
170-
target_version('4.0.0') do
171-
assert_instance_of Array, redis.memory(:stats)
172-
end
160+
assert_instance_of Array, redis.memory(:stats)
173161
end
174162

175163
def test_memory_usage
176-
target_version('4.0.0') do
177-
redis.set('key1', 'Hello World')
178-
assert_operator redis.memory(:usage, 'key1'), :>, 0
179-
end
164+
redis.set('key1', 'Hello World')
165+
assert_operator redis.memory(:usage, 'key1'), :>, 0
180166
end
181167

182168
def test_monitor

test/distributed/commands_on_hyper_log_log_test.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,17 @@ class TestDistributedCommandsOnHyperLogLog < Minitest::Test
77
include Lint::HyperLogLog
88

99
def test_pfmerge
10-
target_version '2.8.9' do
11-
assert_raises Redis::Distributed::CannotDistribute do
12-
super
13-
end
10+
assert_raises Redis::Distributed::CannotDistribute do
11+
super
1412
end
1513
end
1614

1715
def test_pfcount_multiple_keys_diff_nodes
18-
target_version '2.8.9' do
19-
assert_raises Redis::Distributed::CannotDistribute do
20-
r.pfadd 'foo', 's1'
21-
r.pfadd 'bar', 's2'
16+
assert_raises Redis::Distributed::CannotDistribute do
17+
r.pfadd 'foo', 's1'
18+
r.pfadd 'bar', 's2'
2219

23-
assert r.pfcount('res', 'foo', 'bar')
24-
end
20+
assert r.pfcount('res', 'foo', 'bar')
2521
end
2622
end
2723
end

test/distributed/commands_on_strings_test.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ def test_msetnx_mapped
5757
end
5858

5959
def test_bitop
60-
target_version "2.5.10" do
61-
assert_raises Redis::Distributed::CannotDistribute do
62-
r.set("foo", "a")
63-
r.set("bar", "b")
60+
assert_raises Redis::Distributed::CannotDistribute do
61+
r.set("foo", "a")
62+
r.set("bar", "b")
6463

65-
r.bitop(:and, "foo&bar", "foo", "bar")
66-
end
64+
r.bitop(:and, "foo&bar", "foo", "bar")
6765
end
6866
end
6967

test/distributed/commands_on_value_types_test.rb

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,35 @@ def test_del_with_array_argument
3939
end
4040

4141
def test_unlink
42-
target_version "4.0.0" do
43-
r.set "foo", "s1"
44-
r.set "bar", "s2"
45-
r.set "baz", "s3"
42+
r.set "foo", "s1"
43+
r.set "bar", "s2"
44+
r.set "baz", "s3"
4645

47-
assert_equal ["bar", "baz", "foo"], r.keys("*").sort
46+
assert_equal ["bar", "baz", "foo"], r.keys("*").sort
4847

49-
assert_equal 1, r.unlink("foo")
48+
assert_equal 1, r.unlink("foo")
5049

51-
assert_equal ["bar", "baz"], r.keys("*").sort
50+
assert_equal ["bar", "baz"], r.keys("*").sort
5251

53-
assert_equal 2, r.unlink("bar", "baz")
52+
assert_equal 2, r.unlink("bar", "baz")
5453

55-
assert_equal [], r.keys("*").sort
56-
end
54+
assert_equal [], r.keys("*").sort
5755
end
5856

5957
def test_unlink_with_array_argument
60-
target_version "4.0.0" do
61-
r.set "foo", "s1"
62-
r.set "bar", "s2"
63-
r.set "baz", "s3"
58+
r.set "foo", "s1"
59+
r.set "bar", "s2"
60+
r.set "baz", "s3"
6461

65-
assert_equal ["bar", "baz", "foo"], r.keys("*").sort
62+
assert_equal ["bar", "baz", "foo"], r.keys("*").sort
6663

67-
assert_equal 1, r.unlink(["foo"])
64+
assert_equal 1, r.unlink(["foo"])
6865

69-
assert_equal ["bar", "baz"], r.keys("*").sort
66+
assert_equal ["bar", "baz"], r.keys("*").sort
7067

71-
assert_equal 2, r.unlink(["bar", "baz"])
68+
assert_equal 2, r.unlink(["bar", "baz"])
7269

73-
assert_equal [], r.keys("*").sort
74-
end
70+
assert_equal [], r.keys("*").sort
7571
end
7672

7773
def test_randomkey

test/distributed/commands_requiring_clustering_test.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,16 @@ def test_sort_with_store
159159
end
160160

161161
def test_bitop
162-
target_version "2.5.10" do
163-
r.set("{qux}foo", "a")
164-
r.set("{qux}bar", "b")
165-
166-
r.bitop(:and, "{qux}foo&bar", "{qux}foo", "{qux}bar")
167-
assert_equal "\x60", r.get("{qux}foo&bar")
168-
r.bitop(:or, "{qux}foo|bar", "{qux}foo", "{qux}bar")
169-
assert_equal "\x63", r.get("{qux}foo|bar")
170-
r.bitop(:xor, "{qux}foo^bar", "{qux}foo", "{qux}bar")
171-
assert_equal "\x03", r.get("{qux}foo^bar")
172-
r.bitop(:not, "{qux}~foo", "{qux}foo")
173-
assert_equal "\x9E", r.get("{qux}~foo")
174-
end
162+
r.set("{qux}foo", "a")
163+
r.set("{qux}bar", "b")
164+
165+
r.bitop(:and, "{qux}foo&bar", "{qux}foo", "{qux}bar")
166+
assert_equal "\x60", r.get("{qux}foo&bar")
167+
r.bitop(:or, "{qux}foo|bar", "{qux}foo", "{qux}bar")
168+
assert_equal "\x63", r.get("{qux}foo|bar")
169+
r.bitop(:xor, "{qux}foo^bar", "{qux}foo", "{qux}bar")
170+
assert_equal "\x03", r.get("{qux}foo^bar")
171+
r.bitop(:not, "{qux}~foo", "{qux}foo")
172+
assert_equal "\x9E", r.get("{qux}~foo")
175173
end
176174
end

0 commit comments

Comments
 (0)