@@ -53,16 +53,16 @@ def test_parse_command_reply
53
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 , 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 }
56
+ 'get' => { first_key_position : 1 , key_step : 1 , write? : false , readonly? : true } ,
57
+ 'set' => { first_key_position : 1 , key_step : 2 , write? : true , readonly? : false }
58
58
}
59
59
} ,
60
60
{
61
61
rows : [
62
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 , last_key_position : - 1 , key_step : 1 , write? : false , readonly? : true }
65
+ 'get' => { first_key_position : 1 , key_step : 1 , write? : false , readonly? : true }
66
66
}
67
67
} ,
68
68
{ rows : [ [ ] ] , want : { } } ,
@@ -87,8 +87,6 @@ def test_extract_first_key
87
87
{ command : %w[ GET foo{bar}baz ] , want : 'foo{bar}baz' } ,
88
88
{ command : %w[ MGET foo bar baz ] , want : 'foo' } ,
89
89
{ command : %w[ UNKNOWN foo bar ] , want : '' } ,
90
- { command : [ [ 'GET' ] , 'foo' ] , want : 'foo' } ,
91
- { command : [ 'GET' , [ 'foo' ] ] , want : 'foo' } ,
92
90
{ command : [ ] , want : '' } ,
93
91
{ command : nil , want : '' }
94
92
] . each_with_index do |c , idx |
@@ -151,7 +149,6 @@ def test_determine_first_key_position
151
149
cmd = ::RedisClient ::Cluster ::Command . load ( @raw_clients )
152
150
[
153
151
{ command : %w[ EVAL "return ARGV[1]" 0 hello ] , want : 3 } ,
154
- { command : [ [ 'EVAL' ] , '"return ARGV[1]"' , 0 , 'hello' ] , want : 3 } ,
155
152
{ command : %w[ EVALSHA sha1 2 foo bar baz zap ] , want : 3 } ,
156
153
{ command : %w[ MIGRATE host port key 0 5 COPY ] , want : 3 } ,
157
154
{ command : [ 'MIGRATE' , 'host' , 'port' , '' , '0' , '5' , 'COPY' , 'KEYS' , 'key' ] , want : 8 } ,
@@ -164,7 +161,7 @@ def test_determine_first_key_position
164
161
{ command : %w[ XREADGROUP GROUP group consumer STREAMS key id ] , want : 5 } ,
165
162
{ command : %w[ SET foo 1 ] , want : 1 } ,
166
163
{ command : %w[ set foo 1 ] , want : 1 } ,
167
- { command : [ [ 'SET' ] , 'foo' , 1 ] , want : 1 } ,
164
+ { command : [ 'SET' , 'foo' , 1 ] , want : 1 } ,
168
165
{ command : %w[ GET foo ] , want : 1 }
169
166
] . each_with_index do |c , idx |
170
167
msg = "Case: #{ idx } "
@@ -179,62 +176,16 @@ def test_determine_optional_key_position
179
176
{ params : { command : %w[ XREAD COUNT 2 STREAMS mystream writers 0-0 0-0 ] , option_name : 'streams' } , want : 4 } ,
180
177
{ params : { command : %w[ XREADGROUP GROUP group consumer STREAMS key id ] , option_name : 'streams' } , want : 5 } ,
181
178
{ params : { command : %w[ GET foo ] , option_name : 'bar' } , want : 0 } ,
182
- { params : { command : [ ' FOO' , [ ' BAR' ] , ' BAZ' ] , option_name : 'bar' } , want : 2 } ,
179
+ { params : { command : %w[ FOO BAR BAZ ] , option_name : 'bar' } , want : 2 } ,
183
180
{ params : { command : %w[ FOO BAR BAZ ] , option_name : 'BAR' } , want : 2 } ,
184
181
{ params : { command : [ ] , option_name : nil } , want : 0 } ,
185
- { params : { command : [ ] , option_name : '' } , want : 0 } ,
186
- { params : { command : nil , option_name : nil } , want : 0 }
182
+ { params : { command : [ ] , option_name : '' } , want : 0 }
187
183
] . each_with_index do |c , idx |
188
184
msg = "Case: #{ idx } "
189
185
got = cmd . send ( :determine_optional_key_position , c [ :params ] [ :command ] , c [ :params ] [ :option_name ] )
190
186
assert_equal ( c [ :want ] , got , msg )
191
187
end
192
188
end
193
-
194
- def test_determine_key_step
195
- cmd = ::RedisClient ::Cluster ::Command . load ( @raw_clients )
196
- [
197
- { name : 'MSET' , want : 2 } ,
198
- { name : 'MGET' , want : 1 } ,
199
- { name : 'DEL' , want : 1 } ,
200
- { name : 'EVALSHA' , want : 1 }
201
- ] . each_with_index do |c , idx |
202
- msg = "Case: #{ idx } "
203
- got = cmd . send ( :determine_key_step , c [ :name ] )
204
- assert_equal ( c [ :want ] , got , msg )
205
- end
206
- end
207
-
208
- def test_extract_all_keys
209
- cmd = ::RedisClient ::Cluster ::Command . load ( @raw_clients )
210
- [
211
- { command : [ 'EVAL' , 'return ARGV[1]' , '0' , 'hello' ] , want : [ ] } ,
212
- { command : [ 'EVAL' , 'return ARGV[1]' , '3' , 'key1' , 'key2' , 'key3' , 'arg1' , 'arg2' ] , want : %w[ key1 key2 key3 ] } ,
213
- { command : [ [ 'EVAL' ] , '"return ARGV[1]"' , 0 , 'hello' ] , want : [ ] } ,
214
- { command : %w[ EVALSHA sha1 2 foo bar baz zap ] , want : %w[ foo bar ] } ,
215
- { command : %w[ MIGRATE host port key 0 5 COPY ] , want : %w[ key ] } ,
216
- { command : [ 'MIGRATE' , 'host' , 'port' , '' , '0' , '5' , 'COPY' , 'KEYS' , 'key1' ] , want : %w[ key1 ] } ,
217
- { command : [ 'MIGRATE' , 'host' , 'port' , '' , '0' , '5' , 'COPY' , 'KEYS' , 'key1' , 'key2' ] , want : %w[ key1 key2 ] } ,
218
- { command : %w[ ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 ] , want : %w[ zset1 zset2 ] } ,
219
- { command : %w[ ZUNIONSTORE out 2 zset1 zset2 WEIGHTS 2 3 ] , want : %w[ zset1 zset2 ] } ,
220
- { command : %w[ OBJECT HELP ] , want : [ ] } ,
221
- { command : %w[ MEMORY HELP ] , want : [ ] } ,
222
- { command : %w[ MEMORY USAGE key ] , want : %w[ key ] } ,
223
- { command : %w[ XREAD COUNT 2 STREAMS mystream writers 0-0 0-0 ] , want : %w[ mystream writers ] } ,
224
- { command : %w[ XREADGROUP GROUP group consumer STREAMS key id ] , want : %w[ key ] } ,
225
- { command : %w[ SET foo 1 ] , want : %w[ foo ] } ,
226
- { command : %w[ set foo 1 ] , want : %w[ foo ] } ,
227
- { command : [ [ 'SET' ] , 'foo' , 1 ] , want : %w[ foo ] } ,
228
- { command : %w[ GET foo ] , want : %w[ foo ] } ,
229
- { command : %w[ MGET foo bar baz ] , want : %w[ foo bar baz ] } ,
230
- { command : %w[ MSET foo val bar val baz val ] , want : %w[ foo bar baz ] } ,
231
- { command : %w[ BLPOP foo bar 0 ] , want : %w[ foo bar ] }
232
- ] . each_with_index do |c , idx |
233
- msg = "Case: #{ idx } "
234
- got = cmd . send ( :extract_all_keys , c [ :command ] )
235
- assert_equal ( c [ :want ] , got , msg )
236
- end
237
- end
238
189
end
239
190
end
240
191
end
0 commit comments