@@ -22,14 +22,15 @@ def teardown
22
22
end
23
23
24
24
def wait_for_replication
25
- @client . call ( 'WAIT' , '1' , ( TEST_TIMEOUT_SEC * 1000 ) . to_i . to_s )
25
+ @client . call ( 'WAIT' , TEST_REPLICA_SIZE , ( TEST_TIMEOUT_SEC * 1000 ) . to_i )
26
26
end
27
27
28
28
def test_inspect
29
29
assert_match ( /^#<RedisClient::Cluster [0-9., :]*>$/ , @client . inspect )
30
30
end
31
31
32
32
def test_call
33
+ assert_raises ( ArgumentError ) { @client . call }
33
34
( 0 ..9 ) . each do |i |
34
35
assert_equal ( 'OK' , @client . call ( 'SET' , "key#{ i } " , i ) , "Case: SET: key#{ i } " )
35
36
wait_for_replication
@@ -38,6 +39,7 @@ def test_call
38
39
end
39
40
40
41
def test_call_once
42
+ assert_raises ( ArgumentError ) { @client . call_once }
41
43
( 0 ..9 ) . each do |i |
42
44
assert_equal ( 'OK' , @client . call_once ( 'SET' , "key#{ i } " , i ) , "Case: SET: key#{ i } " )
43
45
wait_for_replication
@@ -46,6 +48,7 @@ def test_call_once
46
48
end
47
49
48
50
def test_blocking_call
51
+ assert_raises ( ArgumentError ) { @client . blocking_call ( TEST_TIMEOUT_SEC ) }
49
52
@client . call ( *%w[ RPUSH foo hello ] )
50
53
@client . call ( *%w[ RPUSH foo world ] )
51
54
wait_for_replication
@@ -140,6 +143,50 @@ def test_pubsub
140
143
def test_close
141
144
assert_nil ( @client . close )
142
145
end
146
+
147
+ def test_dedicated_commands
148
+ ( 0 ..9 ) . each { |i | @client . call ( 'SET' , "key#{ i } " , i ) }
149
+ [
150
+ { command : %w[ ACL HELP ] , is_a : Array } ,
151
+ { command : %w[ WAIT 1 1 ] , want : TEST_NUMBER_OF_REPLICAS } ,
152
+ { command : %w[ KEYS * ] , want : ( 0 ..9 ) . map { |i | "key#{ i } " } } ,
153
+ { command : %w[ DBSIZE ] , want : ( 0 ..9 ) . size } ,
154
+ { command : %w[ SCAN ] , is_a : Array } ,
155
+ { command : %w[ LASTSAVE ] , is_a : Array } ,
156
+ { command : %w[ ROLE ] , is_a : Array } ,
157
+ { command : %w[ CONFIG RESETSTAT ] , want : 'OK' } ,
158
+ { command : %w[ CONFIG GET maxmemory ] , is_a : Hash } ,
159
+ { command : %w[ CLIENT LIST ] , is_a : Array } ,
160
+ { command : %w[ CLIENT PAUSE 100 ] , want : 'OK' } ,
161
+ { command : %w[ CLIENT INFO ] , is_a : String } ,
162
+ { command : %w[ CLUSTER SET-CONFIG-EPOCH 0 ] , error : ::RedisClient ::Cluster ::OrchestrationCommandNotSupported } ,
163
+ { command : %w[ CLUSTER SAVECONFIG ] , want : 'OK' } ,
164
+ { command : %w[ CLUSTER NODES ] , is_a : String } ,
165
+ { command : %w[ READONLY ] , error : ::RedisClient ::Cluster ::OrchestrationCommandNotSupported } ,
166
+ { command : %w[ MEMORY STATS ] , is_a : Array } ,
167
+ { command : %w[ MEMORY PURGE ] , want : 'OK' } ,
168
+ { command : %w[ MEMORY USAGE key0 ] , is_a : Integer } ,
169
+ { command : %w[ SCRIPT DEBUG NO ] , want : 'OK' } ,
170
+ { command : %w[ SCRIPT FLUSH ] , want : 'OK' } ,
171
+ { command : %w[ SCRIPT EXISTS b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c ] , want : [ 0 ] } ,
172
+ { command : %w[ PUBSUB CHANNELS test-channel* ] , want : [ ] } ,
173
+ { command : %w[ PUBSUB NUMSUB test-channel ] , want : { 'test-channel' => 0 } } ,
174
+ { command : %w[ PUBSUB NUMPAT ] , want : 0 } ,
175
+ { command : %w[ PUBSUB HELP ] , is_a : Array } ,
176
+ { command : %w[ MULTI ] , error : ::RedisClient ::Cluster ::AmbiguousNodeError } ,
177
+ { command : %w[ FLUSHDB ] , want : 'OK' }
178
+ ] . each do |c |
179
+ msg = "Case: #{ c [ :command ] . join ( ' ' ) } "
180
+ got = -> { @client . call ( *c [ :command ] ) }
181
+ if c . key? ( :error )
182
+ assert_raises ( c [ :error ] , msg , &got )
183
+ elsif c . key? ( :is_a )
184
+ assert_instance_of ( c [ :is_a ] , got . call , msg )
185
+ else
186
+ assert_equal ( c [ :want ] , got . call , msg )
187
+ end
188
+ end
189
+ end
143
190
end
144
191
145
192
class PrimaryOnly < Minitest ::Test
0 commit comments