Browse Source

Fix some tests and deactivate broken ones

greenkeeper-update-all
Ruben Bridgewater 9 years ago
parent
commit
1ae280dcec
  1. 3
      test/commands/hmget.spec.js
  2. 31
      test/commands/mset.spec.js
  3. 22
      test/commands/set.spec.js
  4. 1
      test/commands/setnx.spec.js
  5. 2
      test/helper.js
  6. 50
      test/node_redis.spec.js

3
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));
});
});

31
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);
});
});
});
});
});

22
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);
});
});
});
});
});

1
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 () {

2
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();
};
},

50
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()

Loading…
Cancel
Save