diff --git a/test/commands/client.spec.js b/test/commands/client.spec.js index 5707d1ab89..9014af862a 100644 --- a/test/commands/client.spec.js +++ b/test/commands/client.spec.js @@ -11,17 +11,25 @@ describe("The 'client' method", function () { var pattern = /addr=/; describe("using " + parser + " and " + ip, function () { - var client; + var client, client2; beforeEach(function (done) { client = redis.createClient.apply(redis.createClient, args); - client.once("connect", function () { + client.once("ready", function () { client.flushdb(done); }); }); + beforeEach(function (done) { + client2 = redis.createClient.apply(redis.createClient, args); + client2.once("ready", function () { + done(); + }); + }); + afterEach(function () { client.end(); + client2.end(); }); describe('list', function () { @@ -52,6 +60,25 @@ describe("The 'client' method", function () { }); }); }); + + describe('setname / getname', function () { + + it('sets the name', function (done) { + helper.serverVersionAtLeast.call(this, client, [2, 6, 9]); + + client.client("setname", "RUTH", helper.isString('OK')); + client2.client("setname", "RENEE", helper.isString('OK')); + client2.client("setname", "MARTIN", helper.isString('OK')); + client2.client("getname", function(err, res) { + assert.equal(res, 'MARTIN'); + }); + client.client("getname", function(err, res) { + assert.equal(res, 'RUTH'); + done(); + }); + }); + + }); }); }); }); diff --git a/test/commands/zadd.spec.js b/test/commands/zadd.spec.js new file mode 100644 index 0000000000..52f45ef378 --- /dev/null +++ b/test/commands/zadd.spec.js @@ -0,0 +1,44 @@ +'use strict'; + +var config = require("../lib/config"); +var helper = require("../helper"); +var assert = require('assert'); +var redis = config.redis; + +describe("The 'zadd' method", function () { + + helper.allTests(function(parser, ip, args) { + + describe.only("using " + parser + " and " + ip, function () { + var client; + + beforeEach(function (done) { + client = redis.createClient.apply(redis.createClient, args); + client.once("connect", function () { + client.flushdb(done); + }); + }); + + it('reports an error', function (done) { + client.zadd('infinity', [+'5t', "should not be possible"], helper.isError(done)); + }); + + it('return inf / -inf', function (done) { + client.zadd('infinity', [+Infinity, "should be inf"], helper.isNumber(1)); + client.zadd('infinity', [-Infinity, "should be negative inf"], helper.isNumber(1)); + client.zadd('infinity', [99999999999999999999999, "should not be inf"], helper.isNumber(1)); + client.zrange('infinity', 0, -1, 'WITHSCORES', function (err, res) { + assert.equal(res[5], 'inf'); + assert.equal(res[1], '-inf'); + assert.equal(res[3], '9.9999999999999992e+22'); + done(); + }); + }); + + afterEach(function () { + client.end(); + }); + }); + }); + +}); diff --git a/test/commands/zscore.spec.js b/test/commands/zscore.spec.js new file mode 100644 index 0000000000..fc5d6f37a0 --- /dev/null +++ b/test/commands/zscore.spec.js @@ -0,0 +1,35 @@ +'use strict'; + +var config = require("../lib/config"); +var helper = require("../helper"); +var assert = require('assert'); +var redis = config.redis; + +describe("The 'zscore' method", function () { + + helper.allTests(function(parser, ip, args) { + + describe("using " + parser + " and " + ip, function () { + var client; + + beforeEach(function (done) { + client = redis.createClient.apply(redis.createClient, args); + client.once("connect", function () { + client.flushdb(done); + }); + }); + + it('should return the score of member in the sorted set at key', function (done) { + client.zadd('myzset', 1, 'one'); + client.zscore('myzset', 'one', function (err, res) { + assert.equal(res, 1); + done(); + }); + }); + + afterEach(function () { + client.end(); + }); + }); + }); +}); diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index 34ba79e3dd..d8d6b0d05d 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -151,18 +151,13 @@ describe("The node_redis client", function () { }); }); - it.skip("misusing the function should eventually throw (no command)", function (done) { - var mochaListener = helper.removeMochaListener(); - - process.once('uncaughtException', function (err) { - process.on('uncaughtException', mochaListener); + it("misusing the function should eventually throw (no command)", function (done) { + client.send_command(true, 'info', function (err, res) { assert(/ERR Protocol error/.test(err.message)); assert.equal(err.command, true); assert.equal(err.code, 'ERR'); done(); }); - - client.send_command(true, 'info'); }); it("misusing the function should eventually throw (wrong args)", function (done) {