Browse Source

Merge pull request #876 from NodeRedis/test-tweak

a couple tweaks to get the test suite running on my old MacBook
greenkeeper-update-all
Benjamin E. Coe 9 years ago
parent
commit
2fc54ece57
  1. 6
      test/helper.js
  2. 69
      test/node_redis.spec.js

6
test/helper.js

@ -159,11 +159,11 @@ module.exports = {
killConnection: function (client) {
// Change the connection option to a non existing one and destroy the stream
client.connectionOption = {
port: 6370,
host: '127.0.0.2',
port: 65535,
host: '127.0.0.1',
family: 4
};
client.address = '127.0.0.2:6370';
client.address = '127.0.0.1:65535';
client.stream.destroy();
}
};

69
test/node_redis.spec.js

@ -214,7 +214,7 @@ describe("The node_redis client", function () {
var client = redis.createClient();
client.quit(function() {
client.get("foo", function(err, res) {
assert.strictEqual(err.message, 'Redis connection gone from end event.');
assert(err.message.indexOf('Redis connection gone') !== -1);
assert.strictEqual(client.offline_queue.length, 0);
done();
});
@ -355,42 +355,41 @@ describe("The node_redis client", function () {
}
});
});
});
describe('monitor', function () {
it('monitors commands on all other redis clients', function (done) {
helper.serverVersionAtLeast.call(this, client, [2, 6, 0]);
var monitorClient = redis.createClient.apply(redis.createClient, args);
var responses = [];
monitorClient.monitor(function (err, res) {
client.mget("some", "keys", "foo", "bar");
client.set("json", JSON.stringify({
foo: "123",
bar: "sdflkdfsjk",
another: false
}));
});
monitorClient.on("monitor", function (time, args) {
responses.push(args);
if (responses.length === 2) {
assert.strictEqual(5, responses[0].length);
assert.strictEqual("mget", responses[0][0]);
assert.strictEqual("some", responses[0][1]);
assert.strictEqual("keys", responses[0][2]);
assert.strictEqual("foo", responses[0][3]);
assert.strictEqual("bar", responses[0][4]);
assert.strictEqual(3, responses[1].length);
assert.strictEqual("set", responses[1][0]);
assert.strictEqual("json", responses[1][1]);
assert.strictEqual('{"foo":"123","bar":"sdflkdfsjk","another":false}', responses[1][2]);
monitorClient.quit(done);
}
});
describe('monitor', function () {
it('monitors commands on all other redis clients', function (done) {
helper.serverVersionAtLeast.call(this, client, [2, 6, 0]);
var monitorClient = redis.createClient.apply(redis.createClient, args);
var responses = [];
monitorClient.monitor(function (err, res) {
client.mget("some", "keys", "foo", "bar");
client.set("json", JSON.stringify({
foo: "123",
bar: "sdflkdfsjk",
another: false
}));
});
monitorClient.on("monitor", function (time, args) {
responses.push(args);
if (responses.length === 2) {
assert.strictEqual(5, responses[0].length);
assert.strictEqual("mget", responses[0][0]);
assert.strictEqual("some", responses[0][1]);
assert.strictEqual("keys", responses[0][2]);
assert.strictEqual("foo", responses[0][3]);
assert.strictEqual("bar", responses[0][4]);
assert.strictEqual(3, responses[1].length);
assert.strictEqual("set", responses[1][0]);
assert.strictEqual("json", responses[1][1]);
assert.strictEqual('{"foo":"123","bar":"sdflkdfsjk","another":false}', responses[1][2]);
monitorClient.quit(done);
}
});
});
});
describe('idle', function () {
@ -619,7 +618,7 @@ describe("The node_redis client", function () {
client.set('baz', 13);
client.set('foo', 'bar', function(err, result) {
assert(i, 3);
assert('Redis connection gone from error event', err.message);
assert(err);
assert.strictEqual(client.offline_queue.length, 0);
});
});

Loading…
Cancel
Save