@@ -53,16 +53,16 @@ def test_parse_command_reply
5353 [ 'set' , -3 , Set [ 'write' , 'denyoom' , 'movablekeys' ] , 1 , -1 , 2 , Set [ '@write' , '@string' , '@slow' ] , Set [ ] , Set [ ] , Set [ ] ]
5454 ] ,
5555 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 }
5858 }
5959 } ,
6060 {
6161 rows : [
6262 [ 'GET' , 2 , Set [ 'readonly' , 'fast' ] , 1 , -1 , 1 , Set [ '@read' , '@string' , '@fast' ] , Set [ ] , Set [ ] , Set [ ] ]
6363 ] ,
6464 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 }
6666 }
6767 } ,
6868 { rows : [ [ ] ] , want : { } } ,
@@ -87,8 +87,6 @@ def test_extract_first_key
8787 { command : %w[ GET foo{bar}baz ] , want : 'foo{bar}baz' } ,
8888 { command : %w[ MGET foo bar baz ] , want : 'foo' } ,
8989 { command : %w[ UNKNOWN foo bar ] , want : '' } ,
90- { command : [ [ 'GET' ] , 'foo' ] , want : 'foo' } ,
91- { command : [ 'GET' , [ 'foo' ] ] , want : 'foo' } ,
9290 { command : [ ] , want : '' } ,
9391 { command : nil , want : '' }
9492 ] . each_with_index do |c , idx |
@@ -151,7 +149,6 @@ def test_determine_first_key_position
151149 cmd = ::RedisClient ::Cluster ::Command . load ( @raw_clients )
152150 [
153151 { command : %w[ EVAL "return ARGV[1]" 0 hello ] , want : 3 } ,
154- { command : [ [ 'EVAL' ] , '"return ARGV[1]"' , 0 , 'hello' ] , want : 3 } ,
155152 { command : %w[ EVALSHA sha1 2 foo bar baz zap ] , want : 3 } ,
156153 { command : %w[ MIGRATE host port key 0 5 COPY ] , want : 3 } ,
157154 { command : [ 'MIGRATE' , 'host' , 'port' , '' , '0' , '5' , 'COPY' , 'KEYS' , 'key' ] , want : 8 } ,
@@ -164,7 +161,7 @@ def test_determine_first_key_position
164161 { command : %w[ XREADGROUP GROUP group consumer STREAMS key id ] , want : 5 } ,
165162 { command : %w[ SET foo 1 ] , want : 1 } ,
166163 { command : %w[ set foo 1 ] , want : 1 } ,
167- { command : [ [ 'SET' ] , 'foo' , 1 ] , want : 1 } ,
164+ { command : [ 'SET' , 'foo' , 1 ] , want : 1 } ,
168165 { command : %w[ GET foo ] , want : 1 }
169166 ] . each_with_index do |c , idx |
170167 msg = "Case: #{ idx } "
@@ -179,62 +176,16 @@ def test_determine_optional_key_position
179176 { params : { command : %w[ XREAD COUNT 2 STREAMS mystream writers 0-0 0-0 ] , option_name : 'streams' } , want : 4 } ,
180177 { params : { command : %w[ XREADGROUP GROUP group consumer STREAMS key id ] , option_name : 'streams' } , want : 5 } ,
181178 { 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 } ,
183180 { params : { command : %w[ FOO BAR BAZ ] , option_name : 'BAR' } , want : 2 } ,
184181 { 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 }
187183 ] . each_with_index do |c , idx |
188184 msg = "Case: #{ idx } "
189185 got = cmd . send ( :determine_optional_key_position , c [ :params ] [ :command ] , c [ :params ] [ :option_name ] )
190186 assert_equal ( c [ :want ] , got , msg )
191187 end
192188 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
238189 end
239190 end
240191end
0 commit comments