@@ -178,7 +178,7 @@ def test_pipelined_with_many_commands
178
178
end
179
179
180
180
def test_transaction_with_single_key
181
- got = @client . multi do |t |
181
+ got = @client . multi ( key : 'counter' ) do |t |
182
182
t . call ( 'SET' , 'counter' , '0' )
183
183
t . call ( 'INCR' , 'counter' )
184
184
t . call ( 'INCR' , 'counter' )
@@ -190,7 +190,7 @@ def test_transaction_with_single_key
190
190
191
191
def test_transaction_with_multiple_key
192
192
assert_raises ( ::RedisClient ::Cluster ::Transaction ::ConsistencyError ) do
193
- @client . multi do |t |
193
+ @client . multi ( key : 'key1' ) do |t |
194
194
t . call ( 'SET' , 'key1' , '1' )
195
195
t . call ( 'SET' , 'key2' , '2' )
196
196
t . call ( 'SET' , 'key3' , '3' )
@@ -204,20 +204,19 @@ def test_transaction_with_multiple_key
204
204
205
205
def test_transaction_with_empty_block
206
206
assert_raises ( ArgumentError ) { @client . multi { } }
207
- assert_raises ( LocalJumpError ) { @client . multi }
207
+ assert_raises ( LocalJumpError ) { @client . multi ( key : 'foo' ) }
208
208
end
209
209
210
210
def test_transaction_with_keyless_commands
211
- assert_raises ( ::RedisClient ::Cluster ::Transaction ::ConsistencyError ) do
212
- @client . multi do |t |
213
- t . call ( 'ECHO' , 'foo' )
214
- t . call ( 'ECHO' , 'bar' )
215
- end
211
+ got = @client . multi ( key : 'hello' ) do |t |
212
+ t . call ( 'ECHO' , 'foo' )
213
+ t . call ( 'ECHO' , 'bar' )
216
214
end
215
+ assert_equal %w[ foo bar ] , got
217
216
end
218
217
219
218
def test_transaction_with_hashtag
220
- got = @client . multi do |t |
219
+ got = @client . multi ( key : '{key}' ) do |t |
221
220
t . call ( 'MSET' , '{key}1' , '1' , '{key}2' , '2' )
222
221
t . call ( 'MSET' , '{key}3' , '3' , '{key}4' , '4' )
223
222
end
@@ -228,14 +227,14 @@ def test_transaction_with_hashtag
228
227
229
228
def test_transaction_without_hashtag
230
229
assert_raises ( ::RedisClient ::Cluster ::Transaction ::ConsistencyError ) do
231
- @client . multi do |t |
230
+ @client . multi ( key : 'key1' ) do |t |
232
231
t . call ( 'MSET' , 'key1' , '1' , 'key2' , '2' )
233
232
t . call ( 'MSET' , 'key3' , '3' , 'key4' , '4' )
234
233
end
235
234
end
236
235
237
- assert_raises ( ::RedisClient ::CommandError , 'CROSSSLOT keys' ) do
238
- @client . multi do |t |
236
+ assert_raises ( ::RedisClient ::Cluster :: Transaction :: ConsistencyError ) do
237
+ @client . multi ( key : 'key1' ) do |t |
239
238
t . call ( 'MSET' , 'key1' , '1' , 'key2' , '2' )
240
239
t . call ( 'MSET' , 'key1' , '1' , 'key3' , '3' )
241
240
t . call ( 'MSET' , 'key1' , '1' , 'key4' , '4' )
0 commit comments