@@ -188,15 +188,14 @@ def test_pubsub_without_subscription
188188 end
189189
190190 def test_transaction_with_single_key
191- want = [ 'OK' , 1 , 2 , '2' ]
192191 got = @client . multi do |t |
193192 t . call ( 'SET' , 'counter' , '0' )
194193 t . call ( 'INCR' , 'counter' )
195194 t . call ( 'INCR' , 'counter' )
196- t . call ( 'GET' , 'counter' )
197195 end
198196
199- assert_equal ( want , got )
197+ assert_equal ( [ 'OK' , 1 , 2 ] , got )
198+ assert_equal ( '2' , @client . call ( 'GET' , 'counter' ) )
200199 end
201200
202201 def test_transaction_with_multiple_key
@@ -215,25 +214,41 @@ def test_transaction_with_multiple_key
215214
216215 def test_transaction_with_empty_block
217216 assert_raises ( ArgumentError ) { @client . multi { } }
217+ assert_raises ( LocalJumpError ) { @client . multi }
218+ end
219+
220+ def test_transaction_with_keyless_commands
221+ assert_raises ( ::RedisClient ::Cluster ::Transaction ::ConsistencyError ) do
222+ @client . multi do |t |
223+ t . call ( 'ECHO' , 'foo' )
224+ t . call ( 'ECHO' , 'bar' )
225+ end
226+ end
218227 end
219228
220229 def test_transaction_with_hashtag
221- want = [ 'OK' , 'OK' , %w[ 1 2 3 4 ] ]
222230 got = @client . multi do |t |
223231 t . call ( 'MSET' , '{key}1' , '1' , '{key}2' , '2' )
224232 t . call ( 'MSET' , '{key}3' , '3' , '{key}4' , '4' )
225- t . call ( 'MGET' , '{key}1' , '{key}2' , '{key}3' , '{key}4' )
226233 end
227234
228- assert_equal ( want , got )
235+ assert_equal ( %w[ OK OK ] , got )
236+ assert_equal ( %w[ 1 2 3 4 ] , @client . call ( 'MGET' , '{key}1' , '{key}2' , '{key}3' , '{key}4' ) )
229237 end
230238
231239 def test_transaction_without_hashtag
232240 assert_raises ( ::RedisClient ::Cluster ::Transaction ::ConsistencyError ) do
233241 @client . multi do |t |
234242 t . call ( 'MSET' , 'key1' , '1' , 'key2' , '2' )
235243 t . call ( 'MSET' , 'key3' , '3' , 'key4' , '4' )
236- t . call ( 'MGET' , 'key1' , 'key2' , 'key3' , 'key4' )
244+ end
245+ end
246+
247+ assert_raises ( ::RedisClient ::CommandError , 'CROSSSLOT keys' ) do
248+ @client . multi do |t |
249+ t . call ( 'MSET' , 'key1' , '1' , 'key2' , '2' )
250+ t . call ( 'MSET' , 'key1' , '1' , 'key3' , '3' )
251+ t . call ( 'MSET' , 'key1' , '1' , 'key4' , '4' )
237252 end
238253 end
239254
0 commit comments