Skip to content

Commit ba234ed

Browse files
committed
Fix tests for older versions of Redis.
1 parent 5e1cebe commit ba234ed

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

test.js

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -116,47 +116,51 @@ next = function next(name) {
116116
// Tests are run in the order they are defined, so FLUSHDB should always be first.
117117

118118
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.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-
});
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

140140
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.address + ", 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

162166
tests.UNIX_SOCKET = function () {
@@ -635,7 +639,7 @@ tests.CLIENT_LIST = function() {
635639
return next(name);
636640
}
637641

638-
var pattern = /^add=/;
642+
var pattern = /^addr=/;
639643
if ( server_version_at_least(client, [2, 8, 12])) {
640644
pattern = /^id=\d+ addr=/;
641645
}

0 commit comments

Comments
 (0)