@@ -6,6 +6,9 @@ class TestPublishSubscribe < Test::Unit::TestCase
6
6
7
7
include Helper ::Client
8
8
9
+ class TestError < StandardError
10
+ end
11
+
9
12
def test_subscribe_and_unsubscribe
10
13
@subscribed = false
11
14
@unsubscribed = false
@@ -84,6 +87,62 @@ def test_psubscribe_and_punsubscribe
84
87
assert_equal "s1" , @message
85
88
end
86
89
90
+ def test_subscribe_connection_usable_after_raise
91
+ @subscribed = false
92
+
93
+ wire = Wire . new do
94
+ begin
95
+ r . subscribe ( "foo" ) do |on |
96
+ on . subscribe do |channel , total |
97
+ @subscribed = true
98
+ end
99
+
100
+ on . message do |channel , message |
101
+ raise TestError
102
+ end
103
+ end
104
+ rescue TestError
105
+ end
106
+ end
107
+
108
+ # Wait until the subscription is active before publishing
109
+ Wire . pass while !@subscribed
110
+
111
+ Redis . new ( OPTIONS ) . publish ( "foo" , "s1" )
112
+
113
+ wire . join
114
+
115
+ assert_equal "PONG" , r . ping
116
+ end
117
+
118
+ def test_psubscribe_connection_usable_after_raise
119
+ @subscribed = false
120
+
121
+ wire = Wire . new do
122
+ begin
123
+ r . psubscribe ( "f*" ) do |on |
124
+ on . psubscribe do |pattern , total |
125
+ @subscribed = true
126
+ end
127
+
128
+ on . pmessage do |pattern , channel , message |
129
+ raise TestError
130
+ end
131
+ end
132
+ rescue TestError
133
+ end
134
+ end
135
+
136
+ # Wait until the subscription is active before publishing
137
+ Wire . pass while !@subscribed
138
+
139
+ Redis . new ( OPTIONS ) . publish ( "foo" , "s1" )
140
+
141
+ wire . join
142
+
143
+ assert_equal "PONG" , r . ping
144
+ end
145
+
87
146
def test_subscribe_within_subscribe
88
147
@channels = [ ]
89
148
0 commit comments