Permalink
Browse files

Merge pull request #401 from dohse/enable-client-command

Enable client command
  • Loading branch information...
2 parents ccd4a2b + 67e908a commit a5dc9898bbe86b04789529707fb3b99c04814725 @brycebaril brycebaril committed Mar 15, 2013
Showing with 41 additions and 4 deletions.
  1. +3 −3 index.js
  2. +38 −1 test.js
View
@@ -841,7 +841,7 @@ RedisClient.prototype.end = function () {
};
function Multi(client, args) {
- this.client = client;
+ this._client = client;
this.queue = [["MULTI"]];
if (Array.isArray(args)) {
this.queue = this.queue.concat(args);
@@ -1009,7 +1009,7 @@ Multi.prototype.exec = function (callback) {
args.push(obj[key]);
});
}
- this.client.send_command(command, args, function (err, reply) {
+ this._client.send_command(command, args, function (err, reply) {
if (err) {
var cur = self.queue[index];
if (typeof cur[cur.length - 1] === "function") {
@@ -1023,7 +1023,7 @@ Multi.prototype.exec = function (callback) {
}, this);
// TODO - make this callback part of Multi.prototype instead of creating it each time
- return this.client.send_command("EXEC", [], function (err, replies) {
+ return this._client.send_command("EXEC", [], function (err, replies) {
if (err) {
if (callback) {
callback(new Error(err));
View
39 test.js
@@ -493,7 +493,44 @@ tests.SCRIPT_LOAD = function() {
bclient.script("load", command, function(err, result) {
assert.strictEqual(result.toString(), commandSha);
- next(name);
+ client.multi().script("load", command).exec(function(err, result) {
+ assert.strictEqual(result[0].toString(), commandSha);
+ client.multi([['script', 'load', command]]).exec(function(err, result) {
+ assert.strictEqual(result[0].toString(), commandSha);
+ next(name);
+ });
+ });
+ });
+};
+
+tests.CLIENT_LIST = function() {
+ var name = "CLIENT_LIST";
+
+ if (!server_version_at_least(client, [2, 4, 0])) {
+ console.log("Skipping " + name + " for old Redis server version < 2.4.x");
+ return next(name);
+ }
+
+ function checkResult(result) {
+ var lines = result.toString().split('\n').slice(0, -1);
+ assert.strictEqual(lines.length, 4);
+ assert(lines.every(function(line) {
+ return line.match(/^addr=/);
+ }));
+ }
+
+ bclient.client("list", function(err, result) {
+ console.log(result.toString());
+ checkResult(result);
+ client.multi().client("list").exec(function(err, result) {
+ console.log(result.toString());
+ checkResult(result);
+ client.multi([['client', 'list']]).exec(function(err, result) {
+ console.log(result.toString());
+ checkResult(result);
+ next(name);
+ });
+ });
});
};

0 comments on commit a5dc989

Please sign in to comment.