From 0b8705abe9e3a5c4c7bc0e3e020246de2d3a013b Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 10 Sep 2015 18:06:50 +0200 Subject: [PATCH] Do not run all tests with every single connection (if one connection works, the others are going to be fine too) --- test/auth.spec.js | 5 +++-- test/commands/hgetall.spec.js | 1 - test/helper.js | 35 ++++++++++++++++++++--------------- test/node_redis.spec.js | 7 ++++--- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/test/auth.spec.js b/test/auth.spec.js index 6eb96e0f87..d29b605f27 100644 --- a/test/auth.spec.js +++ b/test/auth.spec.js @@ -12,10 +12,11 @@ describe("client authentication", function () { }); }); - helper.allTests(function(parser, ip, args) { + helper.allTests({ + allConnections: true + }, function(parser, ip, args) { describe("using " + parser + " and " + ip, function () { - var args = config.configureClient(parser, ip); var auth = 'porkchopsandwiches'; var client = null; diff --git a/test/commands/hgetall.spec.js b/test/commands/hgetall.spec.js index e45995aa35..958e717c8c 100644 --- a/test/commands/hgetall.spec.js +++ b/test/commands/hgetall.spec.js @@ -13,7 +13,6 @@ describe("The 'hgetall' method", function () { var client; describe('regular client', function () { - var args = config.configureClient(parser, ip); beforeEach(function (done) { client = redis.createClient.apply(redis.createClient, args); diff --git a/test/helper.js b/test/helper.js index 5f4d7b4624..7e9fb5ff2a 100644 --- a/test/helper.js +++ b/test/helper.js @@ -108,22 +108,27 @@ module.exports = { } return true; }, - allTests: function (cb) { - [undefined].forEach(function (options) { // add buffer option at some point - describe(options && options.return_buffers ? "returning buffers" : "returning strings", function () { - var parsers = ['javascript']; - var protocols = ['IPv4']; - if (process.platform !== 'win32') { - parsers.push('hiredis'); - protocols.push('IPv6'); + allTests: function (options, cb) { + if (!cb) { + cb = options; + options = {}; + } + // TODO: Test all different option cases at some point (e.g. buffers) + // [undefined, { return_buffers: true }].forEach(function (config_options) { + // describe(config_options && config_options.return_buffers ? "returning buffers" : "returning strings", function () { + // }); + // }); + var parsers = ['javascript']; + var protocols = ['IPv4']; + if (process.platform !== 'win32') { + parsers.push('hiredis'); + protocols.push('IPv6', '/tmp/redis.sock'); + } + parsers.forEach(function (parser) { + protocols.forEach(function (ip, i) { + if (i === 0 || options.allConnections) { + cb(parser, ip, config.configureClient(parser, ip)); } - - parsers.forEach(function (parser) { - if (process.platform !== 'win32') cb(parser, "/tmp/redis.sock", config.configureClient(parser, "/tmp/redis.sock", options)); - protocols.forEach(function (ip) { - cb(parser, ip, config.configureClient(parser, ip, options)); - }); - }); }); }); }, diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index 38a65f8ecd..9725cce67b 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -8,7 +8,9 @@ var redis = config.redis; describe("The node_redis client", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests({ + allConnections: true + }, function(parser, ip, args) { if (args[2]) { // skip if options are undefined describe("testing parser existence", function () { @@ -624,7 +626,6 @@ describe("The node_redis client", function () { describe('defaults to true', function () { var client; - var args = config.configureClient(parser, ip); it("fires client.on('ready')", function (done) { client = redis.createClient.apply(redis.createClient, args); @@ -703,7 +704,7 @@ describe("The node_redis client", function () { if (err) return done(err); }); - return setTimeout(function(){ + return setTimeout(function() { assert.strictEqual(client.offline_queue.length, 1); return done(); }, 25);