Skip to content

Some fixes #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/redis-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ var commands = [
"zcard",
"zcount",
"zincrby",
"zinter",
"zinterstore",
"zrange",
"zrangebyscore",
"zrank",
Expand All @@ -642,7 +642,7 @@ var commands = [
"zrevrange",
"zrevrank",
"zscore",
"zunion",
"zunionstore",
];

// For internal use but maybe useful in rare cases or when the client command
Expand Down
43 changes: 19 additions & 24 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ function testParseBulkReply() {
b.feed(bufferFromString("$-1\r\n"));
}

Buffer.prototype.toString=function() {
return this.utf8Slice(0,this.length);
}

function testParseMultiBulkReply() {
var a = new redisclient.ReplyParser(function (reply) {
checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply a-0");
Expand Down Expand Up @@ -508,8 +504,9 @@ function testEXPIRE() {
client.expire('expfoo', 2, expectNumber(1, "testEXPIRE"));

// subsequent expirations cannot be set.
// this is only for redis versions < 2.1.3

client.expire('expfoo', 10, expectNumber(0, "testEXPIRE"));
//client.expire('expfoo', 10, expectNumber(0, "testEXPIRE"));

if (verbose)
log("info", "Please wait while a test key expires ...");
Expand Down Expand Up @@ -1324,33 +1321,31 @@ function testZINCRBY() {
client.zincrby('z0', 1, 'a', expectNumber(2, "testZINCRBY"));
}

// This really should be called ZINTERSTORE.

function testZINTER() {
client.zadd('z0', 1, 'a', expectNumber(1, "testZINTER"));
client.zadd('z0', 2, 'b', expectNumber(1, "testZINTER"));
client.zadd('z1', 3, 'a', expectNumber(1, "testZINTER"));
client.zinter('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(1, "testZINTER"));
function testZINTERSTORE() {
client.zadd('z0', 1, 'a', expectNumber(1, "testZINTERSTORE"));
client.zadd('z0', 2, 'b', expectNumber(1, "testZINTERSTORE"));
client.zadd('z1', 3, 'a', expectNumber(1, "testZINTERSTORE"));
client.zinterstore('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(1, "testZINTERSTORE"));
client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {
if (err) assert.fail(err, "testZINTER");
if (err) assert.fail(err, "testZINTERSTORE");
redisclient.convertMultiBulkBuffersToUTF8Strings(members);
checkDeepEqual(members, [ 'a', 4 ], "testZINTER"); // score=1+3
checkDeepEqual(members, [ 'a', 4 ], "testZINTERSTORE"); // score=1+3
});
}

function testZUNION() {
client.zadd('z0', 1, 'a', expectNumber(1, "testZUNION"));
client.zadd('z0', 2, 'b', expectNumber(1, "testZUNION"));
client.zadd('z1', 3, 'a', expectNumber(1, "testZUNION"));
client.zunion('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(2, "testZUNION"));
function testZUNIONSTORE() {
client.zadd('z0', 1, 'a', expectNumber(1, "testZUNIONSTORE"));
client.zadd('z0', 2, 'b', expectNumber(1, "testZUNIONSTORE"));
client.zadd('z1', 3, 'a', expectNumber(1, "testZUNIONSTORE"));
client.zunionstore('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(2, "testZUNIONSTORE"));
client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {
if (err) assert.fail(err, "testZUNION");
if (err) assert.fail(err, "testZUNIONSTORE");
redisclient.convertMultiBulkBuffersToUTF8Strings(members);
check(members.length % 2 == 0, "testZUNION");
check(members.length % 2 == 0, "testZUNIONSTORE");
var set = {};
for (var i=0; i<members.length; i += 2)
set[members[i]] = members[i + 1];
checkDeepEqual(set, { a:4, b:2 }, "testZUNION"); // a's score=1+3
checkDeepEqual(set, { a:4, b:2 }, "testZUNIONSTORE"); // a's score=1+3
});
}

Expand Down Expand Up @@ -1725,7 +1720,7 @@ var allTestFunctions = [
testZCARD,
testZCOUNT,
testZINCRBY,
testZINTER,
testZINTERSTORE,
testZRANGE,
testZRANGEBYSCORE,
testZRANK,
Expand All @@ -1735,7 +1730,7 @@ var allTestFunctions = [
testZREVRANGE,
testZREVRANK,
testZSCORE,
testZUNION,
testZUNIONSTORE,
];

// Check buffer resizing of input buffer by loading a "large" data and reading
Expand Down