Skip to content

Commit 81e54de

Browse files
committed
add redis target version to pubsub tests
1 parent 16e296d commit 81e54de

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

test/publish_subscribe_test.rb

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,43 +88,47 @@ def test_psubscribe_and_punsubscribe
8888
end
8989

9090
def test_pubsub_with_numpat_subcommand
91-
@subscribed = false
92-
wire = Wire.new do
93-
r.psubscribe("f*") do |on|
94-
on.psubscribe { |channel, total| @subscribed = true }
95-
on.pmessage { |pattern, channel, message| r.punsubscribe }
91+
target_version("2.8.0") do
92+
@subscribed = false
93+
wire = Wire.new do
94+
r.psubscribe("f*") do |on|
95+
on.psubscribe { |channel, total| @subscribed = true }
96+
on.pmessage { |pattern, channel, message| r.punsubscribe }
97+
end
9698
end
97-
end
98-
Wire.pass while !@subscribed
99-
redis = Redis.new(OPTIONS)
100-
numpat_result = redis.pubsub(:numpat)
99+
Wire.pass while !@subscribed
100+
redis = Redis.new(OPTIONS)
101+
numpat_result = redis.pubsub(:numpat)
101102

102-
redis.publish("foo", "s1")
103-
wire.join
103+
redis.publish("foo", "s1")
104+
wire.join
104105

105-
assert_equal redis.pubsub(:numpat), 0
106-
assert_equal numpat_result, 1
106+
assert_equal redis.pubsub(:numpat), 0
107+
assert_equal numpat_result, 1
108+
end
107109
end
108110

109111

110112
def test_pubsub_with_channels_and_numsub_subcommnads
111-
@subscribed = false
112-
wire = Wire.new do
113-
r.subscribe("foo") do |on|
114-
on.subscribe { |channel, total| @subscribed = true }
115-
on.message { |channel, message| r.unsubscribe }
113+
target_version("2.8.0") do
114+
@subscribed = false
115+
wire = Wire.new do
116+
r.subscribe("foo") do |on|
117+
on.subscribe { |channel, total| @subscribed = true }
118+
on.message { |channel, message| r.unsubscribe }
119+
end
116120
end
117-
end
118-
Wire.pass while !@subscribed
119-
redis = Redis.new(OPTIONS)
120-
channels_result = redis.pubsub(:channels)
121-
numsub_result = redis.pubsub(:numsub, 'foo', 'boo')
121+
Wire.pass while !@subscribed
122+
redis = Redis.new(OPTIONS)
123+
channels_result = redis.pubsub(:channels)
124+
numsub_result = redis.pubsub(:numsub, 'foo', 'boo')
122125

123-
redis.publish("foo", "s1")
124-
wire.join
126+
redis.publish("foo", "s1")
127+
wire.join
125128

126-
assert_equal channels_result, ['foo']
127-
assert_equal numsub_result, ['foo', '1', 'boo', '0']
129+
assert_equal channels_result, ['foo']
130+
assert_equal numsub_result, ['foo', '1', 'boo', '0']
131+
end
128132
end
129133

130134
def test_subscribe_connection_usable_after_raise

0 commit comments

Comments
 (0)