@@ -116,49 +116,78 @@ next = function next(name) {
116
116
// Tests are run in the order they are defined, so FLUSHDB should always be first.
117
117
118
118
tests . IPV4 = function ( ) {
119
- var ipv4Client = redis . createClient ( PORT , "127.0.0.1" , { "family" : "IPv4" } ) ;
120
-
121
- ipv4Client . once ( "ready" , function start_tests ( ) {
122
- console . log ( "Connected to " + ipv4Client . host + ":" + ipv4Client . port + ", Redis server version " + ipv4Client . server_info . redis_version + "\n" ) ;
123
- console . log ( "Using reply parser " + ipv4Client . reply_parser . name ) ;
124
-
125
- ipv4Client . quit ( ) ;
126
- run_next_test ( ) ;
127
- } ) ;
128
-
129
- ipv4Client . on ( 'end' , function ( ) {
130
-
131
- } ) ;
132
-
133
- // Exit immediately on connection failure, which triggers "exit", below, which fails the test
134
- ipv4Client . on ( "error" , function ( err ) {
135
- console . error ( "client: " + err . stack ) ;
136
- process . exit ( ) ;
137
- } ) ;
119
+ var ipv4Client = redis . createClient ( PORT , "127.0.0.1" , { "family" : "IPv4" } ) ;
120
+
121
+ ipv4Client . once ( "ready" , function start_tests ( ) {
122
+ console . log ( "Connected to " + ipv4Client . address + ", Redis server version " + ipv4Client . server_info . redis_version + "\n" ) ;
123
+ console . log ( "Using reply parser " + ipv4Client . reply_parser . name ) ;
124
+
125
+ ipv4Client . quit ( ) ;
126
+ run_next_test ( ) ;
127
+ } ) ;
128
+
129
+ ipv4Client . on ( 'end' , function ( ) {
130
+
131
+ } ) ;
132
+
133
+ // Exit immediately on connection failure, which triggers "exit", below, which fails the test
134
+ ipv4Client . on ( "error" , function ( err ) {
135
+ console . error ( "client: " + err . stack ) ;
136
+ process . exit ( ) ;
137
+ } ) ;
138
138
}
139
139
140
140
tests . IPV6 = function ( ) {
141
- var ipv6Client = redis . createClient ( PORT , "::1" , { "family" : "IPv6" } ) ;
142
-
143
- ipv6Client . once ( "ready" , function start_tests ( ) {
144
- console . log ( "Connected to " + ipv6Client . host + ":" + ipv6Client . port + ", Redis server version " + ipv6Client . server_info . redis_version + "\n" ) ;
145
- console . log ( "Using reply parser " + ipv6Client . reply_parser . name ) ;
146
-
147
- ipv6Client . quit ( ) ;
148
- run_next_test ( ) ;
149
- } ) ;
150
-
151
- ipv6Client . on ( 'end' , function ( ) {
152
-
153
- } ) ;
154
-
155
- // Exit immediately on connection failure, which triggers "exit", below, which fails the test
156
- ipv6Client . on ( "error" , function ( err ) {
157
- console . error ( "client: " + err . stack ) ;
158
- process . exit ( ) ;
159
- } ) ;
141
+ if ( ! server_version_at_least ( client , [ 2 , 8 , 0 ] ) ) {
142
+ console . log ( "Skipping IPV6 for old Redis server version < 2.8.0" ) ;
143
+ return run_next_test ( ) ;
144
+ }
145
+ var ipv6Client = redis . createClient ( PORT , "::1" , { "family" : "IPv6" } ) ;
146
+
147
+ ipv6Client . once ( "ready" , function start_tests ( ) {
148
+ console . log ( "Connected to " + ipv6Client . address + ", Redis server version " + ipv6Client . server_info . redis_version + "\n" ) ;
149
+ console . log ( "Using reply parser " + ipv6Client . reply_parser . name ) ;
150
+
151
+ ipv6Client . quit ( ) ;
152
+ run_next_test ( ) ;
153
+ } ) ;
154
+
155
+ ipv6Client . on ( 'end' , function ( ) {
156
+
157
+ } ) ;
158
+
159
+ // Exit immediately on connection failure, which triggers "exit", below, which fails the test
160
+ ipv6Client . on ( "error" , function ( err ) {
161
+ console . error ( "client: " + err . stack ) ;
162
+ process . exit ( ) ;
163
+ } ) ;
160
164
}
161
165
166
+ tests . UNIX_SOCKET = function ( ) {
167
+ var unixClient = redis . createClient ( '/tmp/redis.sock' ) ;
168
+
169
+ // if this fails, check the permission of unix socket.
170
+ // unixsocket /tmp/redis.sock
171
+ // unixsocketperm 777
172
+
173
+ unixClient . once ( 'ready' , function start_tests ( ) {
174
+ console . log ( "Connected to " + unixClient . address + ", Redis server version " + unixClient . server_info . redis_version + "\n" ) ;
175
+ console . log ( "Using reply parser " + unixClient . reply_parser . name ) ;
176
+
177
+ unixClient . quit ( ) ;
178
+ run_next_test ( ) ;
179
+ } ) ;
180
+
181
+ unixClient . on ( 'end' , function ( ) {
182
+
183
+ } ) ;
184
+
185
+ // Exit immediately on connection failure, which triggers "exit", below, which fails the test
186
+ unixClient . on ( "error" , function ( err ) {
187
+ console . error ( "client: " + err . stack ) ;
188
+ process . exit ( ) ;
189
+ } ) ;
190
+ }
162
191
163
192
tests . FLUSHDB = function ( ) {
164
193
var name = "FLUSHDB" ;
@@ -610,11 +639,16 @@ tests.CLIENT_LIST = function() {
610
639
return next ( name ) ;
611
640
}
612
641
642
+ var pattern = / ^ a d d r = / ;
643
+ if ( server_version_at_least ( client , [ 2 , 8 , 12 ] ) ) {
644
+ pattern = / ^ i d = \d + a d d r = / ;
645
+ }
646
+
613
647
function checkResult ( result ) {
614
648
var lines = result . toString ( ) . split ( '\n' ) . slice ( 0 , - 1 ) ;
615
649
assert . strictEqual ( lines . length , 4 ) ;
616
650
assert ( lines . every ( function ( line ) {
617
- return line . match ( / ^ a d d r = / ) ;
651
+ return line . match ( pattern ) ;
618
652
} ) ) ;
619
653
}
620
654
@@ -683,7 +717,7 @@ tests.WATCH_TRANSACTION = function () {
683
717
684
718
685
719
tests . detect_buffers = function ( ) {
686
- var name = "detect_buffers" , detect_client = redis . createClient ( null , null , { detect_buffers : true } ) ;
720
+ var name = "detect_buffers" , detect_client = redis . createClient ( { detect_buffers : true } ) ;
687
721
688
722
detect_client . on ( "ready" , function ( ) {
689
723
// single Buffer or String
@@ -750,9 +784,9 @@ tests.detect_buffers = function () {
750
784
tests . socket_nodelay = function ( ) {
751
785
var name = "socket_nodelay" , c1 , c2 , c3 , ready_count = 0 , quit_count = 0 ;
752
786
753
- c1 = redis . createClient ( null , null , { socket_nodelay : true } ) ;
754
- c2 = redis . createClient ( null , null , { socket_nodelay : false } ) ;
755
- c3 = redis . createClient ( null , null ) ;
787
+ c1 = redis . createClient ( { socket_nodelay : true } ) ;
788
+ c2 = redis . createClient ( { socket_nodelay : false } ) ;
789
+ c3 = redis . createClient ( ) ;
756
790
757
791
function quit_check ( ) {
758
792
quit_count ++ ;
@@ -2194,7 +2228,7 @@ run_next_test = function run_next_test() {
2194
2228
} ;
2195
2229
2196
2230
client . once ( "ready" , function start_tests ( ) {
2197
- console . log ( "Connected to " + client . host + ":" + client . port + ", Redis server version " + client . server_info . redis_version + "\n" ) ;
2231
+ console . log ( "Connected to " + client . address + ", Redis server version " + client . server_info . redis_version + "\n" ) ;
2198
2232
console . log ( "Using reply parser " + client . reply_parser . name ) ;
2199
2233
2200
2234
run_next_test ( ) ;
0 commit comments