Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: truffleruby-22.2.0
ruby-version: truffleruby
bundler-cache: true
- name: Cache local temporary directory
uses: actions/cache@v3
Expand Down
18 changes: 9 additions & 9 deletions test/redis/publish_subscribe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_psubscribe_connection_usable_after_raise
end

def test_subscribe_within_subscribe
@channels = []
@channels = Queue.new

thread = new_thread do |r|
r.subscribe(channel_name) do |on|
Expand All @@ -192,7 +192,8 @@ def test_subscribe_within_subscribe

thread.join

assert_equal [channel_name, "bar"], @channels
assert_equal [channel_name, "bar"], [@channels.pop, @channels.pop]
assert_empty @channels
end

def test_other_commands_within_a_subscribe
Expand Down Expand Up @@ -270,8 +271,7 @@ def test_psubscribe_with_timeout
def test_unsubscribe_from_another_thread
@unsubscribed = @subscribed = false
@subscribed_redis = nil
@messages = []
@messages_count = 0
@messages = Queue.new
thread = new_thread do |r|
@subscribed_redis = r
r.subscribe(channel_name) do |on|
Expand All @@ -281,7 +281,6 @@ def test_unsubscribe_from_another_thread

on.message do |channel, message|
@messages << [channel, message]
@messages_count += 1
end

on.unsubscribe do |_channel, _total|
Expand All @@ -293,16 +292,16 @@ def test_unsubscribe_from_another_thread
Thread.pass until @subscribed

redis.publish(channel_name, "test")
Thread.pass until @messages_count == 1
assert_equal [channel_name, "test"], @messages.last
assert_equal [channel_name, "test"], @messages.pop
assert_empty @messages

@subscribed_redis.unsubscribe # this shouldn't block
refute_nil thread.join(2)
assert_equal true, @unsubscribed
end

def test_subscribe_from_another_thread
@events = []
@events = Queue.new
@subscribed_redis = nil
thread = new_thread do |r|
r.subscribe(channel_name) do |on|
Expand Down Expand Up @@ -339,7 +338,8 @@ def test_subscribe_from_another_thread
["unsubscribed", channel_name],
["unsubscribed", "#{channel_name}:2"]
]
assert_equal expected, @events
assert_equal(expected, expected.map { @events.pop })
assert_empty @events
end

private
Expand Down