@@ -98,6 +98,18 @@ def test_assignment_of_results_inside_the_block_with_errors
9898 assert_raises ( Redis ::FutureNotReady ) { @second . value }
9999 end
100100
101+ def test_assignment_of_results_inside_the_block_without_raising_exception
102+ r . pipelined ( exception : false ) do |p |
103+ @first = p . doesnt_exist
104+ @second = p . sadd? ( "foo" , 1 )
105+ @third = p . sadd? ( "foo" , 1 )
106+ end
107+
108+ assert_equal RedisClient ::CommandError , @first . value . class
109+ assert_equal true , @second . value
110+ assert_equal false , @third . value
111+ end
112+
101113 def test_assignment_of_results_inside_a_nested_block
102114 r . pipelined do |p |
103115 @first = p . sadd? ( "foo" , 1 )
@@ -111,6 +123,30 @@ def test_assignment_of_results_inside_a_nested_block
111123 assert_equal false , @second . value
112124 end
113125
126+ def test_nested_pipelining_returns_without_raising_exception
127+ result = r . pipelined ( exception : false ) do |p1 |
128+ p1 . doesnt_exist
129+ p1 . set ( "foo" , "42" )
130+ p1 . pipelined do |p2 |
131+ p1 . doesnt_exist_again
132+ p2 . set ( "bar" , "99" )
133+ end
134+ end
135+
136+ assert result [ 0 ] . is_a? ( RedisClient ::CommandError )
137+ assert_equal [ "doesnt_exist" ] , result [ 0 ] . command
138+
139+ assert_equal "OK" , result [ 1 ]
140+
141+ assert result [ 2 ] . is_a? ( RedisClient ::CommandError )
142+ assert_equal [ "doesnt_exist_again" ] , result [ 2 ] . command
143+
144+ assert_equal "OK" , result [ 3 ]
145+
146+ assert_equal "42" , r . get ( "foo" )
147+ assert_equal "99" , r . get ( "bar" )
148+ end
149+
114150 def test_futures_raise_when_confused_with_something_else
115151 r . pipelined do |p |
116152 @result = p . sadd? ( "foo" , 1 )
0 commit comments