@@ -49,20 +49,20 @@ def test_parse_command_reply
49
49
[
50
50
{
51
51
rows : [
52
- [ 'get' , 2 , Set [ 'readonly' , 'fast' ] , 1 , 1 , 1 , Set [ '@read' , '@string' , '@fast' ] , Set [ ] , Set [ ] , Set [ ] ] ,
53
- [ 'set' , -3 , Set [ 'write' , 'denyoom' , 'movablekeys' ] , 1 , 1 , 1 , Set [ '@write' , '@string' , '@slow' ] , Set [ ] , Set [ ] , Set [ ] ]
52
+ [ 'get' , 2 , Set [ 'readonly' , 'fast' ] , 1 , - 1 , 1 , Set [ '@read' , '@string' , '@fast' ] , Set [ ] , Set [ ] , Set [ ] ] ,
53
+ [ 'set' , -3 , Set [ 'write' , 'denyoom' , 'movablekeys' ] , 1 , - 1 , 2 , Set [ '@write' , '@string' , '@slow' ] , Set [ ] , Set [ ] , Set [ ] ]
54
54
] ,
55
55
want : {
56
- 'get' => { first_key_position : 1 , write? : false , readonly? : true } ,
57
- 'set' => { first_key_position : 1 , write? : true , readonly? : false }
56
+ 'get' => { first_key_position : 1 , last_key_position : - 1 , key_step : 1 , write? : false , readonly? : true } ,
57
+ 'set' => { first_key_position : 1 , last_key_position : - 1 , key_step : 2 , write? : true , readonly? : false }
58
58
}
59
59
} ,
60
60
{
61
61
rows : [
62
- [ 'GET' , 2 , Set [ 'readonly' , 'fast' ] , 1 , 1 , 1 , Set [ '@read' , '@string' , '@fast' ] , Set [ ] , Set [ ] , Set [ ] ]
62
+ [ 'GET' , 2 , Set [ 'readonly' , 'fast' ] , 1 , - 1 , 1 , Set [ '@read' , '@string' , '@fast' ] , Set [ ] , Set [ ] , Set [ ] ]
63
63
] ,
64
64
want : {
65
- 'get' => { first_key_position : 1 , write? : false , readonly? : true }
65
+ 'get' => { first_key_position : 1 , last_key_position : - 1 , key_step : 1 , write? : false , readonly? : true }
66
66
}
67
67
} ,
68
68
{ rows : [ [ ] ] , want : { } } ,
@@ -212,6 +212,37 @@ def test_extract_hash_tag
212
212
assert_equal ( c [ :want ] , got , msg )
213
213
end
214
214
end
215
+
216
+ def test_extract_all_keys
217
+ cmd = ::RedisClient ::Cluster ::Command . load ( @raw_clients )
218
+ [
219
+ { command : [ 'EVAL' , 'return ARGV[1]' , '0' , 'hello' ] , want : [ ] } ,
220
+ { command : [ 'EVAL' , 'return ARGV[1]' , '3' , 'key1' , 'key2' , 'key3' , 'arg1' , 'arg2' ] , want : %w[ key1 key2 key3 ] } ,
221
+ { command : [ [ 'EVAL' ] , '"return ARGV[1]"' , 0 , 'hello' ] , want : [ ] } ,
222
+ { command : %w[ EVALSHA sha1 2 foo bar baz zap ] , want : %w[ foo bar ] } ,
223
+ { command : %w[ MIGRATE host port key 0 5 COPY ] , want : %w[ key ] } ,
224
+ { command : [ 'MIGRATE' , 'host' , 'port' , '' , '0' , '5' , 'COPY' , 'KEYS' , 'key1' ] , want : %w[ key1 ] } ,
225
+ { command : [ 'MIGRATE' , 'host' , 'port' , '' , '0' , '5' , 'COPY' , 'KEYS' , 'key1' , 'key2' ] , want : %w[ key1 key2 ] } ,
226
+ { command : %w[ ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 ] , want : %w[ zset1 zset2 ] } ,
227
+ { command : %w[ ZUNIONSTORE out 2 zset1 zset2 WEIGHTS 2 3 ] , want : %w[ zset1 zset2 ] } ,
228
+ { command : %w[ OBJECT HELP ] , want : [ ] } ,
229
+ { command : %w[ MEMORY HELP ] , want : [ ] } ,
230
+ { command : %w[ MEMORY USAGE key ] , want : %w[ key ] } ,
231
+ { command : %w[ XREAD COUNT 2 STREAMS mystream writers 0-0 0-0 ] , want : %w[ mystream writers ] } ,
232
+ { command : %w[ XREADGROUP GROUP group consumer STREAMS key id ] , want : %w[ key ] } ,
233
+ { command : %w[ SET foo 1 ] , want : %w[ foo ] } ,
234
+ { command : %w[ set foo 1 ] , want : %w[ foo ] } ,
235
+ { command : [ [ 'SET' ] , 'foo' , 1 ] , want : %w[ foo ] } ,
236
+ { command : %w[ GET foo ] , want : %w[ foo ] } ,
237
+ { command : %w[ MGET foo bar baz ] , want : %w[ foo bar baz ] } ,
238
+ { command : %w[ MSET foo val bar val baz val ] , want : %w[ foo bar baz ] } ,
239
+ { command : %w[ BLPOP foo bar 0 ] , want : %w[ foo bar ] }
240
+ ] . each_with_index do |c , idx |
241
+ msg = "Case: #{ idx } "
242
+ got = cmd . send ( :extract_all_keys , c [ :command ] )
243
+ assert_equal ( c [ :want ] , got , msg )
244
+ end
245
+ end
215
246
end
216
247
end
217
248
end
0 commit comments