@@ -116,49 +116,78 @@ next = function next(name) {
116116// Tests are run in the order they are defined, so FLUSHDB should always be first.
117117
118118tests . 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+ } ) ;
138138}
139139
140140tests . 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+ } ) ;
160164}
161165
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+ }
162191
163192tests . FLUSHDB = function ( ) {
164193 var name = "FLUSHDB" ;
@@ -610,11 +639,16 @@ tests.CLIENT_LIST = function() {
610639 return next ( name ) ;
611640 }
612641
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+
613647 function checkResult ( result ) {
614648 var lines = result . toString ( ) . split ( '\n' ) . slice ( 0 , - 1 ) ;
615649 assert . strictEqual ( lines . length , 4 ) ;
616650 assert ( lines . every ( function ( line ) {
617- return line . match ( / ^ a d d r = / ) ;
651+ return line . match ( pattern ) ;
618652 } ) ) ;
619653 }
620654
@@ -683,7 +717,7 @@ tests.WATCH_TRANSACTION = function () {
683717
684718
685719tests . 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 } ) ;
687721
688722 detect_client . on ( "ready" , function ( ) {
689723 // single Buffer or String
@@ -750,9 +784,9 @@ tests.detect_buffers = function () {
750784tests . socket_nodelay = function ( ) {
751785 var name = "socket_nodelay" , c1 , c2 , c3 , ready_count = 0 , quit_count = 0 ;
752786
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 ( ) ;
756790
757791 function quit_check ( ) {
758792 quit_count ++ ;
@@ -2194,7 +2228,7 @@ run_next_test = function run_next_test() {
21942228} ;
21952229
21962230client . 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" ) ;
21982232 console . log ( "Using reply parser " + client . reply_parser . name ) ;
21992233
22002234 run_next_test ( ) ;
0 commit comments