@@ -31,37 +31,36 @@ def test_load
31
31
end
32
32
end
33
33
34
- def test_parse_command_details
35
- keys = %i[ arity flags first last step ] . freeze
34
+ def test_parse_command_reply
36
35
[
37
36
{
38
37
rows : [
39
38
[ 'get' , 2 , Set [ 'readonly' , 'fast' ] , 1 , 1 , 1 , Set [ '@read' , '@string' , '@fast' ] , Set [ ] , Set [ ] , Set [ ] ] ,
40
39
[ 'set' , -3 , Set [ 'write' , 'denyoom' , 'movablekeys' ] , 1 , 1 , 1 , Set [ '@write' , '@string' , '@slow' ] , Set [ ] , Set [ ] , Set [ ] ]
41
40
] ,
42
41
want : {
43
- 'get' => { arity : 2 , flags : Set [ 'readonly' , 'fast' ] , first : 1 , last : 1 , step : 1 } ,
44
- 'set' => { arity : - 3 , flags : Set [ ' write' , 'denyoom' , 'movablekeys' ] , first : 1 , last : 1 , step : 1 }
42
+ 'get' => { first_key_position : 1 , write? : false , readonly? : true } ,
43
+ 'set' => { first_key_position : 1 , write? : true , readonly? : false }
45
44
}
46
45
} ,
47
46
{
48
47
rows : [
49
48
[ 'GET' , 2 , Set [ 'readonly' , 'fast' ] , 1 , 1 , 1 , Set [ '@read' , '@string' , '@fast' ] , Set [ ] , Set [ ] , Set [ ] ]
50
49
] ,
51
50
want : {
52
- 'get' => { arity : 2 , flags : Set [ 'readonly' , 'fast' ] , first : 1 , last : 1 , step : 1 }
51
+ 'get' => { first_key_position : 1 , write? : false , readonly? : true }
53
52
}
54
53
} ,
55
54
{ rows : [ [ ] ] , want : { } } ,
56
55
{ rows : [ ] , want : { } } ,
57
56
{ rows : nil , want : { } }
58
57
] . each_with_index do |c , idx |
59
58
msg = "Case: #{ idx } "
60
- got = ::RedisClient ::Cluster ::Command . send ( :parse_command_details , c [ :rows ] )
59
+ got = ::RedisClient ::Cluster ::Command . send ( :parse_command_reply , c [ :rows ] )
61
60
assert_equal ( c [ :want ] . size , got . size , msg )
62
61
assert_equal ( c [ :want ] . keys . sort , got . keys . sort , msg )
63
- c [ :want ] . each do |k1 , v |
64
- keys . each { | k2 | assert_equal ( v [ k2 ] , got [ k1 ] [ k2 ] , "#{ msg } : #{ k2 } " ) }
62
+ c [ :want ] . each do |k , v |
63
+ assert_equal ( v , got [ k ] . to_h , "#{ msg } : #{ k } " )
65
64
end
66
65
end
67
66
end
@@ -134,60 +133,6 @@ def test_exists?
134
133
end
135
134
end
136
135
137
- def test_pick_details
138
- keys = %i[ first_key_position write readonly ] . freeze
139
- [
140
- {
141
- details : {
142
- 'get' => { arity : 2 , flags : Set [ 'readonly' , 'fast' ] , first : 1 , last : 1 , step : 1 } ,
143
- 'set' => { arity : -3 , flags : Set [ 'write' , 'denyoom' , 'movablekeys' ] , first : 1 , last : 1 , step : 1 }
144
- } ,
145
- want : {
146
- 'get' => { first_key_position : 1 , write : false , readonly : true } ,
147
- 'set' => { first_key_position : 1 , write : true , readonly : false }
148
- }
149
- } ,
150
- { details : { } , want : { } } ,
151
- { details : nil , want : { } }
152
- ] . each_with_index do |c , idx |
153
- msg = "Case: #{ idx } "
154
- cmd = ::RedisClient ::Cluster ::Command . new ( c [ :details ] )
155
- got = cmd . send ( :pick_details , c [ :details ] )
156
- assert_equal ( c [ :want ] . size , got . size , msg )
157
- assert_equal ( c [ :want ] . keys . sort , got . keys . sort , msg )
158
- c [ :want ] . each do |k1 , v |
159
- keys . each { |k2 | assert_equal ( v [ k2 ] , got [ k1 ] [ k2 ] , "#{ msg } : #{ k2 } " ) }
160
- end
161
- end
162
- end
163
-
164
- def test_dig_details
165
- cmd = ::RedisClient ::Cluster ::Command . new (
166
- {
167
- 'get' => { arity : 2 , flags : Set [ 'readonly' , 'fast' ] , first : 1 , last : 1 , step : 1 } ,
168
- 'set' => { arity : -3 , flags : Set [ 'write' , 'denyoom' , 'movablekeys' ] , first : 1 , last : 1 , step : 1 }
169
- }
170
- )
171
- [
172
- { params : { command : %w[ SET foo 1 ] , key : :first_key_position } , want : 1 } ,
173
- { params : { command : %w[ SET foo 1 ] , key : :write } , want : true } ,
174
- { params : { command : %w[ set foo 1 ] , key : :write } , want : true } ,
175
- { params : { command : %w[ SET foo 1 ] , key : :readonly } , want : false } ,
176
- { params : { command : %w[ GET foo ] , key : :first_key_position } , want : 1 } ,
177
- { params : { command : %w[ GET foo ] , key : :write } , want : false } ,
178
- { params : { command : %w[ GET foo ] , key : :readonly } , want : true } ,
179
- { params : { command : %w[ get foo ] , key : :readonly } , want : true } ,
180
- { params : { command : %w[ UNKNOWN foo ] , key : :readonly } , want : nil } ,
181
- { params : { command : [ [ 'SET' ] , 'foo' , 1 ] , key : :write } , want : true } ,
182
- { params : { command : [ ] , key : :readonly } , want : nil } ,
183
- { params : { command : nil , key : :readonly } , want : nil }
184
- ] . each_with_index do |c , idx |
185
- msg = "Case: #{ idx } "
186
- got = cmd . send ( :dig_details , c [ :params ] [ :command ] , c [ :params ] [ :key ] )
187
- c [ :want ] . nil? ? assert_nil ( got , msg ) : assert_equal ( c [ :want ] , got , msg )
188
- end
189
- end
190
-
191
136
def test_determine_first_key_position
192
137
cmd = ::RedisClient ::Cluster ::Command . load ( @raw_clients )
193
138
[
0 commit comments