From 1ae280dcec16cfc8ebb52a162468059224fec9f3 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 1 Sep 2015 21:47:15 +0200 Subject: [PATCH] Fix some tests and deactivate broken ones --- test/commands/hmget.spec.js | 3 +-- test/commands/mset.spec.js | 31 ++++++----------------- test/commands/set.spec.js | 22 ---------------- test/commands/setnx.spec.js | 1 - test/helper.js | 2 +- test/node_redis.spec.js | 50 +++++-------------------------------- 6 files changed, 15 insertions(+), 94 deletions(-) diff --git a/test/commands/hmget.spec.js b/test/commands/hmget.spec.js index 1b5387d..af673bf 100644 --- a/test/commands/hmget.spec.js +++ b/test/commands/hmget.spec.js @@ -18,8 +18,7 @@ describe("The 'hmget' method", function () { client.once("error", done); client.once("connect", function () { client.flushdb(); - client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value"}, helper.isString('OK')); - return done(); + client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value"}, helper.isString('OK', done)); }); }); diff --git a/test/commands/mset.spec.js b/test/commands/mset.spec.js index e834871..2ef9726 100644 --- a/test/commands/mset.spec.js +++ b/test/commands/mset.spec.js @@ -60,9 +60,13 @@ describe("The 'mset' method", function () { describe("and a callback is specified", function () { describe("with valid parameters", function () { it("sets the value correctly", function (done) { - client.mset(key, value, key2, value2); - client.get(key, helper.isString(value)); - client.get(key2, helper.isString(value2, done)); + client.mset(key, value, key2, value2, function(err) { + if (err) { + return done(err); + } + client.get(key, helper.isString(value)); + client.get(key2, helper.isString(value2, done)); + }); }); }); @@ -75,14 +79,6 @@ describe("The 'mset' method", function () { }); }); - describe("with undefined 'key' and defined 'value' parameters", function () { - it("reports an error", function () { - client.mset(undefined, value, undefined, value2, function (err, res) { - helper.isError()(err, null); - done(); - }); - }); - }); }); describe("and no callback is specified", function () { @@ -108,19 +104,6 @@ describe("The 'mset' method", function () { client.mset(); }); }); - - describe("with undefined 'key' and defined 'value' parameters", function () { - it("throws an error", function () { - var mochaListener = helper.removeMochaListener(); - - process.once('uncaughtException', function (err) { - process.on('uncaughtException', mochaListener); - helper.isError()(err, null); - }); - - client.mset(undefined, value, undefined, value2); - }); - }); }); }); }); diff --git a/test/commands/set.spec.js b/test/commands/set.spec.js index a6e49d0..1674051 100644 --- a/test/commands/set.spec.js +++ b/test/commands/set.spec.js @@ -76,15 +76,6 @@ describe("The 'set' method", function () { }); }); }); - - describe("with undefined 'key' and defined 'value' parameters", function () { - it("reports an error", function () { - client.set(undefined, value, function (err, res) { - helper.isError()(err, null); - done(); - }); - }); - }); }); describe("and no callback is specified", function () { @@ -132,19 +123,6 @@ describe("The 'set' method", function () { }, 100); }); }); - - describe("with undefined 'key' and defined 'value' parameters", function () { - it("throws an error", function () { - var mochaListener = helper.removeMochaListener(); - - process.once('uncaughtException', function (err) { - process.on('uncaughtException', mochaListener); - helper.isError()(err, null); - }); - - client.set(undefined, value); - }); - }); }); }); }); diff --git a/test/commands/setnx.spec.js b/test/commands/setnx.spec.js index 20a5759..8e426d6 100644 --- a/test/commands/setnx.spec.js +++ b/test/commands/setnx.spec.js @@ -28,7 +28,6 @@ describe("The 'setnx' method", function () { client.set('foo', 'bar', helper.isString('OK')); client.setnx('foo', 'banana', helper.isNumber(0)); client.get('foo', helper.isString('bar', done)); - return done(); }); afterEach(function () { diff --git a/test/helper.js b/test/helper.js index 36878f6..aec927c 100644 --- a/test/helper.js +++ b/test/helper.js @@ -58,7 +58,7 @@ module.exports = { }, isError: function (done) { return function (err, results) { - assert.notEqual(err, null, "err is null, but an error is expected here."); + assert(err instanceof Error, "err is not instance of 'Error', but an error is expected here."); if (done) return done(); }; }, diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index ea792b9..7b90fd3 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -188,54 +188,16 @@ describe("The node_redis client", function () { // Does not pass. // "Connection in subscriber mode, only subscriber commands may be used" it("reconnects, unsubscribes, and can retrieve the pre-existing data", function (done) { - client.on("reconnecting", function on_recon(params) { - client.on("ready", function on_connect() { - client.unsubscribe(helper.isNotError()); - - client.on('unsubscribe', function (channel, count) { - // we should now be out of subscriber mode. - client.set('foo', 'bar', helper.isNumber(1)); - return done(); - }); - }); - }); + client.on("ready", function on_connect() { + client.unsubscribe(helper.isNotError()); - client.set("recon 1", "one"); - client.subscribe("recon channel", function (err, res) { - // Do not do this in normal programs. This is to simulate the server closing on us. - // For orderly shutdown in normal programs, do client.quit() - client.stream.destroy(); - }); - }); - - it("remains subscribed", function () { - var client2 = redis.createClient.apply(redis.createClient, args); - - client.on("reconnecting", function on_recon(params) { - client.on("ready", function on_connect() { - async.parallel([function (cb) { - client.on("message", function (channel, message) { - try { - helper.isString("recon channel")(null, channel); - helper.isString("a test message")(null, message); - } catch (err) { - cb(err); - } - }); - - client2.subscribe("recon channel", function (err, res) { - if (err) { - cb(err); - return; - } - client2.publish("recon channel", "a test message"); - }); - }], function (err, results) { - done(err); - }); + client.on('unsubscribe', function (channel, count) { + // we should now be out of subscriber mode. + client.set('foo', 'bar', helper.isString('OK', done)); }); }); + client.set("recon 1", "one"); client.subscribe("recon channel", function (err, res) { // Do not do this in normal programs. This is to simulate the server closing on us. // For orderly shutdown in normal programs, do client.quit()