Skip to content

Instantly share code, notes, and snippets.

@nikhilm
Created April 18, 2010 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhilm/369987 to your computer and use it in GitHub Desktop.
Save nikhilm/369987 to your computer and use it in GitHub Desktop.
DEBUG: [CONNECTED]
[INFO] Testing AUTH
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing BGSAVE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing BLPOP
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>blpop<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *4<CRLF>$5<CRLF>blpop<CRLF>$5<CRLF>list1<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>blpop<CRLF>$5<CRLF>listX<CRLF>$1<CRLF>1<CRLF>
[INFO] Testing BRPOP
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>DEF<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>brpop<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *4<CRLF>$5<CRLF>brpop<CRLF>$5<CRLF>list1<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>brpop<CRLF>$5<CRLF>listX<CRLF>$1<CRLF>1<CRLF>
[INFO] Testing DBSIZE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *1<CRLF>$6<CRLF>dbsize<CRLF>
[INFO] Testing DECR
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>decr<CRLF>$7<CRLF>counter<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>decr<CRLF>$7<CRLF>counter<CRLF>
[INFO] Testing DECRBY
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>decrby<CRLF>$7<CRLF>counter<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>decrby<CRLF>$7<CRLF>counter<CRLF>$1<CRLF>2<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>decrby<CRLF>$7<CRLF>counter<CRLF>$2<CRLF>-3<CRLF>
[INFO] Testing DEL
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>goo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>del<CRLF>$3<CRLF>goo<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>goo<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>del<CRLF>$3<CRLF>goo<CRLF>
[INFO] Testing EXISTS
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$4<CRLF>foo2<CRLF>
[INFO] Testing EXPIRE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$6<CRLF>expfoo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>expire<CRLF>$6<CRLF>expfoo<CRLF>$1<CRLF>2<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>expire<CRLF>$6<CRLF>expfoo<CRLF>$1<CRLF>2<CRLF>
[INFO] Testing FLUSHALL
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing FLUSHDB
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing GET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>buz<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>get<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>get<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$13<CRLF>largetestfile<CRLF>$62863<CRLF>#!/usr/bin/env node<LF><LF>/*<LF> Redis client for Node.js -- tests<LF><LF> Copyright (C) 2010 Fictorial LLC.<LF><LF> Permission is hereby granted, free of charge, to any person obtaining<LF> a copy of this software and associated documentation files (the<LF> "Software"), to deal in the Software without restriction, including without<LF> limitation the rights to use, copy, modify, merge, publish, distribute,<LF> sublicense, and/or sell copies of the Software, and to permit persons to<LF> whom the Software is furnished to do so, subject to the following<LF> conditions:<LF><LF> The above copyright notice and this permission notice shall be included in<LF> all copies or substantial portions of the Software.<LF><LF> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<LF> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<LF> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<LF> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<LF> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<LF> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<LF> DEALINGS IN THE SOFTWARE.<LF>*/<LF><LF>// http://github.com/fictorial/redis-node-client<LF>// Brian Hammond <brian at fictorial dot com><LF><LF>// NOTE: this test suite uses databases 14 and 15 for test purposes! <LF>// Make sure your Redis instance has at least this many databases; the default has 16.<LF>// These databases will be flushed these databases at the start of each test run. <LF>// If you want to use a different database number, update TEST_DB_NUMBER* below.<LF><LF>// NOTE: each test is responsible for configuring the dataset needed to <LF>// run that test. There are no "fixtures" or similar.<LF><LF>var TEST_DB_NUMBER = 15,<LF> TEST_DB_NUMBER_FOR_MOVE = 14;<LF><LF>var MAX_TEST_TIME = 20000;<LF><LF>var sys = require("sys"),<LF> assert = require("assert"),<LF> redisclient = require("../lib/redis-client"),<LF> fs = require("fs"),<LF> Buffer = require("buffer").Buffer;<LF><LF>var verbose = process.argv.indexOf("-v") != -1;<LF>var quiet = process.argv.indexOf("-q") != -1;<LF><LF>redisclient.debugMode = verbose && !quiet;<LF><LF>function log(level, msg) {<LF> var colorsForLevel = { info:37, warn:33, error:31 };<LF> sys.error("\033[" + colorsForLevel[level || 'info'] + "m[" + <LF> level.toUpperCase() + "] " + msg + "\033[0m");<LF>}<LF><LF>function showContext(context) {<LF> sys.error("\n");<LF> log('error', context + " FAILED!");<LF> sys.error("");<LF>}<LF><LF>// These wrappers around the assert module exist because we generate functions<LF>// to test for expected conditions which lose context, and assert's functions<LF>// use the 'message' in place of the failed condition.<LF><LF>function checkEqual(actual, expected, context) {<LF> try {<LF> assert.equal(actual, expected);<LF> } catch (e) {<LF> showContext(context);<LF> throw e;<LF> }<LF>}<LF><LF>function check(what, context) {<LF> try {<LF> assert.ok(what);<LF> } catch (e) {<LF> showContext(context);<LF> throw e;<LF> }<LF>}<LF><LF>function checkDeepEqual(actual, expected, context) {<LF> try {<LF> assert.deepEqual(actual, expected);<LF> } catch (e) {<LF> showContext(context);<LF> throw e;<LF> }<LF>}<LF><LF>// Redis' protocol returns +OK for some operations to mean "true" or "success".<LF>// The client converts this into a boolean with value true.<LF><LF>function expectOK(context) {<LF> return function (err, truthiness) {<LF> if (err) assert.fail(err, context);<LF> checkEqual(typeof(truthiness), 'boolean', context);<LF> checkEqual(truthiness, true, context);<LF> };<LF>}<LF><LF>function maybeAsNumber(str) {<LF> var value = parseInt(str, 10);<LF><LF> if (isNaN(value)) <LF> value = parseFloat(str);<LF><LF> if (isNaN(value)) <LF> return str;<LF><LF> return value;<LF>}<LF><LF>function expectNumber(expectedValue, context) {<LF> return function (err, reply) {<LF> if (err) assert.fail(err, context);<LF> var value = maybeAsNumber(reply);<LF> checkEqual(value, expectedValue, context);<LF> };<LF>}<LF><LF>function clearTestDatabasesBeforeEachTest() {<LF> client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK("select"));<LF> client.flushdb(expectOK("flushdb"));<LF><LF> client.select(TEST_DB_NUMBER, expectOK("select"));<LF> client.flushdb(expectOK("flushdb"));<LF>}<LF><LF>function bufferFromString(str, encoding) {<LF> var enc = encoding || 'utf8';<LF> var buf = new Buffer(str.length);<LF> switch (enc) {<LF> case 'utf8': buf.utf8Write(str); break;<LF> case 'ascii': buf.asciiWrite(str); break;<LF> case 'binary': buf.binaryWrite(str); break;<LF> default: <LF> assert.fail("unknown encoding: " + encoding);<LF> }<LF> return buf;<LF>}<LF><LF>function testParseBulkReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.BULK, "testParseBulkReply a-0");<LF> check(reply.value instanceof Buffer, "testParseBulkReply a-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), "FOOBAR", "testParseBulkReply a-2");<LF> });<LF> a.feed(bufferFromString("$6\r\nFOOBAR\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.BULK, "testParseBulkReply b-0");<LF> checkEqual(reply.value, null, "testParseBulkReply b-1");<LF> });<LF> b.feed(bufferFromString("$-1\r\n"));<LF>}<LF><LF>Buffer.prototype.toString=function() {<LF> return this.utf8Slice(0,this.length);<LF>}<LF><LF>function testParseMultiBulkReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply a-0");<LF> check(reply.value instanceof Array, "testParseMultiBulkReply a-1");<LF> checkEqual(reply.value.length, 4, "testParseMultiBulkReply a-2");<LF> check(reply.value[0].type === redisclient.BULK, "testParseMultiBulkReply a-3");<LF> check(reply.value[1].type === redisclient.BULK, "testParseMultiBulkReply a-4");<LF> check(reply.value[2].type === redisclient.BULK, "testParseMultiBulkReply a-5");<LF> check(reply.value[3].type === redisclient.BULK, "testParseMultiBulkReply a-6");<LF> check(reply.value[0].value instanceof Buffer, "testParseMultiBulkReply a-7");<LF> check(reply.value[1].value instanceof Buffer, "testParseMultiBulkReply a-8");<LF> check(reply.value[2].value instanceof Buffer, "testParseMultiBulkReply a-9");<LF> check(reply.value[3].value instanceof Buffer, "testParseMultiBulkReply a-10");<LF> checkEqual(reply.value[0].value.length, 3, "testParseMultiBulkReply a-11");<LF> checkEqual(reply.value[1].value.length, 3, "testParseMultiBulkReply a-12");<LF> checkEqual(reply.value[2].value.length, 5, "testParseMultiBulkReply a-13");<LF> checkEqual(reply.value[3].value.length, 6, "testParseMultiBulkReply a-14");<LF> checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', "testParseMultiBulkReply a-15");<LF> checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), 'BAR', "testParseMultiBulkReply a-16");<LF> checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'HELLO', "testParseMultiBulkReply a-17");<LF> checkEqual(reply.value[3].value.utf8Slice(0, reply.value[3].value.length), 'WORLD!', "testParseMultiBulkReply a-18");<LF> });<LF> a.feed(bufferFromString("*4\r\n$3\r\nFOO\r\n$3\r\nBAR\r\n$5\r\nHELLO\r\n$6\r\nWORLD!\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply b-0");<LF> checkEqual(reply.value, null, "testParseMultiBulkReply b-1");<LF> });<LF> b.feed(bufferFromString("*-1\r\n"));<LF><LF> var c = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply c-0");<LF> check(reply.value instanceof Array, "testParseMultiBulkReply c-1");<LF> checkEqual(reply.value.length, 3, "testParseMultiBulkReply c-2");<LF> check(reply.value[0].type === redisclient.BULK, "testParseMultiBulkReply c-3");<LF> check(reply.value[1].type === redisclient.BULK, "testParseMultiBulkReply c-4");<LF> check(reply.value[2].type === redisclient.BULK, "testParseMultiBulkReply c-5");<LF> checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', "testParseMultiBulkReply c-6");<LF> checkEqual(reply.value[1].value, null, "testParseMultiBulkReply c-7");<LF> checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'BARZ', "testParseMultiBulkReply c-8");<LF> });<LF> c.feed(bufferFromString("*3\r\n$3\r\nFOO\r\n$-1\r\n$4\r\nBARZ\r\n"));<LF><LF> // Test with a multi-bulk reply containing a subreply that's non-bulk<LF> // but an inline/integer reply instead.<LF><LF> var d = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply d-0");<LF> check(reply.value instanceof Array, "testParseMultiBulkReply d-1");<LF> checkEqual(reply.value.length, 3, "testParseMultiBulkReply d-2");<LF> check(reply.value[0].type === redisclient.BULK, "testParseMultiBulkReply d-3");<LF> check(reply.value[1].type === redisclient.BULK, "testParseMultiBulkReply d-4");<LF> check(reply.value[2].type === redisclient.INTEGER, "testParseMultiBulkReply d-5");<LF> check(reply.value[0].value instanceof Buffer, "testParseMultiBulkReply d-6");<LF> check(reply.value[1].value instanceof Buffer, "testParseMultiBulkReply d-7");<LF> checkEqual(typeof(reply.value[2].value), "number", "testParseMultiBulkReply d-8");<LF> checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'subscribe', "testParseMultiBulkReply d-9");<LF> checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), '#redis', "testParseMultiBulkReply d-10");<LF> checkEqual(reply.value[2].value, 1, "testParseMultiBulkReply d-11");<LF> });<LF> d.feed(bufferFromString("*3\r\n$9\r\nsubscribe\r\n$6\r\n#redis\r\n:1\r\n*3\r\n$7\r\nmessage\r\n"));<LF><LF> var e = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply e-0");<LF> checkEqual(reply.value, null, "testParseMultiBulkReply e-1");<LF> });<LF> e.feed(bufferFromString("*0\r\n"));<LF>}<LF><LF>function testParseInlineReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> // maybeConvertReplyValue is called by redisclient for non-test calls<LF> reply.value = redisclient.maybeConvertReplyValue_('N/A', reply); <LF> checkEqual(reply.type, redisclient.INLINE, "testParseInlineReply a-0");<LF> checkEqual(typeof(reply.value), 'boolean', "testParseInlineReply a-1");<LF> checkEqual(reply.value, true, "testParseInlineReply a-2");<LF> });<LF> a.feed(bufferFromString("+OK\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.INLINE, "testParseInlineReply b-0");<LF> check(reply.value instanceof Buffer, "testParseInlineReply b-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), 'WHATEVER', "testParseInlineReply b-2");<LF> });<LF> b.feed(bufferFromString("+WHATEVER\r\n"));<LF>}<LF><LF>function testParseIntegerReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.INTEGER, "testParseIntegerReply a-0");<LF> checkEqual(typeof(reply.value), 'number', "testParseIntegerReply a-1");<LF> checkEqual(reply.value, -1, "testParseIntegerReply a-2");<LF> });<LF> a.feed(bufferFromString(":-1\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.INTEGER, "testParseIntegerReply b-0");<LF> checkEqual(typeof(reply.value), 'number', "testParseIntegerReply b-1");<LF> checkEqual(reply.value, 1000, "testParseIntegerReply b-2");<LF> });<LF> b.feed(bufferFromString(":1000\r\n"));<LF>}<LF><LF>function testParseErrorReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.ERROR, "testParseErrorReply c-0");<LF> check(reply.value instanceof Buffer, "testParseErrorReply c-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), "ERR solar flare", "testParseErrorReply c-2");<LF> });<LF> a.feed(bufferFromString("-ERR solar flare\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.ERROR, "testParseErrorReply b-0");<LF> check(reply.value instanceof Buffer, "testParseErrorReply b-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), "hiccup", "testParseErrorReply b-2");<LF> });<LF> b.feed(bufferFromString("-hiccup\r\n"));<LF>}<LF><LF>function testAUTH() {<LF> // You need to configure redis to enable auth.<LF> // This unit test suite assumes the auth feature is off/disabled.<LF> // Auth *would be* the first command required after connecting.<LF><LF> printDisclaimer();<LF>}<LF><LF>function testSELECT() {<LF> printDisclaimer();<LF>}<LF><LF>function testFLUSHDB() {<LF> // no-op; tested in testSelect<LF><LF> printDisclaimer();<LF>}<LF><LF>function testSET() {<LF> client.set('foo', 'bar', expectOK("testSET"));<LF> client.set('baz', 'buz', expectOK("testSET"));<LF> client.set('ggg', '123', expectOK("testSET"));<LF>}<LF><LF>function testSETNX() {<LF> client.set('foo', 'bar', expectOK("testSETNX"));<LF> client.setnx('foo', 'quux', expectNumber(0, "testSETNX")); // fails when already set<LF> client.setnx('boo', 'apple', expectNumber(1, "testSETNX")); // no such key already so OK<LF>}<LF><LF>function testGET() {<LF> client.set('foo', 'bar', expectOK("testGET"));<LF> client.set('baz', 'buz', expectOK("testGET"));<LF><LF> client.get('foo', function (err, value) {<LF> if (err) assert.fail(err, "testGET");<LF> checkEqual(value, 'bar', "testGET");<LF> });<LF><LF> client.get('baz', function (err, value) {<LF> if (err) assert.fail(err, "testGET");<LF> checkEqual(value, 'buz', "testGET");<LF> });<LF><LF> // Check buffer resizing of input buffer<LF> // by loading really large data and reading<LF> // it back. We use ourselves<LF> var large = fs.readFileSync(__filename);<LF> client.set('largetestfile', large);<LF><LF> client.get('largetestfile', function(err, value) {<LF> if (err) assert.fail(err, "testGET");<LF> checkEqual(value.utf8Slice(0,value.length), large, "testGET");<LF> });<LF>}<LF><LF>function testMGET() {<LF> client.set('foo', 'bar', expectOK("testMGET"));<LF> client.set('baz', 'buz', expectOK("testMGET"));<LF><LF> client.mget('foo', 'baz', function (err, values) {<LF> if (err) assert.fail(err, "testMGET");<LF> checkEqual(values[0], 'bar', "testMGET");<LF> checkEqual(values[1], 'buz', "testMGET");<LF> });<LF>}<LF><LF>function testGETSET() {<LF> client.set('getsetfoo', 'getsetbar', expectOK("testGETSET 0"));<LF><LF> client.getset('getsetfoo', 'fuzz', function (err, previousValue) {<LF> if (err) assert.fail(err, "testGETSET 1");<LF> checkEqual(previousValue, 'getsetbar', "testGETSET 2");<LF> });<LF><LF> client.get('getsetfoo', function (err, value) {<LF> if (err) assert.fail(err, "testGETSET 3");<LF> checkEqual(value, 'fuzz', "testGETSET 4");<LF> });<LF>}<LF><LF>function testSETANDGETMULTIBYTE() {<LF> var testValue = '\u00F6\u65E5\u672C\u8A9E'; // �������<LF> var buffer = new Buffer(32);<LF> var size = buffer.utf8Write(testValue,0);<LF> client.set('testUtf8Key', buffer.slice(0,size), expectOK("testSETANDGETMULTIBYTE"))<LF><LF> client.get('testUtf8Key', function (err, value) {<LF> if (err) assert.fail(err, "testSETANDGETMULTIBYTE");<LF> checkEqual(value.utf8Slice(0, value.length), testValue, "testSETANDGETMULTIBYTE");<LF> });<LF>}<LF><LF>function testINFO() {<LF> client.info(function (err, info) {<LF> check(info instanceof Object, "testINFO");<LF> check(info.hasOwnProperty('redis_version'), "testINFO");<LF> check(info.hasOwnProperty('connected_clients'), "testINFO");<LF> check(info.hasOwnProperty('uptime_in_seconds'), "testINFO");<LF> checkEqual(typeof(info.uptime_in_seconds), 'string', "testINFO");<LF> checkEqual(typeof(info.connected_clients), 'string', "testINFO");<LF> });<LF>}<LF><LF>function testINCR() {<LF> client.incr('counter', expectNumber(1, "testINCR"))<LF> client.incr('counter', expectNumber(2, "testINCR"))<LF>}<LF><LF>function testINCRBY() {<LF> client.incrby('counter', 2, expectNumber(2, "testINCRBY"))<LF> client.incrby('counter', -1, expectNumber(1, "testINCRBY"))<LF>}<LF><LF>function testDECR() {<LF> client.decr('counter', expectNumber(-1, "testDECR"))<LF> client.decr('counter', expectNumber(-2, "testDECR"))<LF>}<LF><LF>function testDECRBY() {<LF> client.decrby('counter', '1', expectNumber(-1, "testDECRBY"))<LF> client.decrby('counter', '2', expectNumber(-3, "testDECRBY"))<LF> client.decrby('counter', '-3', expectNumber(0, "testDECRBY"))<LF>}<LF><LF>function testEXISTS() {<LF> client.set('foo', 'bar', expectOK("testEXISTS"));<LF> client.exists('foo', expectNumber(1, "testEXISTS"))<LF> client.exists('foo2', expectNumber(0, "testEXISTS"))<LF>}<LF><LF>function testDEL() {<LF> client.set('goo', 'bar', expectOK("testDEL"));<LF> client.del('goo', expectNumber(1, "testDEL"));<LF> client.exists('goo', expectNumber(0, "testDEL"));<LF> client.del('goo', expectNumber(0, "testDEL"));<LF>}<LF><LF>function testKEYS() {<LF> client.set('foo1', 'foo1Value', expectOK("testKEYS"))<LF> client.set('foo2', 'foo2Value', expectOK("testKEYS"))<LF><LF> client.keys('foo*', function (err, keys) {<LF> if (err) assert.fail(err, "testKEYS");<LF> checkEqual(keys.length, 2, "testKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(keys);<LF> checkDeepEqual(keys.sort(), ['foo1', 'foo2'], "testKEYS");<LF> });<LF><LF> client.set('baz', 'bazValue', expectOK("testKEYS"))<LF> client.set('boo', 'booValue', expectOK("testKEYS"))<LF><LF> // At this point we have foo1, foo2, baz, boo<LF><LF> client.keys('*', function (err, keys) {<LF> if (err) assert.fail(err, "testKEYS");<LF> checkEqual(keys.length, 4, "testKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(keys);<LF> checkDeepEqual(keys.sort(), ['baz', 'boo', 'foo1', 'foo2'], "testKEYS");<LF> });<LF><LF> client.keys('?oo', function (err, keys) {<LF> if (err) assert.fail(err, "testKEYS");<LF> checkEqual(keys.length, 1, "testKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(keys);<LF> checkDeepEqual(keys.sort(), ['boo'], "testKEYS");<LF> });<LF>}<LF><LF>function testRANDOMKEY() {<LF> client.set('foo', 'bar', expectOK("testRANDOMKEY"));<LF> client.set('baz', 'buz', expectOK("testRANDOMKEY"));<LF><LF> client.randomkey(function (err, someKey) {<LF> if (err) assert.fail(err, "testRANDOMKEY");<LF> check(/^(foo|baz)$/.test(someKey), "testRANDOMKEY");<LF> });<LF>}<LF><LF>function testRENAME() {<LF> client.set('foo', 'bar', expectOK("testRENAME"));<LF> client.rename('foo', 'zoo', expectOK("testRENAME"));<LF> client.exists('foo', expectNumber(0, "testRENAME"));<LF> client.exists('zoo', expectNumber(1, "testRENAME"));<LF>}<LF><LF>function testRENAMENX() {<LF> client.set('roo', 'bar', expectOK("testRENAMENX"));<LF> client.set('bar', 'baz', expectOK("testRENAMENX"));<LF> client.renamenx('roo', 'bar', expectNumber(0, "testRENAMENX")); // bar already exists<LF> client.exists('roo', expectNumber(1, "testRENAMENX")); // was not renamed<LF> client.exists('bar', expectNumber(1, "testRENAMENX")); // was not touched<LF> client.renamenx('roo', 'too', expectNumber(1, "testRENAMENX")); // too did not exist... OK<LF> client.exists('roo', expectNumber(0, "testRENAMENX")); // was renamed<LF> client.exists('too', expectNumber(1, "testRENAMENX")); // was created<LF>}<LF><LF>function testDBSIZE() {<LF> client.set('foo', 'bar', expectOK("testDBSIZE"));<LF> client.set('bar', 'baz', expectOK("testDBSIZE"));<LF><LF> client.dbsize(function (err, value) {<LF> if (err) assert.fail(err, "testDBSIZE");<LF> checkEqual(value, 2, "testDBSIZE");<LF> });<LF>}<LF><LF>function testEXPIRE() {<LF> // set 'expfoo' to expire in 2 seconds<LF><LF> client.set('expfoo', 'bar', expectOK("testEXPIRE"));<LF> client.expire('expfoo', 2, expectNumber(1, "testEXPIRE"));<LF><LF> // subsequent expirations cannot be set.<LF><LF> client.expire('expfoo', 2, expectNumber(0, "testEXPIRE"));<LF><LF> setTimeout(function () {<LF> client.exists('expfoo', expectNumber(0, "testEXPIRE"));<LF> }, 2500);<LF>}<LF><LF>function testTTL() {<LF> client.set('ttlfoo', 'bar', expectOK("testTTL"));<LF><LF> // ttlfoo is not set to expire<LF><LF> client.ttl('ttlfoo', function (err, value) {<LF> if (err) assert.fail(err, "testTTL");<LF> checkEqual(value, -1, "testTTL");<LF> });<LF><LF> client.set('ttlbar', 'baz', expectOK("testTTL"));<LF> client.expire('ttlbar', 3, expectNumber(1, "testTTL"));<LF><LF> client.ttl('ttlbar', function (err, value) {<LF> if (err) assert.fail(err, "testTTL");<LF> check(value > 0, "testTTL");<LF> });<LF>}<LF><LF>function testRPUSH() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testRPUSH"));<LF> client.exists('list0', expectNumber(1, "testRPUSH"));<LF>}<LF><LF>function testLPUSH() {<LF> client.exists('list1', expectNumber(0, "testLPUSH"));<LF> client.lpush('list1', 'list1value0', expectNumber(1, "testLPUSH"));<LF> client.exists('list1', expectNumber(1, "testLPUSH"));<LF>}<LF><LF>function testLLEN() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLLEN"));<LF> client.llen('list0', expectNumber(1, "testLLEN"));<LF><LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLLEN"));<LF> client.llen('list0', expectNumber(2, "testLLEN"));<LF>}<LF><LF>function testLRANGE() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLRANGE"));<LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLRANGE"));<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLRANGE");<LF> checkEqual(values.length, 2, "testLRANGE");<LF> checkEqual(values[0], 'list0value0', "testLRANGE");<LF> checkEqual(values[1], 'list0value1', "testLRANGE");<LF> });<LF><LF> client.lrange('list0', 0, 0, function (err, values) {<LF> if (err) assert.fail(err, "testLRANGE");<LF> checkEqual(values.length, 1, "testLRANGE");<LF> checkEqual(values[0], 'list0value0', "testLRANGE");<LF> });<LF><LF> client.lrange('list0', -1, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLRANGE");<LF> checkEqual(values.length, 1, "testLRANGE");<LF> checkEqual(values[0], 'list0value1', "testLRANGE");<LF> });<LF>}<LF><LF>function testLTRIM() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLTRIM"));<LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLTRIM"));<LF> client.rpush('list0', 'list0value2', expectNumber(3, "testLTRIM"));<LF><LF> client.llen('list0', function (err, len) {<LF> if (err) assert.fail(err, "testLTRIM");<LF> checkEqual(len, 3, "testLTRIM");<LF> });<LF><LF> client.ltrim('list0', 0, 1, expectOK("testLTRIM"))<LF><LF> client.llen('list0', function (err, len) {<LF> if (err) assert.fail(err, "testLTRIM");<LF> checkEqual(len, 2, "testLTRIM");<LF> });<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLTRIM");<LF> checkEqual(values.length, 2, "testLTRIM");<LF> checkEqual(values[0], 'list0value0', "testLTRIM");<LF> checkEqual(values[1], 'list0value1', "testLTRIM");<LF> });<LF>}<LF><LF>function testLINDEX() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLINDEX"));<LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLINDEX"));<LF><LF> client.lindex('list0', 0, function (err, value) {<LF> if (err) assert.fail(err, "testLINDEX");<LF> checkEqual(value, 'list0value0', "testLINDEX");<LF> });<LF><LF> client.lindex('list0', 1, function (err, value) {<LF> if (err) assert.fail(err, "testLINDEX");<LF> checkEqual(value, 'list0value1', "testLINDEX");<LF> });<LF><LF> // out of range => null<LF><LF> client.lindex('list0', 2, function (err, value) {<LF> if (err) assert.fail(err, "testLINDEX");<LF> checkEqual(value, null, "testLINDEX");<LF> });<LF>}<LF><LF>function testLSET() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLSET"));<LF> client.lset('list0', 0, 'LIST0VALUE0', expectOK("testLSET"));<LF><LF> client.lrange('list0', 0, 0, function (err, values) {<LF> if (err) assert.fail(err, "testLSET");<LF> checkEqual(values.length, 1, "testLSET");<LF> checkEqual(values[0], 'LIST0VALUE0', "testLSET");<LF> });<LF>}<LF><LF>function testLREM() {<LF> client.lpush('list0', 'ABC', expectNumber(1, "testLREM"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testLREM"));<LF> client.lpush('list0', 'ABC', expectNumber(3, "testLREM"));<LF><LF> client.lrem('list0', 1, 'ABC', expectNumber(1, "testLREM"));<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLREM");<LF> checkEqual(values.length, 2, "testLREM");<LF> checkEqual(values[0], 'DEF', "testLREM");<LF> checkEqual(values[1], 'ABC', "testLREM");<LF> });<LF>}<LF><LF>function testLPOP() {<LF> client.lpush('list0', 'ABC', expectNumber(1, "testLPOP"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testLPOP"));<LF> client.lpush('list0', 'GHI', expectNumber(3, "testLPOP"));<LF><LF> client.lpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testLPOP");<LF> checkEqual(value, 'GHI', "testLPOP");<LF> });<LF><LF> client.lpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testLPOP");<LF> checkEqual(value, 'DEF', "testLPOP");<LF> });<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLPOP");<LF> checkEqual(values.length, 1, "testLPOP");<LF> checkEqual(values[0], 'ABC', "testLPOP");<LF> });<LF>}<LF><LF>function testRPOP() {<LF> client.lpush('list0', 'ABC', expectNumber(1, "testRPOP"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testRPOP"));<LF><LF> client.rpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testRPOP");<LF> checkEqual(value, 'ABC', "testRPOP");<LF> });<LF><LF> client.rpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testRPOP");<LF> checkEqual(value, 'DEF', "testRPOP");<LF> });<LF><LF> client.llen('list0', function (err, len) {<LF> if (err) assert.fail(err, "testRPOP");<LF> checkEqual(len, 0, "testRPOP");<LF> });<LF>}<LF><LF>function testRPOPLPUSH() {<LF> client.rpush('src', 'ABC', expectNumber(1, "testRPOPLPUSH"));<LF> client.rpush('src', 'DEF', expectNumber(2, "testRPOPLPUSH"));<LF><LF> client.rpoplpush('src', 'dst', function (err, value) {<LF> if (err) assert.fail(err, "testRPOPLPUSH");<LF> checkEqual(value, 'DEF', "testRPOPLPUSH");<LF> });<LF><LF> client.lrange('src', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testRPOPLPUSH");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(values);<LF> checkDeepEqual(values, [ 'ABC' ], "testRPOPLPUSH");<LF> });<LF><LF> client.lrange('dst', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testRPOPLPUSH");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(values);<LF> checkDeepEqual(values, [ 'DEF' ], "testRPOPLPUSH");<LF> });<LF>}<LF><LF>function testSADD() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSADD"));<LF> client.sadd('set0', 'member0', expectNumber(0, "testSADD")); // already member<LF>}<LF><LF>function testSISMEMBER() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSISMEMBER"));<LF> client.sismember('set0', 'member0', expectNumber(1, "testSISMEMBER"));<LF> client.sismember('set0', 'member1', expectNumber(0, "testSISMEMBER"));<LF>}<LF><LF>function testSCARD() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSCARD"));<LF> client.scard('set0', expectNumber(1, "testSCARD"));<LF><LF> client.sadd('set0', 'member1', expectNumber(1, "testSCARD"));<LF> client.scard('set0', expectNumber(2, "testSCARD"));<LF>}<LF><LF>function testSREM() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSREM"));<LF> client.srem('set0', 'foobar', expectNumber(0, "testSREM"))<LF> client.srem('set0', 'member0', expectNumber(1, "testSREM"))<LF> client.scard('set0', expectNumber(0, "testSREM"));<LF>}<LF><LF>function testSPOP() {<LF> client.sadd('zzz', 'member0', expectNumber(1, "testSPOP"));<LF> client.scard('zzz', expectNumber(1, "testSPOP"));<LF><LF> client.spop('zzz', function (err, value) {<LF> if (err) assert.fail(err, "testSPOP");<LF> checkEqual(value, 'member0', "testSPOP");<LF> });<LF><LF> client.scard('zzz', expectNumber(0, "testSPOP"));<LF>}<LF><LF>function testSDIFF() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSDIFF"));<LF> client.sadd('foo', 'a', expectNumber(1, "testSDIFF"));<LF> client.sadd('foo', 'b', expectNumber(1, "testSDIFF"));<LF> client.sadd('foo', 'c', expectNumber(1, "testSDIFF"));<LF><LF> client.sadd('bar', 'c', expectNumber(1, "testSDIFF"));<LF><LF> client.sadd('baz', 'a', expectNumber(1, "testSDIFF"));<LF> client.sadd('baz', 'd', expectNumber(1, "testSDIFF"));<LF><LF> client.sdiff('foo', 'bar', 'baz', function (err, values) {<LF> if (err) assert.fail(err, "testSDIFF");<LF> values.sort();<LF> checkEqual(values.length, 2, "testSDIFF");<LF> checkEqual(values[0], 'b', "testSDIFF");<LF> checkEqual(values[1], 'x', "testSDIFF");<LF> });<LF>}<LF><LF>function testSDIFFSTORE() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('foo', 'a', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('foo', 'b', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('foo', 'c', expectNumber(1, "testSDIFFSTORE"))<LF><LF> client.sadd('bar', 'c', expectNumber(1, "testSDIFFSTORE"))<LF><LF> client.sadd('baz', 'a', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('baz', 'd', expectNumber(1, "testSDIFFSTORE"))<LF><LF> // NB: SDIFFSTORE returns the number of elements in the dstkey <LF><LF> client.sdiffstore('quux', 'foo', 'bar', 'baz', expectNumber(2, "testSDIFFSTORE"))<LF><LF> client.smembers('quux', function (err, members) {<LF> if (err) assert.fail(err, "testSDIFFSTORE");<LF> members.sort();<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'b', 'x' ], "testSDIFFSTORE");<LF> });<LF>}<LF><LF>function testSMEMBERS() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSMEMBERS"));<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testSMEMBERS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'x' ], "testSMEMBERS");<LF> });<LF><LF> client.sadd('foo', 'y', expectNumber(1, "testSMEMBERS"));<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testSMEMBERS");<LF> checkEqual(members.length, 2, "testSMEMBERS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members.sort(), [ 'x', 'y' ], "testSMEMBERS");<LF> });<LF>}<LF><LF>function testSMOVE() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSMOVE"));<LF> client.smove('foo', 'bar', 'x', expectNumber(1, "testSMOVE"));<LF> client.sismember('foo', 'x', expectNumber(0, "testSMOVE"));<LF> client.sismember('bar', 'x', expectNumber(1, "testSMOVE"));<LF> client.smove('foo', 'bar', 'x', expectNumber(0, "testSMOVE"));<LF>}<LF><LF>function testSINTER() {<LF> client.sadd('sa', 'a', expectNumber(1, "testSINTER"));<LF> client.sadd('sa', 'b', expectNumber(1, "testSINTER"));<LF> client.sadd('sa', 'c', expectNumber(1, "testSINTER"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testSINTER"));<LF> client.sadd('sb', 'c', expectNumber(1, "testSINTER"));<LF> client.sadd('sb', 'd', expectNumber(1, "testSINTER"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testSINTER"));<LF> client.sadd('sc', 'd', expectNumber(1, "testSINTER"));<LF> client.sadd('sc', 'e', expectNumber(1, "testSINTER"));<LF><LF> client.sinter('sa', 'sb', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 2, "testSINTER");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);<LF> checkDeepEqual(intersection.sort(), [ 'b', 'c' ], "testSINTER");<LF> });<LF><LF> client.sinter('sb', 'sc', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 2, "testSINTER");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);<LF> checkDeepEqual(intersection.sort(), [ 'c', 'd' ], "testSINTER");<LF> });<LF><LF> client.sinter('sa', 'sc', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 1, "testSINTER");<LF> checkEqual(intersection[0], 'c', "testSINTER");<LF> });<LF><LF> // 3-way<LF><LF> client.sinter('sa', 'sb', 'sc', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 1, "testSINTER");<LF> checkEqual(intersection[0], 'c', "testSINTER");<LF> });<LF>}<LF><LF>function testSINTERSTORE() {<LF> client.sadd('sa', 'a', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sa', 'b', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sa', 'c', expectNumber(1, "testSINTERSTORE"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sb', 'c', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sb', 'd', expectNumber(1, "testSINTERSTORE"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sc', 'd', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sc', 'e', expectNumber(1, "testSINTERSTORE"));<LF><LF> client.sinterstore('foo', 'sa', 'sb', 'sc', expectNumber(1, "testSINTERSTORE"))<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testSINTERSTORE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'c' ], "testSINTERSTORE");<LF> });<LF>}<LF><LF>function testSUNION() {<LF> client.sadd('sa', 'a', expectNumber(1, "testUNION"));<LF> client.sadd('sa', 'b', expectNumber(1, "testUNION"));<LF> client.sadd('sa', 'c', expectNumber(1, "testUNION"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testUNION"));<LF> client.sadd('sb', 'c', expectNumber(1, "testUNION"));<LF> client.sadd('sb', 'd', expectNumber(1, "testUNION"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testUNION"));<LF> client.sadd('sc', 'd', expectNumber(1, "testUNION"));<LF> client.sadd('sc', 'e', expectNumber(1, "testUNION"));<LF><LF> client.sunion('sa', 'sb', 'sc', function (err, union) {<LF> if (err) assert.fail(err, "testUNION");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(union);<LF> checkDeepEqual(union.sort(), ['a', 'b', 'c', 'd', 'e'], "testUNION");<LF> });<LF>}<LF><LF>function testSUNIONSTORE() {<LF> client.sadd('sa', 'a', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sa', 'b', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sa', 'c', expectNumber(1, "testUNIONSTORE"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sb', 'c', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sb', 'd', expectNumber(1, "testUNIONSTORE"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sc', 'd', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sc', 'e', expectNumber(1, "testUNIONSTORE"));<LF><LF> client.sunionstore('foo', 'sa', 'sb', 'sc', function (err, cardinality) {<LF> if (err) assert.fail(err, "testUNIONSTORE");<LF> checkEqual(cardinality, 5, "testUNIONSTORE");<LF> });<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testUNIONSTORE");<LF> checkEqual(members.length, 5, "testUNIONSTORE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members.sort(), ['a', 'b', 'c', 'd', 'e'], "testUNIONSTORE");<LF> });<LF>}<LF><LF>function testTYPE() {<LF> client.sadd('sa', 'a', expectNumber(1, "testTYPE"));<LF> client.type('sa', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'set', "testTYPE");<LF> });<LF><LF> client.rpush('list0', 'x', expectNumber(1, "testTYPE"));<LF> client.type('list0', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'list', "testTYPE");<LF> });<LF><LF> client.set('foo', 'bar', expectOK("testTYPE"));<LF> client.type('foo', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'string', "testTYPE");<LF> });<LF><LF> client.type('xxx', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'none', "testTYPE");<LF> });<LF>}<LF><LF>function testMOVE() {<LF> client.rpush('list0', 'x', expectNumber(1, "testMOVE"));<LF> client.move('list0', TEST_DB_NUMBER_FOR_MOVE, expectNumber(1, "testMOVE"));<LF><LF> client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK("testMOVE"));<LF> client.exists('list0', expectNumber(1, "testMOVE"));<LF><LF> client.select(TEST_DB_NUMBER, expectOK("testMOVE"));<LF> client.exists('list0', expectNumber(0, "testMOVE"));<LF>}<LF><LF>// TODO sort with STORE option.<LF><LF>// Sort is a beast.<LF>//<LF>// $ redis-cli lrange x 0 -1<LF>// 1. 3<LF>// 2. 9<LF>// 3. 2<LF>// 4. 4<LF>//<LF>// $ redis-cli mget w3 w9 w2 w4<LF>// 1. 4<LF>// 2. 5<LF>// 3. 12<LF>// 4. 6<LF>//<LF>// $ redis-cli sort x by w*<LF>// 1. 3<LF>// 2. 9<LF>// 3. 4<LF>// 4. 2<LF>//<LF>// When using 'by w*' value x[i]'s effective value is w{x[i]}.<LF>//<LF>// sort [ w3, w9, w2, w4 ] = sort [ 4, 5, 12, 6 ]<LF>// = [ 4, 5, 6, 12 ]<LF>// = [ w3, w9, w4, w2 ]<LF>//<LF>// Thus, sorting x 'by w*' results in [ 3, 9, 4, 2 ]<LF>//<LF>// Once sorted redis can fetch entries at the keys indicated by the 'get'<LF>// pattern. If we specify 'get o*', redis would fetch [ o3, o9, o4, o2 ] <LF>// since our sorted list was [ 3, 9, 4, 2 ].<LF>//<LF>// $ redis-cli mget o2 o3 o4 o9<LF>// 1. buz<LF>// 2. foo<LF>// 3. baz<LF>// 4. bar<LF>//<LF>// $ redis-cli sort x by w* get o*<LF>// 1. foo<LF>// 2. bar<LF>// 3. baz<LF>// 4. buz<LF>//<LF>// One can specify multiple get patterns and the keys for each get pattern<LF>// are interlaced in the results.<LF>//<LF>// $ redis-cli mget p2 p3 p4 p9<LF>// 1. qux<LF>// 2. bux<LF>// 3. lux<LF>// 4. tux<LF>//<LF>// $ redis-cli sort x by w* get o* get p*<LF>// 1. foo<LF>// 2. bux<LF>// 3. bar<LF>// 4. tux<LF>// 5. baz<LF>// 6. lux<LF>// 7. buz<LF>// 8. qux<LF>//<LF>// Phew! Now, let's test all that.<LF><LF>function testSORT() {<LF> client.rpush('y', 'd', expectNumber(1, "testSORT"));<LF> client.rpush('y', 'b', expectNumber(2, "testSORT"));<LF> client.rpush('y', 'a', expectNumber(3, "testSORT"));<LF> client.rpush('y', 'c', expectNumber(4, "testSORT"));<LF><LF> client.rpush('x', '3', expectNumber(1, "testSORT"));<LF> client.rpush('x', '9', expectNumber(2, "testSORT"));<LF> client.rpush('x', '2', expectNumber(3, "testSORT"));<LF> client.rpush('x', '4', expectNumber(4, "testSORT"));<LF><LF> client.set('w3', '4', expectOK("testSORT"));<LF> client.set('w9', '5', expectOK("testSORT"));<LF> client.set('w2', '12', expectOK("testSORT"));<LF> client.set('w4', '6', expectOK("testSORT"));<LF><LF> client.set('o2', 'buz', expectOK("testSORT"));<LF> client.set('o3', 'foo', expectOK("testSORT"));<LF> client.set('o4', 'baz', expectOK("testSORT"));<LF> client.set('o9', 'bar', expectOK("testSORT"));<LF><LF> client.set('p2', 'qux', expectOK("testSORT"));<LF> client.set('p3', 'bux', expectOK("testSORT"));<LF> client.set('p4', 'lux', expectOK("testSORT"));<LF> client.set('p9', 'tux', expectOK("testSORT"));<LF><LF> // Now the data has been setup, we can test.<LF><LF> // But first, test basic sorting.<LF><LF> // y = [ d b a c ]<LF> // sort y ascending = [ a b c d ]<LF> // sort y descending = [ d c b a ]<LF><LF> client.sort('y', 'asc', 'alpha', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['a', 'b', 'c', 'd'], "testSORT");<LF> });<LF><LF> client.sort('y', 'desc', 'alpha', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['d', 'c', 'b', 'a'], "testSORT");<LF> });<LF><LF> // Now try sorting numbers in a list.<LF> // x = [ 3, 9, 2, 4 ]<LF><LF> client.sort('x', 'asc', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, [2, 3, 4, 9], "testSORT");<LF> });<LF><LF> client.sort('x', 'desc', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, [9, 4, 3, 2], "testSORT");<LF> });<LF><LF> // Try sorting with a 'by' pattern.<LF><LF> client.sort('x', 'by', 'w*', 'asc', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, [3, 9, 4, 2], "testSORT");<LF> });<LF><LF> // Try sorting with a 'by' pattern and 1 'get' pattern.<LF><LF> client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['foo', 'bar', 'baz', 'buz'], "testSORT");<LF> });<LF><LF> // Try sorting with a 'by' pattern and 2 'get' patterns.<LF><LF> client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], "testSORT");<LF> });<LF><LF> // Try sorting with a 'by' pattern and 2 'get' patterns.<LF> // Instead of getting back the sorted set/list, store the values to a list.<LF> // Then check that the values are there in the expected order.<LF><LF> client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', 'store', 'bacon', function (err) {<LF> if (err) assert.fail(err, "testSORT");<LF> });<LF><LF> client.lrange('bacon', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(values);<LF> checkDeepEqual(values, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], "testSORT");<LF> });<LF>}<LF><LF>function testSAVE() {<LF> client.save(expectOK("testSAVE"));<LF>}<LF><LF>function testBGSAVE() {<LF> printDisclaimer();<LF>}<LF><LF>function testLASTSAVE() {<LF> client.lastsave( function (err, value) {<LF> if (err) assert.fail(err, "testLASTSAVE");<LF> checkEqual(typeof(value), 'number', "testLASTSAVE");<LF> check(value > 0, "testLASTSAVE");<LF> });<LF>}<LF><LF>function testFLUSHALL() {<LF> printDisclaimer();<LF>}<LF><LF>function testSHUTDOWN() {<LF> printDisclaimer();<LF>}<LF><LF>function testMSET() {<LF> // set a=b, c=d, e=100<LF><LF> client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK("testMSET"));<LF>}<LF><LF>function testMSETNX() {<LF> client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK("testMSET"));<LF><LF> // should fail since as 'a' already exists.<LF><LF> client.msetnx('g', 'h', 'a', 'i', expectNumber(0, "testMSETNX"));<LF><LF> // should pass as key 'g' was NOT set in prev. command<LF> // since it failed due to key 'a' already existing.<LF><LF> client.msetnx('g', 'h', 'i', 'j', expectNumber(1, "testMSETNX"));<LF>}<LF><LF>function testZADD() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZADD"));<LF><LF> // Already added m0; just update the score to 50.<LF> // Redis returns 0 in this case.<LF><LF> client.zadd('z0', 50, 'm0', expectNumber(0, "testZADD"));<LF>}<LF><LF>function testZREM() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZREM"));<LF> client.zrem('z0', 'm0', expectNumber(1, "testZREM"));<LF> client.zrem('z0', 'm0', expectNumber(0, "testZREM"));<LF>}<LF><LF>function testZCARD() {<LF> client.zcard('zzzzzz', expectNumber(0, "testZCARD")); // doesn't exist.<LF><LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZCARD"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZCARD"));<LF><LF> client.zcard('z0', expectNumber(2, "testZCARD"));<LF>}<LF><LF>function testZSCORE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZSCORE"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZSCORE"));<LF><LF> client.zscore('z0', 'm0', expectNumber(100, "testZSCORE"));<LF> client.zscore('z0', 'm1', expectNumber(200, "testZSCORE"));<LF><LF> client.zscore('z0', 'zzzzzzz', function (err, score) {<LF> if (err) assert.fail(err, "testZSCORE");<LF> checkEqual(score, null, "testZSCORE");<LF> });<LF>}<LF><LF>function testZRANGE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZRANGE"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZRANGE"));<LF> client.zadd('z0', 300, 'm2', expectNumber(1, "testZRANGE"));<LF><LF> client.zrange('z0', 0, -1, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], "testZRANGE");<LF> });<LF><LF> client.zrange('z0', -1, -1, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm2' ], "testZRANGE");<LF> });<LF><LF> client.zrange('z0', -2, -1, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm1', 'm2' ], "testZRANGE");<LF> });<LF>}<LF><LF>function testZREVRANGE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZREVRANGE"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZREVRANGE"));<LF> client.zadd('z0', 300, 'm2', expectNumber(1, "testZREVRANGE"));<LF><LF> client.zrevrange('z0', 0, 1000, function (err, members) {<LF> if (err) assert.fail(err, "testZREVRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm2', 'm1', 'm0' ], "testZREVRANGE");<LF> });<LF>}<LF><LF>function testZRANGEBYSCORE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZRANGEBYSCORE 1"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZRANGEBYSCORE 2"));<LF> client.zadd('z0', 300, 'm2', expectNumber(1, "testZRANGEBYSCORE 3"));<LF><LF> client.zrangebyscore('z0', 200, 300, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGEBYSCORE 4");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm1', 'm2' ], "testZRANGEBYSCORE 5");<LF> });<LF><LF> client.zrangebyscore('z0', 100, 1000, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGEBYSCORE 6");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], "testZRANGEBYSCORE 7");<LF> });<LF><LF> client.zrangebyscore('z0', 10000, 100000, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGEBYSCORE 8");<LF> checkEqual(members, null, "testZRANGEBYSCORE 9");<LF> });<LF>}<LF><LF>// zcount is undocumented as of Thu Apr 01 20:17:58 EDT 2010 <LF>// zcount key startScore endScore => number of elements in [startScore, endScore]<LF><LF>function testZCOUNT() {<LF> client.zcount('z0', 0, 100, expectNumber(0, "testZCOUNT"));<LF><LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZCOUNT"));<LF> client.zcount('z0', 0, 100, expectNumber(1, "testZCOUNT"));<LF><LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZCOUNT"));<LF> client.zcount('z0', 0, 100, expectNumber(2, "testZCOUNT"));<LF>}<LF><LF>function testZINCRBY() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZINCRBY"));<LF> client.zincrby('z0', 1, 'a', expectNumber(2, "testZINCRBY"));<LF>}<LF><LF>// This really should be called ZINTERSTORE.<LF><LF>function testZINTER() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZINTER"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZINTER"));<LF> client.zadd('z1', 3, 'a', expectNumber(1, "testZINTER"));<LF> client.zinter('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(1, "testZINTER"));<LF> client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZINTER");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'a', 4 ], "testZINTER"); // score=1+3<LF> });<LF>}<LF><LF>function testZUNION() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZUNION"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZUNION"));<LF> client.zadd('z1', 3, 'a', expectNumber(1, "testZUNION"));<LF> client.zunion('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(2, "testZUNION"));<LF> client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZUNION");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> check(members.length % 2 == 0, "testZUNION");<LF> var set = {};<LF> for (var i=0; i<members.length; i += 2)<LF> set[members[i]] = members[i + 1];<LF> checkDeepEqual(set, { a:4, b:2 }, "testZUNION"); // a's score=1+3<LF> });<LF>}<LF><LF>function testZRANK() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZRANK"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZRANK"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZRANK"));<LF><LF> client.zrank('z0', 'a', expectNumber(0, "testZRANK"));<LF> client.zrank('z0', 'b', expectNumber(1, "testZRANK"));<LF> client.zrank('z0', 'c', expectNumber(2, "testZRANK"));<LF>}<LF><LF>function testZREVRANK() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZREVRANK"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZREVRANK"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZREVRANK"));<LF><LF> client.zrevrank('z0', 'a', expectNumber(2, "testZREVRANK"));<LF> client.zrevrank('z0', 'b', expectNumber(1, "testZREVRANK"));<LF> client.zrevrank('z0', 'c', expectNumber(0, "testZREVRANK"));<LF>}<LF><LF>function testZREMRANGEBYRANK() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZREMRANGEBYRANK"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZREMRANGEBYRANK"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZREMRANGEBYRANK"));<LF><LF> client.zremrangebyrank('z0', -1, -1, expectNumber(1, "testZREMRANGEBYRANK"));<LF><LF> client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZREMRANGEBYRANK");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> check(members.length % 2 == 0, "testZREMRANGEBYRANK");<LF> var set = {};<LF> for (var i=0; i<members.length; i += 2)<LF> set[members[i]] = members[i + 1];<LF> checkDeepEqual(set, { a:1, b:2 }, "testZREMRANGEBYRANK");<LF> });<LF>}<LF><LF>function testZREMRANGEBYSCORE() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZREMRANGEBYSCORE"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZREMRANGEBYSCORE"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZREMRANGEBYSCORE"));<LF><LF> // inclusive<LF> client.zremrangebyscore('z0', 2, 3, expectNumber(2, "testZREMRANGEBYSCORE"));<LF><LF> client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZREMRANGEBYSCORE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> check(members.length % 2 == 0, "testZREMRANGEBYSCORE");<LF> var set = {};<LF> for (var i=0; i<members.length; i += 2)<LF> set[members[i]] = members[i + 1];<LF> checkDeepEqual(set, { a:1 }, "testZREMRANGEBYSCORE");<LF> });<LF>}<LF><LF>function testHDEL() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHDEL"));<LF> client.hdel("foo", "bar", expectNumber(1, "testHDEL"));<LF> client.hdel("foo", "bar", expectNumber(0, "testHDEL"));<LF>}<LF><LF>function testHEXISTS() {<LF> client.hset("hfoo", "bar", "baz", expectNumber(1, "testHEXISTS"));<LF> client.hexists("hfoo", "bar", expectNumber(1, "testHEXISTS"));<LF> client.hexists("hfoo", "baz", expectNumber(0, "testHEXISTS"));<LF>}<LF><LF>function testHGET() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHGET"));<LF> client.hget("foo", "bar", function (err, reply) {<LF> if (err) assert.fail(err, "testHGET");<LF> checkEqual("baz", reply, "testHGET");<LF> });<LF>}<LF><LF>function testHGETALL() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHGETALL"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHGETALL"));<LF> client.hgetall("foo", function (err, all) {<LF> if (err) assert.fail(err, "testHGETALL");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(all);<LF> checkDeepEqual(all, { bar:"baz", quux:"doo" }, "testHGETALL");<LF> });<LF>}<LF><LF>function testHINCRBY() {<LF> client.hincrby("foo", "bar", 1, expectNumber(1, "testHINCRBY 1"));<LF> client.hget("foo", "bar", expectNumber(1, "testHINCRBY 2"));<LF><LF> client.hincrby("foo", "bar", 1, expectNumber(2, "testHINCRBY 3"));<LF> client.hget("foo", "bar", expectNumber(2, "testHINCRBY 4"));<LF>}<LF><LF>function testHKEYS() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHKEYS"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHKEYS"));<LF> client.hkeys("foo", function (err, reply) {<LF> if (err) assert.fail(err, "testHKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply.sort(), [ "bar", "quux" ], "testHKEYS");<LF> });<LF>}<LF><LF>function testHVALS() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHVALS"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHVALS"));<LF> client.hvals("foo", function (err, reply) {<LF> if (err) assert.fail(err, "testHVALS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply.sort(), [ "baz", "doo" ], "testHVALS");<LF> });<LF>}<LF><LF>function testHLEN() {<LF> client.hlen("foo", expectNumber(0, "testHLEN"));<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHLEN"));<LF> client.hlen("foo", expectNumber(1, "testHLEN"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHLEN"));<LF> client.hlen("foo", expectNumber(2, "testHLEN"));<LF>}<LF><LF>function testHSET() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHSET"));<LF> client.hget("foo", "bar", function (err, reply) {<LF> if (err) assert.fail(err, "testHSET");<LF> checkEqual("baz", reply, "testHSET");<LF> });<LF>}<LF><LF>// Note that the user of this client should add a listener for "connect" via<LF>// client.stream.addListener("connect", function () { ... }); in order to<LF>// subscribe to channels/classes of interest after each connection is established<LF>// (subscriptions are not remembered across connections and reconnections).<LF><LF>// We need a 2nd client to act as publisher in order to test that a message<LF>// is received after SUBSCRIBE[ing] to a channel/class. We can at least test<LF>// that SUBSCRIBE itself does not fail (it shouldn't).<LF><LF>function testSUBSCRIBE() {<LF> client.subscribe("#redis", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "subscribe", "#redis", "1" ], "testSUBSCRIBE");<LF> });<LF><LF> client.subscribe("#Node.js", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "subscribe", "#Node.js", "2" ], "testSUBSCRIBE");<LF> });<LF><LF> client.unsubscribe("#redis", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "unsubscribe", "#redis", "1" ], "testSUBSCRIBE");<LF> });<LF><LF> client.unsubscribe("#Node.js", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "unsubscribe", "#Node.js", "0" ], "testSUBSCRIBE");<LF> });<LF>}<LF><LF>function testUNSUBSCRIBE() {<LF> printDisclaimer();<LF>}<LF><LF>function testPSUBSCRIBE() {<LF> client.psubscribe("cooking.*", function (err, reply) {<LF> if (err) assert.fail(err, "testPSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "psubscribe", "cooking.*", "1" ], "testPSUBSCRIBE");<LF> });<LF><LF> client.punsubscribe("cooking.*", function (err, reply) {<LF> if (err) assert.fail(err, "testPSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "punsubscribe", "cooking.*", "0" ], "testPSUBSCRIBE");<LF> });<LF>}<LF><LF>function testPUNSUBSCRIBE() {<LF> printDisclaimer();<LF>}<LF><LF>function testPUBLISH() {<LF> // No one is subscribed so 0<LF><LF> client.publish("#redis", "Hello, world!", expectNumber(0, "testPUBLISH"));<LF>}<LF><LF>var messageWasReceived = false;<LF><LF>function testSUBSCRIBEandPUBLISH() {<LF> var messagePayload = "I'm a lumberjack!";<LF> var channelName = "Monty"; <LF><LF> client.subscribeTo(channelName, function (channel, message) {<LF> checkEqual(channel, channelName, "testSUBSCRIBEandPUBLISH a0");<LF> checkEqual(message, messagePayload, "testSUBSCRIBEandPUBLISH a1");<LF> messageWasReceived = true;<LF> }); <LF><LF> // Create a 2nd client that publishes a message.<LF><LF> var publisher = redisclient.createClient();<LF> publisher.stream.addListener("connect", function () {<LF> publisher.publish(channelName, messagePayload, function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBEandPUBLISH b0");<LF> expectNumber(1, "testSUBSCRIBEandPUBLISH b1");<LF> });<LF> });<LF>}<LF><LF>// We cannot test the blocking behavior of BLPOP and BRPOP from a single client<LF>// without using a timeout. That being said, we can test the non-blocking<LF>// behavior by ensuring there's an element in a list that we try to pop from.<LF><LF>function testBLPOP() {<LF> var timeout = 1;<LF><LF> // Non-blocking against a single key.<LF><LF> client.lpush('list0', 'ABC', expectNumber(1, "testBLPOP 1"));<LF> client.blpop('list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBLPOP 2");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "ABC" ], "testBLPOP 3");<LF> });<LF><LF> // Non-blocking against multiple keys.<LF> // Returns the first one that has something in it.<LF><LF> client.lpush('list0', 'ABC', expectNumber(1, "testBLPOP 4"));<LF> client.blpop('list1', 'list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBLPOP 5");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "ABC" ], "testBLPOP 6");<LF> });<LF><LF> // Non-blocking against a single key that does not exist.<LF> // This should timeout after 1 second and return a null reply.<LF><LF> client.blpop('listX', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBLPOP 7");<LF> checkEqual(reply, null, "testBLPOP 8");<LF> });<LF>}<LF><LF>function testBRPOP() {<LF> var timeout = 1;<LF><LF> // Non-blocking against a single key.<LF><LF> client.lpush('list0', 'ABC', expectNumber(1, "testBRPOP"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testBRPOP"));<LF> client.brpop('list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBRPOP");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "ABC" ], "testBRPOP");<LF> });<LF><LF> // Non-blocking against multiple keys.<LF> // Returns the first one that has something in it.<LF><LF> client.lpush('list0', 'ABC', expectNumber(2, "testBRPOP"));<LF> client.brpop('list1', 'list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBRPOP");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "DEF" ], "testBRPOP");<LF> });<LF><LF> // Non-blocking against a single key that does not exist.<LF> // This should timeout after 1 second and return a null reply.<LF><LF> client.brpop('listX', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBRPOP");<LF> checkEqual(reply, null, "testBRPOP");<LF> });<LF>}<LF><LF>var allTestFunctions = [<LF> testAUTH,<LF> testBGSAVE,<LF> testBLPOP,<LF> testBRPOP,<LF> testDBSIZE,<LF> testDECR,<LF> testDECRBY,<LF> testDEL,<LF> testEXISTS,<LF> testEXPIRE,<LF> testFLUSHALL,<LF> testFLUSHDB,<LF> testGET,<LF> testGETSET,<LF> testHDEL, <LF> testHEXISTS,<LF> testHGET,<LF> testHGETALL,<LF> testHINCRBY,<LF> testHKEYS,<LF> testHLEN,<LF> testHSET,<LF> testHVALS,<LF> testINCR,<LF> testINCRBY,<LF> testINFO,<LF> testKEYS,<LF> testLASTSAVE,<LF> testLINDEX,<LF> testLLEN,<LF> testLPOP,<LF> testLPUSH,<LF> testLRANGE,<LF> testLREM,<LF> testLSET,<LF> testLTRIM,<LF> testMGET,<LF> testMOVE,<LF> testMSET,<LF> testMSETNX,<LF> testParseBulkReply,<LF> testParseErrorReply,<LF> testParseInlineReply,<LF> testParseIntegerReply,<LF> testParseMultiBulkReply,<LF> testPSUBSCRIBE,<LF> testPUBLISH,<LF> testPUNSUBSCRIBE,<LF> testRANDOMKEY,<LF> testRENAME,<LF> testRENAMENX,<LF> testRPOP,<LF> testRPOPLPUSH,<LF> testRPUSH,<LF> testSADD,<LF> testSAVE,<LF> testSCARD,<LF> testSDIFF,<LF> testSDIFFSTORE,<LF> testSELECT,<LF> testSET,<LF> testSETANDGETMULTIBYTE,<LF> testSETNX,<LF> testSHUTDOWN,<LF> testSINTER,<LF> testSINTERSTORE,<LF> testSISMEMBER,<LF> testSMEMBERS,<LF> testSMOVE,<LF> testSORT,<LF> testSPOP,<LF> testSREM,<LF> testSUBSCRIBE,<LF> testSUNION,<LF> testSUNIONSTORE,<LF> testTTL,<LF> testTYPE,<LF> testUNSUBSCRIBE,<LF> testZADD,<LF> testZCARD,<LF> testZCOUNT,<LF> testZINCRBY,<LF> testZINTER,<LF> testZRANGE,<LF> testZRANGEBYSCORE,<LF> testZRANK,<LF> testZREM,<LF> testZREMRANGEBYRANK,<LF> testZREMRANGEBYSCORE,<LF> testZREVRANGE,<LF> testZREVRANK,<LF> testZSCORE,<LF> testZUNION,<LF>];<LF><LF>function checkIfDone() {<LF> if (client.originalCommands.length == 0) {<LF> testSUBSCRIBEandPUBLISH();<LF> <LF> var checks = 0;<LF> setInterval(function () {<LF> if (messageWasReceived) {<LF> sys.error("\n");<LF> log("info", "All tests have passed.");<LF> process.exit(0);<LF> } else {<LF> assert.notEqual(++checks, 5, "testSUBSCRIBEandPUBLISH never received message");<LF> } <LF> }, 100);<LF> } else {<LF> if (verbose)<LF> log('info', client.originalCommands.length + " replies still pending...");<LF> else if (!quiet)<LF> sys.print("+");<LF> }<LF>}<LF><LF>function runAllTests() {<LF> allTestFunctions.forEach(function (testFunction) {<LF> if (verbose) {<LF> sys.error("");<LF> log("info", "Testing " + testFunction.name.replace(/^test/, ''));<LF> sys.error("=========================================");<LF> } else if (!quiet) {<LF> sys.print(".");<LF> }<LF><LF> clearTestDatabasesBeforeEachTest();<LF> testFunction();<LF> });<LF><LF> setInterval(checkIfDone, 1500);<LF> setTimeout(function() {<LF> log("error", "Tests timed out");<LF> process.exit(1);<LF> }, MAX_TEST_TIME);<LF>}<LF><LF>var connectionFailed = false;<LF>var client = redisclient.createClient();<LF>client.stream.addListener("connect", runAllTests);<LF>client.stream.addListener("close", function (inError) {<LF> connectionFailed = inError;<LF> if (inError)<LF> throw new Error("Connection to Redis failed. Not attempting reconnection.");<LF>});<LF><LF>function debugFilter(what) {<LF> var filtered = what;<LF><LF> filtered = filtered.replace(/\r\n/g, '<CRLF>');<LF> filtered = filtered.replace(/\r/g, '<CR>');<LF> filtered = filtered.replace(/\n/g, '<LF>');<LF><LF> return filtered;<LF>}<LF><LF>function printDisclaimer() {<LF> if (redisclient.debugMode) <LF> sys.debug("This test does not do anything");<LF>}<LF><LF><CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>get<CRLF>$13<CRLF>largetestfile<CRLF>
[INFO] Testing GETSET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$9<CRLF>getsetfoo<CRLF>$9<CRLF>getsetbar<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>getset<CRLF>$9<CRLF>getsetfoo<CRLF>$4<CRLF>fuzz<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>get<CRLF>$9<CRLF>getsetfoo<CRLF>
[INFO] Testing HDEL
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>hdel<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>hdel<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
[INFO] Testing HEXISTS
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$4<CRLF>hfoo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$7<CRLF>hexists<CRLF>$4<CRLF>hfoo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$7<CRLF>hexists<CRLF>$4<CRLF>hfoo<CRLF>$3<CRLF>baz<CRLF>
[INFO] Testing HGET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>hget<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
[INFO] Testing HGETALL
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$4<CRLF>quux<CRLF>$3<CRLF>doo<CRLF>
DEBUG: [SEND] *2<CRLF>$7<CRLF>hgetall<CRLF>$3<CRLF>foo<CRLF>
[INFO] Testing HINCRBY
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$7<CRLF>hincrby<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>hget<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *4<CRLF>$7<CRLF>hincrby<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>hget<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
[INFO] Testing HKEYS
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$4<CRLF>quux<CRLF>$3<CRLF>doo<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>hkeys<CRLF>$3<CRLF>foo<CRLF>
[INFO] Testing HLEN
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>hlen<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>hlen<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$4<CRLF>quux<CRLF>$3<CRLF>doo<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>hlen<CRLF>$3<CRLF>foo<CRLF>
[INFO] Testing HSET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>hget<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
[INFO] Testing HVALS
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>hset<CRLF>$3<CRLF>foo<CRLF>$4<CRLF>quux<CRLF>$3<CRLF>doo<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>hvals<CRLF>$3<CRLF>foo<CRLF>
[INFO] Testing INCR
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$7<CRLF>counter<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$7<CRLF>counter<CRLF>
[INFO] Testing INCRBY
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>incrby<CRLF>$7<CRLF>counter<CRLF>$1<CRLF>2<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>incrby<CRLF>$7<CRLF>counter<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing INFO
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *1<CRLF>$4<CRLF>info<CRLF>
[INFO] Testing KEYS
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$4<CRLF>foo1<CRLF>$9<CRLF>foo1Value<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$4<CRLF>foo2<CRLF>$9<CRLF>foo2Value<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>keys<CRLF>$4<CRLF>foo*<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>baz<CRLF>$8<CRLF>bazValue<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>boo<CRLF>$8<CRLF>booValue<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>keys<CRLF>$1<CRLF>*<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>keys<CRLF>$3<CRLF>?oo<CRLF>
[INFO] Testing LASTSAVE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *1<CRLF>$8<CRLF>lastsave<CRLF>
[INFO] Testing LINDEX
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value0<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value1<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>lindex<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>lindex<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>lindex<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>2<CRLF>
[INFO] Testing LLEN
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value0<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>llen<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value1<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>llen<CRLF>$5<CRLF>list0<CRLF>
[INFO] Testing LPOP
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>DEF<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>GHI<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>lpop<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>lpop<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing LPUSH
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$5<CRLF>list1<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list1<CRLF>$11<CRLF>list1value0<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$5<CRLF>list1<CRLF>
[INFO] Testing LRANGE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value0<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value1<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$1<CRLF>0<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>list0<CRLF>$2<CRLF>-1<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing LREM
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>DEF<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>lrem<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>1<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing LSET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value0<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>lset<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$11<CRLF>LIST0VALUE0<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$1<CRLF>0<CRLF>
[INFO] Testing LTRIM
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value0<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value1<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value2<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>llen<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *4<CRLF>$5<CRLF>ltrim<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$1<CRLF>1<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>llen<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing MGET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>buz<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>mget<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>baz<CRLF>
[INFO] Testing MOVE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>move<CRLF>$5<CRLF>list0<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$5<CRLF>list0<CRLF>
[INFO] Testing MSET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *7<CRLF>$4<CRLF>mset<CRLF>$1<CRLF>a<CRLF>$1<CRLF>b<CRLF>$1<CRLF>c<CRLF>$1<CRLF>d<CRLF>$1<CRLF>e<CRLF>$3<CRLF>100<CRLF>
[INFO] Testing MSETNX
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *7<CRLF>$4<CRLF>mset<CRLF>$1<CRLF>a<CRLF>$1<CRLF>b<CRLF>$1<CRLF>c<CRLF>$1<CRLF>d<CRLF>$1<CRLF>e<CRLF>$3<CRLF>100<CRLF>
DEBUG: [SEND] *5<CRLF>$6<CRLF>msetnx<CRLF>$1<CRLF>g<CRLF>$1<CRLF>h<CRLF>$1<CRLF>a<CRLF>$1<CRLF>i<CRLF>
DEBUG: [SEND] *5<CRLF>$6<CRLF>msetnx<CRLF>$1<CRLF>g<CRLF>$1<CRLF>h<CRLF>$1<CRLF>i<CRLF>$1<CRLF>j<CRLF>
[INFO] Testing ParseBulkReply
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
[INFO] Testing ParseErrorReply
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
[INFO] Testing ParseInlineReply
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
[INFO] Testing ParseIntegerReply
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
[INFO] Testing ParseMultiBulkReply
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
[INFO] Testing PSUBSCRIBE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$10<CRLF>psubscribe<CRLF>$9<CRLF>cooking.*<CRLF>
DEBUG: [SEND] *2<CRLF>$12<CRLF>punsubscribe<CRLF>$9<CRLF>cooking.*<CRLF>
[INFO] Testing PUBLISH
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$7<CRLF>publish<CRLF>$6<CRLF>#redis<CRLF>$13<CRLF>Hello, world!<CRLF>
[INFO] Testing PUNSUBSCRIBE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing RANDOMKEY
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>buz<CRLF>
DEBUG: [SEND] *1<CRLF>$9<CRLF>randomkey<CRLF>
[INFO] Testing RENAME
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>rename<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>zoo<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>zoo<CRLF>
[INFO] Testing RENAMENX
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>roo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$8<CRLF>renamenx<CRLF>$3<CRLF>roo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>roo<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$8<CRLF>renamenx<CRLF>$3<CRLF>roo<CRLF>$3<CRLF>too<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>roo<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$3<CRLF>too<CRLF>
[INFO] Testing RPOP
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>lpush<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>DEF<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>rpop<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>rpop<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>llen<CRLF>$5<CRLF>list0<CRLF>
[INFO] Testing RPOPLPUSH
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$3<CRLF>src<CRLF>$3<CRLF>ABC<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$3<CRLF>src<CRLF>$3<CRLF>DEF<CRLF>
DEBUG: [SEND] *3<CRLF>$9<CRLF>rpoplpush<CRLF>$3<CRLF>src<CRLF>$3<CRLF>dst<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$3<CRLF>src<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$3<CRLF>dst<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing RPUSH
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$11<CRLF>list0value0<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$5<CRLF>list0<CRLF>
[INFO] Testing SADD
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member0<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member0<CRLF>
[INFO] Testing SAVE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *1<CRLF>$4<CRLF>save<CRLF>
[INFO] Testing SCARD
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member0<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>scard<CRLF>$4<CRLF>set0<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member1<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>scard<CRLF>$4<CRLF>set0<CRLF>
[INFO] Testing SDIFF
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>bar<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>baz<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>baz<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *4<CRLF>$5<CRLF>sdiff<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
[INFO] Testing SDIFFSTORE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>bar<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>baz<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>baz<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *5<CRLF>$10<CRLF>sdiffstore<CRLF>$4<CRLF>quux<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *2<CRLF>$8<CRLF>smembers<CRLF>$4<CRLF>quux<CRLF>
[INFO] Testing SELECT
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing SET
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>buz<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>ggg<CRLF>$3<CRLF>123<CRLF>
[INFO] Testing SETANDGETMULTIBYTE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$11<CRLF>testUtf8Key<CRLF>$11<CRLF>ö日本語<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>get<CRLF>$11<CRLF>testUtf8Key<CRLF>
[INFO] Testing SETNX
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>setnx<CRLF>$3<CRLF>foo<CRLF>$4<CRLF>quux<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>setnx<CRLF>$3<CRLF>boo<CRLF>$5<CRLF>apple<CRLF>
[INFO] Testing SHUTDOWN
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing SINTER
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>e<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>sinter<CRLF>$2<CRLF>sa<CRLF>$2<CRLF>sb<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>sinter<CRLF>$2<CRLF>sb<CRLF>$2<CRLF>sc<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>sinter<CRLF>$2<CRLF>sa<CRLF>$2<CRLF>sc<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>sinter<CRLF>$2<CRLF>sa<CRLF>$2<CRLF>sb<CRLF>$2<CRLF>sc<CRLF>
[INFO] Testing SINTERSTORE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>e<CRLF>
DEBUG: [SEND] *5<CRLF>$11<CRLF>sinterstore<CRLF>$3<CRLF>foo<CRLF>$2<CRLF>sa<CRLF>$2<CRLF>sb<CRLF>$2<CRLF>sc<CRLF>
DEBUG: [SEND] *2<CRLF>$8<CRLF>smembers<CRLF>$3<CRLF>foo<CRLF>
[INFO] Testing SISMEMBER
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member0<CRLF>
DEBUG: [SEND] *3<CRLF>$9<CRLF>sismember<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member0<CRLF>
DEBUG: [SEND] *3<CRLF>$9<CRLF>sismember<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member1<CRLF>
[INFO] Testing SMEMBERS
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *2<CRLF>$8<CRLF>smembers<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>y<CRLF>
DEBUG: [SEND] *2<CRLF>$8<CRLF>smembers<CRLF>$3<CRLF>foo<CRLF>
[INFO] Testing SMOVE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *4<CRLF>$5<CRLF>smove<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *3<CRLF>$9<CRLF>sismember<CRLF>$3<CRLF>foo<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *3<CRLF>$9<CRLF>sismember<CRLF>$3<CRLF>bar<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *4<CRLF>$5<CRLF>smove<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$1<CRLF>x<CRLF>
[INFO] Testing SORT
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>y<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>y<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>y<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>y<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>x<CRLF>$1<CRLF>3<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>x<CRLF>$1<CRLF>9<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>x<CRLF>$1<CRLF>2<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$1<CRLF>x<CRLF>$1<CRLF>4<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>w3<CRLF>$1<CRLF>4<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>w9<CRLF>$1<CRLF>5<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>w2<CRLF>$2<CRLF>12<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>w4<CRLF>$1<CRLF>6<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>o2<CRLF>$3<CRLF>buz<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>o3<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>o4<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>o9<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>p2<CRLF>$3<CRLF>qux<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>p3<CRLF>$3<CRLF>bux<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>p4<CRLF>$3<CRLF>lux<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$2<CRLF>p9<CRLF>$3<CRLF>tux<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>y<CRLF>$3<CRLF>asc<CRLF>$5<CRLF>alpha<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>y<CRLF>$4<CRLF>desc<CRLF>$5<CRLF>alpha<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>x<CRLF>$3<CRLF>asc<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>x<CRLF>$4<CRLF>desc<CRLF>
DEBUG: [SEND] *5<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>x<CRLF>$2<CRLF>by<CRLF>$2<CRLF>w*<CRLF>$3<CRLF>asc<CRLF>
DEBUG: [SEND] *7<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>x<CRLF>$2<CRLF>by<CRLF>$2<CRLF>w*<CRLF>$3<CRLF>asc<CRLF>$3<CRLF>get<CRLF>$2<CRLF>o*<CRLF>
DEBUG: [SEND] *9<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>x<CRLF>$2<CRLF>by<CRLF>$2<CRLF>w*<CRLF>$3<CRLF>asc<CRLF>$3<CRLF>get<CRLF>$2<CRLF>o*<CRLF>$3<CRLF>get<CRLF>$2<CRLF>p*<CRLF>
DEBUG: [SEND] *11<CRLF>$4<CRLF>sort<CRLF>$1<CRLF>x<CRLF>$2<CRLF>by<CRLF>$2<CRLF>w*<CRLF>$3<CRLF>asc<CRLF>$3<CRLF>get<CRLF>$2<CRLF>o*<CRLF>$3<CRLF>get<CRLF>$2<CRLF>p*<CRLF>$5<CRLF>store<CRLF>$5<CRLF>bacon<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>lrange<CRLF>$5<CRLF>bacon<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing SPOP
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$3<CRLF>zzz<CRLF>$7<CRLF>member0<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>scard<CRLF>$3<CRLF>zzz<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>spop<CRLF>$3<CRLF>zzz<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>scard<CRLF>$3<CRLF>zzz<CRLF>
[INFO] Testing SREM
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member0<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>srem<CRLF>$4<CRLF>set0<CRLF>$6<CRLF>foobar<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>srem<CRLF>$4<CRLF>set0<CRLF>$7<CRLF>member0<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>scard<CRLF>$4<CRLF>set0<CRLF>
[INFO] Testing SUBSCRIBE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$9<CRLF>subscribe<CRLF>$6<CRLF>#redis<CRLF>
DEBUG: [SEND] *2<CRLF>$9<CRLF>subscribe<CRLF>$8<CRLF>#Node.js<CRLF>
DEBUG: [SEND] *2<CRLF>$11<CRLF>unsubscribe<CRLF>$6<CRLF>#redis<CRLF>
DEBUG: [SEND] *2<CRLF>$11<CRLF>unsubscribe<CRLF>$8<CRLF>#Node.js<CRLF>
[INFO] Testing SUNION
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>e<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>sunion<CRLF>$2<CRLF>sa<CRLF>$2<CRLF>sb<CRLF>$2<CRLF>sc<CRLF>
[INFO] Testing SUNIONSTORE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sb<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>d<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sc<CRLF>$1<CRLF>e<CRLF>
DEBUG: [SEND] *5<CRLF>$11<CRLF>sunionstore<CRLF>$3<CRLF>foo<CRLF>$2<CRLF>sa<CRLF>$2<CRLF>sb<CRLF>$2<CRLF>sc<CRLF>
DEBUG: [SEND] *2<CRLF>$8<CRLF>smembers<CRLF>$3<CRLF>foo<CRLF>
[INFO] Testing TTL
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$6<CRLF>ttlfoo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>ttl<CRLF>$6<CRLF>ttlfoo<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$6<CRLF>ttlbar<CRLF>$3<CRLF>baz<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>expire<CRLF>$6<CRLF>ttlbar<CRLF>$1<CRLF>3<CRLF>
DEBUG: [SEND] *2<CRLF>$3<CRLF>ttl<CRLF>$6<CRLF>ttlbar<CRLF>
[INFO] Testing TYPE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>sadd<CRLF>$2<CRLF>sa<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>type<CRLF>$2<CRLF>sa<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>rpush<CRLF>$5<CRLF>list0<CRLF>$1<CRLF>x<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>type<CRLF>$5<CRLF>list0<CRLF>
DEBUG: [SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>type<CRLF>$3<CRLF>foo<CRLF>
DEBUG: [SEND] *2<CRLF>$4<CRLF>type<CRLF>$3<CRLF>xxx<CRLF>
[INFO] Testing UNSUBSCRIBE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: This test does not do anything
[INFO] Testing ZADD
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>50<CRLF>$2<CRLF>m0<CRLF>
[INFO] Testing ZCARD
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>zcard<CRLF>$6<CRLF>zzzzzz<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>200<CRLF>$2<CRLF>m1<CRLF>
DEBUG: [SEND] *2<CRLF>$5<CRLF>zcard<CRLF>$2<CRLF>z0<CRLF>
[INFO] Testing ZCOUNT
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>zcount<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>0<CRLF>$3<CRLF>100<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>zcount<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>0<CRLF>$3<CRLF>100<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>zcount<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>0<CRLF>$3<CRLF>100<CRLF>
[INFO] Testing ZINCRBY
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$7<CRLF>zincrby<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
[INFO] Testing ZINTER
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z1<CRLF>$1<CRLF>3<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *7<CRLF>$6<CRLF>zinter<CRLF>$2<CRLF>z2<CRLF>$1<CRLF>2<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>z1<CRLF>$9<CRLF>AGGREGATE<CRLF>$3<CRLF>SUM<CRLF>
DEBUG: [SEND] *5<CRLF>$6<CRLF>zrange<CRLF>$2<CRLF>z2<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>$10<CRLF>WITHSCORES<CRLF>
[INFO] Testing ZRANGE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>200<CRLF>$2<CRLF>m1<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>300<CRLF>$2<CRLF>m2<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>zrange<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>zrange<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>-1<CRLF>$2<CRLF>-1<CRLF>
DEBUG: [SEND] *4<CRLF>$6<CRLF>zrange<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>-2<CRLF>$2<CRLF>-1<CRLF>
[INFO] Testing ZRANGEBYSCORE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>200<CRLF>$2<CRLF>m1<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>300<CRLF>$2<CRLF>m2<CRLF>
DEBUG: [SEND] *4<CRLF>$13<CRLF>zrangebyscore<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>200<CRLF>$3<CRLF>300<CRLF>
DEBUG: [SEND] *4<CRLF>$13<CRLF>zrangebyscore<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$4<CRLF>1000<CRLF>
DEBUG: [SEND] *4<CRLF>$13<CRLF>zrangebyscore<CRLF>$2<CRLF>z0<CRLF>$5<CRLF>10000<CRLF>$6<CRLF>100000<CRLF>
[INFO] Testing ZRANK
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>3<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>zrank<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>zrank<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$5<CRLF>zrank<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>c<CRLF>
[INFO] Testing ZREM
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>zrem<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *3<CRLF>$4<CRLF>zrem<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>m0<CRLF>
[INFO] Testing ZREMRANGEBYRANK
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>3<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *4<CRLF>$15<CRLF>zremrangebyrank<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>-1<CRLF>$2<CRLF>-1<CRLF>
DEBUG: [SEND] *5<CRLF>$6<CRLF>zrange<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>$10<CRLF>WITHSCORES<CRLF>
[INFO] Testing ZREMRANGEBYSCORE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>3<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *4<CRLF>$16<CRLF>zremrangebyscore<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>3<CRLF>
DEBUG: [SEND] *5<CRLF>$6<CRLF>zrange<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>$10<CRLF>WITHSCORES<CRLF>
[INFO] Testing ZREVRANGE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>200<CRLF>$2<CRLF>m1<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>300<CRLF>$2<CRLF>m2<CRLF>
DEBUG: [SEND] *4<CRLF>$9<CRLF>zrevrange<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>0<CRLF>$4<CRLF>1000<CRLF>
[INFO] Testing ZREVRANK
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>3<CRLF>$1<CRLF>c<CRLF>
DEBUG: [SEND] *3<CRLF>$8<CRLF>zrevrank<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *3<CRLF>$8<CRLF>zrevrank<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *3<CRLF>$8<CRLF>zrevrank<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>c<CRLF>
[INFO] Testing ZSCORE
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>100<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$3<CRLF>200<CRLF>$2<CRLF>m1<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>zscore<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>m0<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>zscore<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>m1<CRLF>
DEBUG: [SEND] *3<CRLF>$6<CRLF>zscore<CRLF>$2<CRLF>z0<CRLF>$7<CRLF>zzzzzzz<CRLF>
[INFO] Testing ZUNION
=========================================
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>14<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>select<CRLF>$2<CRLF>15<CRLF>
DEBUG: [SEND] *1<CRLF>$7<CRLF>flushdb<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>1<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z0<CRLF>$1<CRLF>2<CRLF>$1<CRLF>b<CRLF>
DEBUG: [SEND] *4<CRLF>$4<CRLF>zadd<CRLF>$2<CRLF>z1<CRLF>$1<CRLF>3<CRLF>$1<CRLF>a<CRLF>
DEBUG: [SEND] *7<CRLF>$6<CRLF>zunion<CRLF>$2<CRLF>z2<CRLF>$1<CRLF>2<CRLF>$2<CRLF>z0<CRLF>$2<CRLF>z1<CRLF>$9<CRLF>AGGREGATE<CRLF>$3<CRLF>SUM<CRLF>
DEBUG: [SEND] *5<CRLF>$6<CRLF>zrange<CRLF>$2<CRLF>z2<CRLF>$1<CRLF>0<CRLF>$2<CRLF>-1<CRLF>$10<CRLF>WITHSCORES<CRLF>
DEBUG: [RECV] +OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>*2<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>:1<CRLF>*2<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>
[INFO] 727 replies still pending...
DEBUG: [RECV] *-1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>*2<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>ABC<CRLF>:2<CRLF>*2<CRLF>$5<CRLF>list0<CRLF>$3<CRLF>DEF<CRLF>
DEBUG: [SEND] *2<CRLF>$6<CRLF>exists<CRLF>$6<CRLF>expfoo<CRLF>
[INFO] 718 replies still pending...
DEBUG: [RECV] *-1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:-1<CRLF>:-2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:-1<CRLF>:-3<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:0<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>buz<CRLF>+OK<CRLF>$62863<CRLF>
DEBUG: [RECV] #!/usr/bin/env node<LF><LF>/*<LF> Redis client for Node.js -- tests<LF><LF> Copyright (C) 2010 Fictorial LLC.<LF><LF> Permission is hereby granted, free of charge, to any person obtaining<LF> a copy of this software and associated documentation files (the<LF> "Software"), to deal in the Software without restriction, including without<LF> limitation the rights to use, copy, modify, merge, publish, distribute,<LF> sublicense, and/or sell copies of the Software, and to permit persons to<LF> whom the Software is furnished to do so, subject to the following<LF> conditions:<LF><LF> The above copyright notice and this permission notice shall be included in<LF> all copies or substantial portions of the Software.<LF><LF> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<LF> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<LF> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<LF> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<LF> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<LF> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<LF> DEALINGS IN THE SOFTWARE.<LF>*/<LF><LF>// http://github.com/fictorial/redis-node-client<LF>// Brian Hammond <brian at fictorial dot com><LF><LF>// NOTE: this test suite uses databases 14 and 15 for test purposes! <LF>// Make sure your Redis instance has at least this many databases; the default has 16.<LF>// These databases will be flushed these databases at the start of each test run. <LF>// If you want to use a different database number, update TEST_DB_NUMBER* below.<LF><LF>// NOTE: each test is responsible for configuring the dataset needed to <LF>// run that test. There are no "fixtures" or similar.<LF><LF>var TEST_DB_NUMBER = 15,<LF> TEST_DB_NUMBER_FOR_MOVE = 14;<LF><LF>var MAX_TEST_TIME = 20000;<LF><LF>var sys = require("sys"),<LF> assert = require("assert"),<LF> redisclient = require("../lib/redis-client"),<LF> fs = require("fs"),<LF> Buffer = require("buffer").Buffer;<LF><LF>var verbose = process.argv.indexOf("-v") != -1;<LF>var quiet = process.argv.indexOf("-q") != -1;<LF><LF>redisclient.debugMode = verbose && !quiet;<LF><LF>function log(level, msg) {<LF> var colorsForLevel = { info:37, warn:33, error:31 };<LF> sys.error("\033[" + colorsForLevel[level || 'info'] + "m[" + <LF> level.toUpperCase() + "] " + msg + "\033[0m");<LF>}<LF><LF>function showContext(context) {<LF> sys.error("\n");<LF> log('error', context + " FAILED!");<LF> sys.error("");<LF>}<LF><LF>// These wrappers around the assert module exist because we generate functions<LF>// to test for expected conditions which lose context, and assert's functions<LF>// use the 'message' in place of the failed condition.<LF><LF>function checkEqual(actual, expected, context) {<LF> try {<LF> assert.equal(actual, expected);<LF> } catch (e) {<LF> showContext(context);<LF> throw e;<LF> }<LF>}<LF><LF>function check(what, context) {<LF> try {<LF> assert.ok(what);<LF> } catch (e) {<LF> showContext(context);<LF> throw e;<LF> }<LF>}<LF><LF>function checkDeepEqual(actual, expected, context) {<LF> try {<LF> assert.deepEqual(actual, expected);<LF> } catch (e) {<LF> showContext(context);<LF> throw e;<LF> }<LF>}<LF><LF>// Redis' protocol returns +OK for some operations to mean "true" or "success".<LF>// The client converts this into a boolean with value true.<LF><LF>function expectOK(context) {<LF> return function (err, truthiness) {<LF> if (err) assert.fail(err, context);<LF> checkEqual(typeof(truthiness), 'boolean', context);<LF> checkEqual(truthiness, true, context);<LF> };<LF>}<LF><LF>function maybeAsNumber(str) {<LF> var value = parseInt(str, 10);<LF><LF> if (isNaN(value)) <LF> value = parseFloat(str);<LF><LF> if (isNaN(value)) <LF> return str;<LF><LF> return value;<LF>}<LF><LF>function expectNumber(expectedValue, context) {<LF> return function (err, reply) {<LF> if (err) assert.fail(err, context);<LF> var value = maybeAsNumber(reply);<LF> checkEqual(value, expectedValue, context);<LF> };<LF>}<LF><LF>function clearTestDatabasesBeforeEachTest() {<LF> client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK("select"));<LF> client.flushdb(expectOK("flushdb"));<LF><LF> client.select(TEST_DB_NUMBER, expectOK("select"));<LF> client.flushdb(expectOK("flushdb"));<LF>}<LF><LF>function bufferFromString(str, encoding) {<LF> var enc = encoding || 'utf8';<LF> var buf = new Buffer(str.length);<LF> switch (enc) {<LF> case 'utf8': buf.utf8Write(str); break;<LF> case 'ascii': buf.asciiWrite(str); break;<LF> case 'binary': buf.binaryWrite(str); break;<LF> default: <LF> assert.fail("unknown encoding: " + encoding);<LF> }<LF> return buf;<LF>}<LF><LF>function testParseBulkReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.BULK, "testParseBulkReply a-0");<LF> check(reply.value instanceof Buffer, "testParseBulkReply a-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), "FOOBAR", "testParseBulkReply a-2");<LF> });<LF> a.feed(bufferFromString("$6\r\nFOOBAR\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.BULK, "testParseBulkReply b-0");<LF> checkEqual(reply.value, null, "testParseBulkReply b-1");<LF> });<LF> b.feed(bufferFromString("$-1\r\n"));<LF>}<LF><LF>Buffer.prototype.toString=function() {<LF> return this.utf8Slice(0,this.length);<LF>}<LF><LF>function testParseMultiBulkReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply a-0");<LF> check(reply.value instanceof Array, "testParseMultiBulkReply a-1");<LF> checkEqual(reply.value.length, 4, "testParseMultiBulkReply a-2");<LF> check(reply.value[0].type === redisclient.BULK, "testParseMultiBulkReply a-3");<LF> check(reply.value[1].type === redisclient.BULK, "testParseMultiBulkReply a-4");<LF> check(reply.value[2].type === redisclient.BULK, "testParseMultiBulkReply a-5");<LF> check(reply.value[3].type === redisclient.BULK, "testParseMultiBulkReply a-6");<LF> check(reply.value[0].value instanceof Buffer, "testParseMultiBulkReply a-7");<LF> check(reply.value[1].value instanceof Buffer, "testParseMultiBulkReply a-8");<LF> check(reply.value[2].value instanceof Buffer, "testParseMultiBulkReply a-9");<LF> check(reply.value[3].value instanceof Buffer, "testParseMultiBulkReply a-10");<LF> checkEqual(reply.value[0].value.length, 3, "testParseMultiBulkReply a-11");<LF> checkEqual(reply.value[1].value.length, 3, "testParseMultiBulkReply a-12");<LF> checkEqual(reply.value[2].value.length, 5, "testParseMultiBulkReply a-13");<LF> checkEqual(reply.value[3].value.length, 6, "testParseMultiBulkReply a-14");<LF> checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', "testParseMultiBulkReply a-15");<LF> checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), 'BAR', "testParseMultiBulkReply a-16");<LF> checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'HELLO', "testParseMultiBulkReply a-17");<LF> checkEqual(reply.value[3].value.utf8Slice(0, reply.value[3].value.length), 'WORLD!', "testParseMultiBulkReply a-18");<LF> });<LF> a.feed(bufferFromString("*4\r\n$3\r\nFOO\r\n$3\r\nBAR\r\n$5\r\nHELLO\r\n$6\r\nWORLD!\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply b-0");<LF> checkEqual(reply.value, null, "testParseMultiBulkReply b-1");<LF> });<LF> b.feed(bufferFromString("*-1\r\n"));<LF><LF> var c = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply c-0");<LF> check(reply.value instanceof Array, "testParseMultiBulkReply c-1");<LF> checkEqual(reply.value.length, 3, "testParseMultiBulkReply c-2");<LF> check(reply.value[0].type === redisclient.BULK, "testParseMultiBulkReply c-3");<LF> check(reply.value[1].type === redisclient.BULK, "testParseMultiBulkReply c-4");<LF> check(reply.value[2].type === redisclient.BULK, "testParseMultiBulkReply c-5");<LF> checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', "testParseMultiBulkReply c-6");<LF> checkEqual(reply.value[1].value, null, "testParseMultiBulkReply c-7");<LF> checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'BARZ', "testParseMultiBulkReply c-8");<LF> });<LF> c.feed(bufferFromString("*3\r\n$3\r\nFOO\r\n$-1\r\n$4\r\nBARZ\r\n"));<LF><LF> // Test with a multi-bulk reply containing a subreply that's non-bulk<LF> // but an inline/integer reply instead.<LF><LF> var d = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply d-0");<LF> check(reply.value instanceof Array, "testParseMultiBulkReply d-1");<LF> checkEqual(reply.value.length, 3, "testParseMultiBulkReply d-2");<LF> check(reply.value[0].type === redisclient.BULK, "testParseMultiBulkReply d-3");<LF> check(reply.value[1].type === redisclient.BULK, "testParseMultiBulkReply d-4");<LF> check(reply.value[2].type === redisclient.INTEGER, "testParseMultiBulkReply d-5");<LF> check(reply.value[0].value instanceof Buffer, "testParseMultiBulkReply d-6");<LF> check(reply.value[1].value instanceof Buffer, "testParseMultiBulkReply d-7");<LF> checkEqual(typeof(reply.value[2].value), "number", "testParseMultiBulkReply d-8");<LF> checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'subscribe', "testParseMultiBulkReply d-9");<LF> checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), '#redis', "testParseMultiBulkReply d-10");<LF> checkEqual(reply.value[2].value, 1, "testParseMultiBulkReply d-11");<LF> });<LF> d.feed(bufferFromString("*3\r\n$9\r\nsubscribe\r\n$6\r\n#redis\r\n:1\r\n*3\r\n$7\r\nmessage\r\n"));<LF><LF> var e = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.MULTIBULK, "testParseMultiBulkReply e-0");<LF> checkEqual(reply.value, null, "testParseMultiBulkReply e-1");<LF> });<LF> e.feed(bufferFromString("*0\r\n"));<LF>}<LF><LF>function testParseInlineReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> // maybeConvertReplyValue is called by redisclient for non-test calls<LF> reply.value = redisclient.maybeConvertReplyValue_('N/A', reply); <LF> checkEqual(reply.type, redisclient.INLINE, "testParseInlineReply a-0");<LF> checkEqual(typeof(reply.value), 'boolean', "testParseInlineReply a-1");<LF> checkEqual(reply.value, true, "testParseInlineReply a-2");<LF> });<LF> a.feed(bufferFromString("+OK\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.INLINE, "testParseInlineReply b-0");<LF> check(reply.value instanceof Buffer, "testParseInlineReply b-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), 'WHATEVER', "testParseInlineReply b-2");<LF> });<LF> b.feed(bufferFromString("+WHATEVER\r\n"));<LF>}<LF><LF>function testParseIntegerReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.INTEGER, "testParseIntegerReply a-0");<LF> checkEqual(typeof(reply.value), 'number', "testParseIntegerReply a-1");<LF> checkEqual(reply.value, -1, "testParseIntegerReply a-2");<LF> });<LF> a.feed(bufferFromString(":-1\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.INTEGER, "testParseIntegerReply b-0");<LF> checkEqual(typeof(reply.value), 'number', "testParseIntegerReply b-1");<LF> checkEqual(reply.value, 1000, "testParseIntegerReply b-2");<LF> });<LF> b.feed(bufferFromString(":1000\r\n"));<LF>}<LF><LF>function testParseErrorReply() {<LF> var a = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.ERROR, "testParseErrorReply c-0");<LF> check(reply.value instanceof Buffer, "testParseErrorReply c-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), "ERR solar flare", "testParseErrorReply c-2");<LF> });<LF> a.feed(bufferFromString("-ERR solar flare\r\n"));<LF><LF> var b = new redisclient.ReplyParser(function (reply) {<LF> checkEqual(reply.type, redisclient.ERROR, "testParseErrorReply b-0");<LF> check(reply.value instanceof Buffer, "testParseErrorReply b-1");<LF> checkEqual(reply.value.utf8Slice(0, reply.value.length), "hiccup", "testParseErrorReply b-2");<LF> });<LF> b.feed(bufferFromString("-hiccup\r\n"));<LF>}<LF><LF>function testAUTH() {<LF> // You need to configure redis to enable auth.<LF> // This unit test suite assumes the auth feature is off/disabled.<LF> // Auth *would be* the first command required after connecting.<LF><LF> printDisclaimer();<LF>}<LF><LF>function testSELECT() {<LF> printDisclaimer();<LF>}<LF><LF>function testFLUSHDB() {<LF> // no-op; tested in testSelect<LF><LF> printDisclaimer();<LF>}<LF><LF>function testSET() {<LF> client.set('foo', 'bar', expectOK("testSET"));<LF> client.set('baz', 'buz', expectOK("testSET"));<LF> client.set('ggg', '123', expectOK("testSET"));<LF>}<LF><LF>function testSETNX() {<LF> client.set('foo', 'bar', expectOK("testSETNX"));<LF> client.setnx('foo', 'quux', expectNumber(0, "testSETNX")); // fails when already set<LF> client.setnx('boo', 'apple', expectNumber(1, "testSETNX")); // no such key already so OK<LF>}<LF><LF>function testGET() {<LF> client.set('foo', 'bar', expectOK("testGET"));<LF> client.set('baz', 'buz', expectOK("testGET"));<LF><LF> client.get('foo', function (err, value) {<LF> if (err) assert.fail(err, "testGET");<LF> checkEqual(value, 'bar', "testGET");<LF> });<LF><LF> client.get('baz', function (err, value) {<LF> if (err) assert.fail(err, "testGET");<LF> checkEqual(value, 'buz', "testGET");<LF> });<LF><LF> // Check buffer resizing of input buffer<LF> // by loading really large data and reading<LF> // it back. We use ourselves<LF> var large = fs.readFileSync(__filename);<LF> client.set('largetestfile', large);<LF><LF> client.get('largetestfile', function(err, value) {<LF> if (err) assert.fail(err, "testGET");<LF> checkEqual(value.utf8Slice(0,value.length), large, "testGET");<LF> });<LF>}<LF><LF>function testMGET() {<LF> client.set('foo', 'bar', expectOK("testMGET"));<LF> client.set('baz', 'buz', expectOK("testMGET"));<LF><LF> client.mget('foo', 'baz', function (err, values) {<LF> if (err) assert.fail(err, "testMGET");<LF> checkEqual(values[0], 'bar', "testMGET");<LF> checkEqual(values[1], 'buz', "testMGET");<LF> });<LF>}<LF><LF>function testGETSET() {<LF> client.set('getsetfoo', 'getsetbar', expectOK("testGETSET 0"));<LF><LF> client.getset('getsetfoo', 'fuzz', function (err, previousValue) {<LF> if (err) assert.fail(err, "testGETSET 1");<LF> checkEqual(previousValue, 'getsetbar', "testGETSET 2");<LF> });<LF><LF> client.get('getsetfoo', function (err, value) {<LF> if (err) assert.fail(err, "testGETSET 3");<LF> checkEqual(value, 'fuzz', "testGETSET 4");<LF> });<LF>}<LF><LF>function testSETANDGETMULTIBYTE() {<LF> var testValue = '\u00F6\u65E5\u672C\u8A9E'; // �������<LF> var buffer = new Buffer(32);<LF> var size = buffer.utf8Write(testValue,0);<LF> client.set('testUtf8Key', buffer.slice(0,size), expectOK("testSETANDGETMULTIBYTE"))<LF><LF> client.get('testUtf8Key', function (err, value) {<LF> if (err) assert.fail(err, "testSETANDGETMULTIBYTE");<LF> checkEqual(value.utf8Slice(0, value.length), testValue, "testSETANDGETMULTIBYTE");<LF> });<LF>}<LF><LF>function testINFO() {<LF> client.info(function (err, info) {<LF> check(info instanceof Object, "testINFO");<LF> check(info.hasOwnProperty('redis_version'), "testINFO");<LF> check(info.hasOwnProperty('connected_clients'), "testINFO");<LF> check(info.hasOwnProperty('uptime_in_seconds'), "testINFO");<LF> checkEqual(typeof(info.uptime_in_seconds), 'string', "testINFO");<LF> checkEqual(typeof(info.connected_clients), 'string', "testINFO");<LF> });<LF>}<LF><LF>function testINCR() {<LF> client.incr('counter', expectNumber(1, "testINCR"))<LF> client.incr('counter', expectNumber(2, "testINCR"))<LF>}<LF><LF>function testINCRBY() {<LF> client.incrby('counter', 2, expectNumber(2, "testINCRBY"))<LF> client.incrby('counter', -1, expectNumber(1, "testINCRBY"))<LF>}<LF><LF>function testDECR() {<LF> client.decr('counter', expectNumber(-1, "testDECR"))<LF> client.decr('counter', expect
DEBUG: [RECV] Number(-2, "testDECR"))<LF>}<LF><LF>function testDECRBY() {<LF> client.decrby('counter', '1', expectNumber(-1, "testDECRBY"))<LF> client.decrby('counter', '2', expectNumber(-3, "testDECRBY"))<LF> client.decrby('counter', '-3', expectNumber(0, "testDECRBY"))<LF>}<LF><LF>function testEXISTS() {<LF> client.set('foo', 'bar', expectOK("testEXISTS"));<LF> client.exists('foo', expectNumber(1, "testEXISTS"))<LF> client.exists('foo2', expectNumber(0, "testEXISTS"))<LF>}<LF><LF>function testDEL() {<LF> client.set('goo', 'bar', expectOK("testDEL"));<LF> client.del('goo', expectNumber(1, "testDEL"));<LF> client.exists('goo', expectNumber(0, "testDEL"));<LF> client.del('goo', expectNumber(0, "testDEL"));<LF>}<LF><LF>function testKEYS() {<LF> client.set('foo1', 'foo1Value', expectOK("testKEYS"))<LF> client.set('foo2', 'foo2Value', expectOK("testKEYS"))<LF><LF> client.keys('foo*', function (err, keys) {<LF> if (err) assert.fail(err, "testKEYS");<LF> checkEqual(keys.length, 2, "testKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(keys);<LF> checkDeepEqual(keys.sort(), ['foo1', 'foo2'], "testKEYS");<LF> });<LF><LF> client.set('baz', 'bazValue', expectOK("testKEYS"))<LF> client.set('boo', 'booValue', expectOK("testKEYS"))<LF><LF> // At this point we have foo1, foo2, baz, boo<LF><LF> client.keys('*', function (err, keys) {<LF> if (err) assert.fail(err, "testKEYS");<LF> checkEqual(keys.length, 4, "testKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(keys);<LF> checkDeepEqual(keys.sort(), ['baz', 'boo', 'foo1', 'foo2'], "testKEYS");<LF> });<LF><LF> client.keys('?oo', function (err, keys) {<LF> if (err) assert.fail(err, "testKEYS");<LF> checkEqual(keys.length, 1, "testKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(keys);<LF> checkDeepEqual(keys.sort(), ['boo'], "testKEYS");<LF> });<LF>}<LF><LF>function testRANDOMKEY() {<LF> client.set('foo', 'bar', expectOK("testRANDOMKEY"));<LF> client.set('baz', 'buz', expectOK("testRANDOMKEY"));<LF><LF> client.randomkey(function (err, someKey) {<LF> if (err) assert.fail(err, "testRANDOMKEY");<LF> check(/^(foo|baz)$/.test(someKey), "testRANDOMKEY");<LF> });<LF>}<LF><LF>function testRENAME() {<LF> client.set('foo', 'bar', expectOK("testRENAME"));<LF> client.rename('foo', 'zoo', expectOK("testRENAME"));<LF> client.exists('foo', expectNumber(0, "testRENAME"));<LF> client.exists('zoo', expectNumber(1, "testRENAME"));<LF>}<LF><LF>function testRENAMENX() {<LF> client.set('roo', 'bar', expectOK("testRENAMENX"));<LF> client.set('bar', 'baz', expectOK("testRENAMENX"));<LF> client.renamenx('roo', 'bar', expectNumber(0, "testRENAMENX")); // bar already exists<LF> client.exists('roo', expectNumber(1, "testRENAMENX")); // was not renamed<LF> client.exists('bar', expectNumber(1, "testRENAMENX")); // was not touched<LF> client.renamenx('roo', 'too', expectNumber(1, "testRENAMENX")); // too did not exist... OK<LF> client.exists('roo', expectNumber(0, "testRENAMENX")); // was renamed<LF> client.exists('too', expectNumber(1, "testRENAMENX")); // was created<LF>}<LF><LF>function testDBSIZE() {<LF> client.set('foo', 'bar', expectOK("testDBSIZE"));<LF> client.set('bar', 'baz', expectOK("testDBSIZE"));<LF><LF> client.dbsize(function (err, value) {<LF> if (err) assert.fail(err, "testDBSIZE");<LF> checkEqual(value, 2, "testDBSIZE");<LF> });<LF>}<LF><LF>function testEXPIRE() {<LF> // set 'expfoo' to expire in 2 seconds<LF><LF> client.set('expfoo', 'bar', expectOK("testEXPIRE"));<LF> client.expire('expfoo', 2, expectNumber(1, "testEXPIRE"));<LF><LF> // subsequent expirations cannot be set.<LF><LF> client.expire('expfoo', 2, expectNumber(0, "testEXPIRE"));<LF><LF> setTimeout(function () {<LF> client.exists('expfoo', expectNumber(0, "testEXPIRE"));<LF> }, 2500);<LF>}<LF><LF>function testTTL() {<LF> client.set('ttlfoo', 'bar', expectOK("testTTL"));<LF><LF> // ttlfoo is not set to expire<LF><LF> client.ttl('ttlfoo', function (err, value) {<LF> if (err) assert.fail(err, "testTTL");<LF> checkEqual(value, -1, "testTTL");<LF> });<LF><LF> client.set('ttlbar', 'baz', expectOK("testTTL"));<LF> client.expire('ttlbar', 3, expectNumber(1, "testTTL"));<LF><LF> client.ttl('ttlbar', function (err, value) {<LF> if (err) assert.fail(err, "testTTL");<LF> check(value > 0, "testTTL");<LF> });<LF>}<LF><LF>function testRPUSH() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testRPUSH"));<LF> client.exists('list0', expectNumber(1, "testRPUSH"));<LF>}<LF><LF>function testLPUSH() {<LF> client.exists('list1', expectNumber(0, "testLPUSH"));<LF> client.lpush('list1', 'list1value0', expectNumber(1, "testLPUSH"));<LF> client.exists('list1', expectNumber(1, "testLPUSH"));<LF>}<LF><LF>function testLLEN() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLLEN"));<LF> client.llen('list0', expectNumber(1, "testLLEN"));<LF><LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLLEN"));<LF> client.llen('list0', expectNumber(2, "testLLEN"));<LF>}<LF><LF>function testLRANGE() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLRANGE"));<LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLRANGE"));<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLRANGE");<LF> checkEqual(values.length, 2, "testLRANGE");<LF> checkEqual(values[0], 'list0value0', "testLRANGE");<LF> checkEqual(values[1], 'list0value1', "testLRANGE");<LF> });<LF><LF> client.lrange('list0', 0, 0, function (err, values) {<LF> if (err) assert.fail(err, "testLRANGE");<LF> checkEqual(values.length, 1, "testLRANGE");<LF> checkEqual(values[0], 'list0value0', "testLRANGE");<LF> });<LF><LF> client.lrange('list0', -1, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLRANGE");<LF> checkEqual(values.length, 1, "testLRANGE");<LF> checkEqual(values[0], 'list0value1', "testLRANGE");<LF> });<LF>}<LF><LF>function testLTRIM() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLTRIM"));<LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLTRIM"));<LF> client.rpush('list0', 'list0value2', expectNumber(3, "testLTRIM"));<LF><LF> client.llen('list0', function (err, len) {<LF> if (err) assert.fail(err, "testLTRIM");<LF> checkEqual(len, 3, "testLTRIM");<LF> });<LF><LF> client.ltrim('list0', 0, 1, expectOK("testLTRIM"))<LF><LF> client.llen('list0', function (err, len) {<LF> if (err) assert.fail(err, "testLTRIM");<LF> checkEqual(len, 2, "testLTRIM");<LF> });<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLTRIM");<LF> checkEqual(values.length, 2, "testLTRIM");<LF> checkEqual(values[0], 'list0value0', "testLTRIM");<LF> checkEqual(values[1], 'list0value1', "testLTRIM");<LF> });<LF>}<LF><LF>function testLINDEX() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLINDEX"));<LF> client.rpush('list0', 'list0value1', expectNumber(2, "testLINDEX"));<LF><LF> client.lindex('list0', 0, function (err, value) {<LF> if (err) assert.fail(err, "testLINDEX");<LF> checkEqual(value, 'list0value0', "testLINDEX");<LF> });<LF><LF> client.lindex('list0', 1, function (err, value) {<LF> if (err) assert.fail(err, "testLINDEX");<LF> checkEqual(value, 'list0value1', "testLINDEX");<LF> });<LF><LF> // out of range => null<LF><LF> client.lindex('list0', 2, function (err, value) {<LF> if (err) assert.fail(err, "testLINDEX");<LF> checkEqual(value, null, "testLINDEX");<LF> });<LF>}<LF><LF>function testLSET() {<LF> client.rpush('list0', 'list0value0', expectNumber(1, "testLSET"));<LF> client.lset('list0', 0, 'LIST0VALUE0', expectOK("testLSET"));<LF><LF> client.lrange('list0', 0, 0, function (err, values) {<LF> if (err) assert.fail(err, "testLSET");<LF> checkEqual(values.length, 1, "testLSET");<LF> checkEqual(values[0], 'LIST0VALUE0', "testLSET");<LF> });<LF>}<LF><LF>function testLREM() {<LF> client.lpush('list0', 'ABC', expectNumber(1, "testLREM"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testLREM"));<LF> client.lpush('list0', 'ABC', expectNumber(3, "testLREM"));<LF><LF> client.lrem('list0', 1, 'ABC', expectNumber(1, "testLREM"));<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLREM");<LF> checkEqual(values.length, 2, "testLREM");<LF> checkEqual(values[0], 'DEF', "testLREM");<LF> checkEqual(values[1], 'ABC', "testLREM");<LF> });<LF>}<LF><LF>function testLPOP() {<LF> client.lpush('list0', 'ABC', expectNumber(1, "testLPOP"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testLPOP"));<LF> client.lpush('list0', 'GHI', expectNumber(3, "testLPOP"));<LF><LF> client.lpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testLPOP");<LF> checkEqual(value, 'GHI', "testLPOP");<LF> });<LF><LF> client.lpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testLPOP");<LF> checkEqual(value, 'DEF', "testLPOP");<LF> });<LF><LF> client.lrange('list0', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testLPOP");<LF> checkEqual(values.length, 1, "testLPOP");<LF> checkEqual(values[0], 'ABC', "testLPOP");<LF> });<LF>}<LF><LF>function testRPOP() {<LF> client.lpush('list0', 'ABC', expectNumber(1, "testRPOP"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testRPOP"));<LF><LF> client.rpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testRPOP");<LF> checkEqual(value, 'ABC', "testRPOP");<LF> });<LF><LF> client.rpop('list0', function (err, value) {<LF> if (err) assert.fail(err, "testRPOP");<LF> checkEqual(value, 'DEF', "testRPOP");<LF> });<LF><LF> client.llen('list0', function (err, len) {<LF> if (err) assert.fail(err, "testRPOP");<LF> checkEqual(len, 0, "testRPOP");<LF> });<LF>}<LF><LF>function testRPOPLPUSH() {<LF> client.rpush('src', 'ABC', expectNumber(1, "testRPOPLPUSH"));<LF> client.rpush('src', 'DEF', expectNumber(2, "testRPOPLPUSH"));<LF><LF> client.rpoplpush('src', 'dst', function (err, value) {<LF> if (err) assert.fail(err, "testRPOPLPUSH");<LF> checkEqual(value, 'DEF', "testRPOPLPUSH");<LF> });<LF><LF> client.lrange('src', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testRPOPLPUSH");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(values);<LF> checkDeepEqual(values, [ 'ABC' ], "testRPOPLPUSH");<LF> });<LF><LF> client.lrange('dst', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testRPOPLPUSH");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(values);<LF> checkDeepEqual(values, [ 'DEF' ], "testRPOPLPUSH");<LF> });<LF>}<LF><LF>function testSADD() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSADD"));<LF> client.sadd('set0', 'member0', expectNumber(0, "testSADD")); // already member<LF>}<LF><LF>function testSISMEMBER() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSISMEMBER"));<LF> client.sismember('set0', 'member0', expectNumber(1, "testSISMEMBER"));<LF> client.sismember('set0', 'member1', expectNumber(0, "testSISMEMBER"));<LF>}<LF><LF>function testSCARD() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSCARD"));<LF> client.scard('set0', expectNumber(1, "testSCARD"));<LF><LF> client.sadd('set0', 'member1', expectNumber(1, "testSCARD"));<LF> client.scard('set0', expectNumber(2, "testSCARD"));<LF>}<LF><LF>function testSREM() {<LF> client.sadd('set0', 'member0', expectNumber(1, "testSREM"));<LF> client.srem('set0', 'foobar', expectNumber(0, "testSREM"))<LF> client.srem('set0', 'member0', expectNumber(1, "testSREM"))<LF> client.scard('set0', expectNumber(0, "testSREM"));<LF>}<LF><LF>function testSPOP() {<LF> client.sadd('zzz', 'member0', expectNumber(1, "testSPOP"));<LF> client.scard('zzz', expectNumber(1, "testSPOP"));<LF><LF> client.spop('zzz', function (err, value) {<LF> if (err) assert.fail(err, "testSPOP");<LF> checkEqual(value, 'member0', "testSPOP");<LF> });<LF><LF> client.scard('zzz', expectNumber(0, "testSPOP"));<LF>}<LF><LF>function testSDIFF() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSDIFF"));<LF> client.sadd('foo', 'a', expectNumber(1, "testSDIFF"));<LF> client.sadd('foo', 'b', expectNumber(1, "testSDIFF"));<LF> client.sadd('foo', 'c', expectNumber(1, "testSDIFF"));<LF><LF> client.sadd('bar', 'c', expectNumber(1, "testSDIFF"));<LF><LF> client.sadd('baz', 'a', expectNumber(1, "testSDIFF"));<LF> client.sadd('baz', 'd', expectNumber(1, "testSDIFF"));<LF><LF> client.sdiff('foo', 'bar', 'baz', function (err, values) {<LF> if (err) assert.fail(err, "testSDIFF");<LF> values.sort();<LF> checkEqual(values.length, 2, "testSDIFF");<LF> checkEqual(values[0], 'b', "testSDIFF");<LF> checkEqual(values[1], 'x', "testSDIFF");<LF> });<LF>}<LF><LF>function testSDIFFSTORE() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('foo', 'a', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('foo', 'b', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('foo', 'c', expectNumber(1, "testSDIFFSTORE"))<LF><LF> client.sadd('bar', 'c', expectNumber(1, "testSDIFFSTORE"))<LF><LF> client.sadd('baz', 'a', expectNumber(1, "testSDIFFSTORE"))<LF> client.sadd('baz', 'd', expectNumber(1, "testSDIFFSTORE"))<LF><LF> // NB: SDIFFSTORE returns the number of elements in the dstkey <LF><LF> client.sdiffstore('quux', 'foo', 'bar', 'baz', expectNumber(2, "testSDIFFSTORE"))<LF><LF> client.smembers('quux', function (err, members) {<LF> if (err) assert.fail(err, "testSDIFFSTORE");<LF> members.sort();<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'b', 'x' ], "testSDIFFSTORE");<LF> });<LF>}<LF><LF>function testSMEMBERS() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSMEMBERS"));<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testSMEMBERS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'x' ], "testSMEMBERS");<LF> });<LF><LF> client.sadd('foo', 'y', expectNumber(1, "testSMEMBERS"));<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testSMEMBERS");<LF> checkEqual(members.length, 2, "testSMEMBERS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members.sort(), [ 'x', 'y' ], "testSMEMBERS");<LF> });<LF>}<LF><LF>function testSMOVE() {<LF> client.sadd('foo', 'x', expectNumber(1, "testSMOVE"));<LF> client.smove('foo', 'bar', 'x', expectNumber(1, "testSMOVE"));<LF> client.sismember('foo', 'x', expectNumber(0, "testSMOVE"));<LF> client.sismember('bar', 'x', expectNumber(1, "testSMOVE"));<LF> client.smove('foo', 'bar', 'x', expectNumber(0, "testSMOVE"));<LF>}<LF><LF>function testSINTER() {<LF> client.sadd('sa', 'a', expectNumber(1, "testSINTER"));<LF> client.sadd('sa', 'b', expectNumber(1, "testSINTER"));<LF> client.sadd('sa', 'c', expectNumber(1, "testSINTER"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testSINTER"));<LF> client.sadd('sb', 'c', expectNumber(1, "testSINTER"));<LF> client.sadd('sb', 'd', expectNumber(1, "testSINTER"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testSINTER"));<LF> client.sadd('sc', 'd', expectNumber(1, "testSINTER"));<LF> client.sadd('sc', 'e', expectNumber(1, "testSINTER"));<LF><LF> client.sinter('sa', 'sb', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 2, "testSINTER");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);<LF> checkDeepEqual(intersection.sort(), [ 'b', 'c' ], "testSINTER");<LF> });<LF><LF> client.sinter('sb', 'sc', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 2, "testSINTER");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);<LF> checkDeepEqual(intersection.sort(), [ 'c', 'd' ], "testSINTER");<LF> });<LF><LF> client.sinter('sa', 'sc', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 1, "testSINTER");<LF> checkEqual(intersection[0], 'c', "testSINTER");<LF> });<LF><LF> // 3-way<LF><LF> client.sinter('sa', 'sb', 'sc', function (err, intersection) {<LF> if (err) assert.fail(err, "testSINTER");<LF> checkEqual(intersection.length, 1, "testSINTER");<LF> checkEqual(intersection[0], 'c', "testSINTER");<LF> });<LF>}<LF><LF>function testSINTERSTORE() {<LF> client.sadd('sa', 'a', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sa', 'b', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sa', 'c', expectNumber(1, "testSINTERSTORE"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sb', 'c', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sb', 'd', expectNumber(1, "testSINTERSTORE"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sc', 'd', expectNumber(1, "testSINTERSTORE"));<LF> client.sadd('sc', 'e', expectNumber(1, "testSINTERSTORE"));<LF><LF> client.sinterstore('foo', 'sa', 'sb', 'sc', expectNumber(1, "testSINTERSTORE"))<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testSINTERSTORE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'c' ], "testSINTERSTORE");<LF> });<LF>}<LF><LF>function testSUNION() {<LF> client.sadd('sa', 'a', expectNumber(1, "testUNION"));<LF> client.sadd('sa', 'b', expectNumber(1, "testUNION"));<LF> client.sadd('sa', 'c', expectNumber(1, "testUNION"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testUNION"));<LF> client.sadd('sb', 'c', expectNumber(1, "testUNION"));<LF> client.sadd('sb', 'd', expectNumber(1, "testUNION"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testUNION"));<LF> client.sadd('sc', 'd', expectNumber(1, "testUNION"));<LF> client.sadd('sc', 'e', expectNumber(1, "testUNION"));<LF><LF> client.sunion('sa', 'sb', 'sc', function (err, union) {<LF> if (err) assert.fail(err, "testUNION");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(union);<LF> checkDeepEqual(union.sort(), ['a', 'b', 'c', 'd', 'e'], "testUNION");<LF> });<LF>}<LF><LF>function testSUNIONSTORE() {<LF> client.sadd('sa', 'a', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sa', 'b', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sa', 'c', expectNumber(1, "testUNIONSTORE"));<LF><LF> client.sadd('sb', 'b', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sb', 'c', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sb', 'd', expectNumber(1, "testUNIONSTORE"));<LF><LF> client.sadd('sc', 'c', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sc', 'd', expectNumber(1, "testUNIONSTORE"));<LF> client.sadd('sc', 'e', expectNumber(1, "testUNIONSTORE"));<LF><LF> client.sunionstore('foo', 'sa', 'sb', 'sc', function (err, cardinality) {<LF> if (err) assert.fail(err, "testUNIONSTORE");<LF> checkEqual(cardinality, 5, "testUNIONSTORE");<LF> });<LF><LF> client.smembers('foo', function (err, members) {<LF> if (err) assert.fail(err, "testUNIONSTORE");<LF> checkEqual(members.length, 5, "testUNIONSTORE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members.sort(), ['a', 'b', 'c', 'd', 'e'], "testUNIONSTORE");<LF> });<LF>}<LF><LF>function testTYPE() {<LF> client.sadd('sa', 'a', expectNumber(1, "testTYPE"));<LF> client.type('sa', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'set', "testTYPE");<LF> });<LF><LF> client.rpush('list0', 'x', expectNumber(1, "testTYPE"));<LF> client.type('list0', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'list', "testTYPE");<LF> });<LF><LF> client.set('foo', 'bar', expectOK("testTYPE"));<LF> client.type('foo', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'string', "testTYPE");<LF> });<LF><LF> client.type('xxx', function (err, type) {<LF> if (err) assert.fail(err, "testTYPE");<LF> checkEqual(type, 'none', "testTYPE");<LF> });<LF>}<LF><LF>function testMOVE() {<LF> client.rpush('list0', 'x', expectNumber(1, "testMOVE"));<LF> client.move('list0', TEST_DB_NUMBER_FOR_MOVE, expectNumber(1, "testMOVE"));<LF><LF> client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK("testMOVE"));<LF> client.exists('list0', expectNumber(1, "testMOVE"));<LF><LF> client.select(TEST_DB_NUMBER, expectOK("testMOVE"));<LF> client.exists('list0', expectNumber(0, "testMOVE"));<LF>}<LF><LF>// TODO sort with STORE option.<LF><LF>// Sort is a beast.<LF>//<LF>// $ redis-cli lrange x 0 -1<LF>// 1. 3<LF>// 2. 9<LF>// 3. 2<LF>// 4. 4<LF>//<LF>// $ redis-cli mget w3 w9 w2 w4<LF>// 1. 4<LF>// 2. 5<LF>// 3. 12<LF>// 4. 6<LF>//<LF>// $ redis-cli sort x by w*<LF>// 1. 3<LF>// 2. 9<LF>// 3. 4<LF>// 4. 2<LF>//<LF>// When using 'by w*' value x[i]'s effective value is w{x[i]}.<LF>//<LF>// sort [ w3, w9, w2, w4 ] = sort [ 4, 5, 12, 6 ]<LF>// = [ 4, 5, 6, 12 ]<LF>// = [ w3, w9, w4, w2 ]<LF>//<LF>// Thus, sorting x 'by w*' results in [ 3, 9, 4, 2 ]<LF>//<LF>// Once sorted redis can fetch entries at the keys indicated by the 'get'<LF>// pattern. If we specify 'get o*', redis would fetch [ o3, o9, o4, o2 ] <LF>// since our sorted list was [ 3, 9, 4, 2 ].<LF>//<LF>// $ redis-cli mget o2 o3 o4 o9<LF>// 1. buz<LF>// 2. foo<LF>// 3. baz<LF>// 4. bar<LF>//<LF>// $ redis-cli sort x by w* get o*<LF>// 1. foo<LF>// 2. bar<LF>// 3. baz<LF>// 4. buz<LF>//<LF>// One can specify multiple get patterns and the keys for each get pattern<LF>// are interlaced in the results.<LF>//<LF>// $ redis-cli mget p2 p3 p4 p9<LF>// 1. qux<LF>// 2. bux<LF>// 3. lux<LF>// 4. tux<LF>//<LF>// $ redis-cli sort x by w* get o* get p*<LF>// 1. foo<LF>// 2. bux<LF>// 3. bar<LF>// 4. tux<LF>// 5. baz<LF>// 6. lux<LF>// 7. buz<LF>// 8. qux<LF>//<LF>// Phew! Now, let's test all that.<LF><LF>function testSORT() {<LF> client.rpush('y', 'd', expectNumber(1, "testSORT"));<LF> client.rpush('y', 'b', expectNumber(2, "testSORT"));<LF> client.rpush('y', 'a', expectNumber(3, "testSORT"));<LF> client.rpush('y', 'c', expectNumber(4, "testSORT"));<LF><LF> client.rpush('x', '3', expectNumber(1, "testSORT"));<LF> client.rpush('x', '9', expectNumber(2, "testSORT"));<LF> client.rpush('x', '2', expectNumber(3, "testSORT"));<LF> client.rpush('x', '4', expectNumber(4, "testSORT"));<LF><LF> client.set('w3', '4', expectOK("testSORT"));<LF> client.set('w9', '5', expectOK("testSORT"));<LF> client.set('w2', '12', expectOK("testSORT"));<LF> client.set('w4', '6', expectOK("testSORT"));<LF><LF> client.set('o2', 'buz', expectOK("testSORT"));<LF> client.set('o3', 'foo', expectOK("testSORT"));<LF> client.set('o4', 'baz', expectOK("testSORT"));<LF> client.set('o9', 'bar', expectOK("testSORT"));<LF><LF> client.set('p2', 'qux', expectOK("testSORT"));<LF> client.set('p3', 'bux', expectOK("testSORT"));<LF> client.set('p4', 'lux', expectOK("testSORT"));<LF> client.set('p9', 'tux', expectOK("testSORT"));<LF><LF> // Now the data has been setup, we can test.<LF><LF> // But first, test basic sorting.<LF><LF> // y = [ d b a c ]<LF> // sort y ascending = [ a b c d ]<LF> // sort y descending = [ d c b a ]<LF><LF> client.sort('y', 'asc', 'alpha', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['a', 'b', 'c', 'd'], "testSORT");<LF> });<LF><LF> client.sort('y', 'desc', 'alpha', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['d', 'c', 'b', 'a'], "testSORT");<LF> });<LF><LF> // Now try sorting numbers in a list.<LF> // x = [ 3, 9, 2, 4 ]<LF><LF> client.sort('x', 'asc', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, [2, 3, 4, 9], "testSORT");<LF> });<LF><LF> client.sort('x', 'desc', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, [9, 4, 3, 2], "testSORT");<LF> });<LF><LF> // Try sorting with a 'by' pattern.<LF><LF> client.sort('x', 'by', 'w*', 'asc', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, [3, 9, 4, 2], "testSORT");<LF> });<LF><LF> // Try s
DEBUG: [RECV] orting with a 'by' pattern and 1 'get' pattern.<LF><LF> client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['foo', 'bar', 'baz', 'buz'], "testSORT");<LF> });<LF><LF> // Try sorting with a 'by' pattern and 2 'get' patterns.<LF><LF> client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', function (err, sorted) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);<LF> checkDeepEqual(sorted, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], "testSORT");<LF> });<LF><LF> // Try sorting with a 'by' pattern and 2 'get' patterns.<LF> // Instead of getting back the sorted set/list, store the values to a list.<LF> // Then check that the values are there in the expected order.<LF><LF> client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', 'store', 'bacon', function (err) {<LF> if (err) assert.fail(err, "testSORT");<LF> });<LF><LF> client.lrange('bacon', 0, -1, function (err, values) {<LF> if (err) assert.fail(err, "testSORT");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(values);<LF> checkDeepEqual(values, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], "testSORT");<LF> });<LF>}<LF><LF>function testSAVE() {<LF> client.save(expectOK("testSAVE"));<LF>}<LF><LF>function testBGSAVE() {<LF> printDisclaimer();<LF>}<LF><LF>function testLASTSAVE() {<LF> client.lastsave( function (err, value) {<LF> if (err) assert.fail(err, "testLASTSAVE");<LF> checkEqual(typeof(value), 'number', "testLASTSAVE");<LF> check(value > 0, "testLASTSAVE");<LF> });<LF>}<LF><LF>function testFLUSHALL() {<LF> printDisclaimer();<LF>}<LF><LF>function testSHUTDOWN() {<LF> printDisclaimer();<LF>}<LF><LF>function testMSET() {<LF> // set a=b, c=d, e=100<LF><LF> client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK("testMSET"));<LF>}<LF><LF>function testMSETNX() {<LF> client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK("testMSET"));<LF><LF> // should fail since as 'a' already exists.<LF><LF> client.msetnx('g', 'h', 'a', 'i', expectNumber(0, "testMSETNX"));<LF><LF> // should pass as key 'g' was NOT set in prev. command<LF> // since it failed due to key 'a' already existing.<LF><LF> client.msetnx('g', 'h', 'i', 'j', expectNumber(1, "testMSETNX"));<LF>}<LF><LF>function testZADD() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZADD"));<LF><LF> // Already added m0; just update the score to 50.<LF> // Redis returns 0 in this case.<LF><LF> client.zadd('z0', 50, 'm0', expectNumber(0, "testZADD"));<LF>}<LF><LF>function testZREM() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZREM"));<LF> client.zrem('z0', 'm0', expectNumber(1, "testZREM"));<LF> client.zrem('z0', 'm0', expectNumber(0, "testZREM"));<LF>}<LF><LF>function testZCARD() {<LF> client.zcard('zzzzzz', expectNumber(0, "testZCARD")); // doesn't exist.<LF><LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZCARD"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZCARD"));<LF><LF> client.zcard('z0', expectNumber(2, "testZCARD"));<LF>}<LF><LF>function testZSCORE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZSCORE"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZSCORE"));<LF><LF> client.zscore('z0', 'm0', expectNumber(100, "testZSCORE"));<LF> client.zscore('z0', 'm1', expectNumber(200, "testZSCORE"));<LF><LF> client.zscore('z0', 'zzzzzzz', function (err, score) {<LF> if (err) assert.fail(err, "testZSCORE");<LF> checkEqual(score, null, "testZSCORE");<LF> });<LF>}<LF><LF>function testZRANGE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZRANGE"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZRANGE"));<LF> client.zadd('z0', 300, 'm2', expectNumber(1, "testZRANGE"));<LF><LF> client.zrange('z0', 0, -1, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], "testZRANGE");<LF> });<LF><LF> client.zrange('z0', -1, -1, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm2' ], "testZRANGE");<LF> });<LF><LF> client.zrange('z0', -2, -1, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm1', 'm2' ], "testZRANGE");<LF> });<LF>}<LF><LF>function testZREVRANGE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZREVRANGE"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZREVRANGE"));<LF> client.zadd('z0', 300, 'm2', expectNumber(1, "testZREVRANGE"));<LF><LF> client.zrevrange('z0', 0, 1000, function (err, members) {<LF> if (err) assert.fail(err, "testZREVRANGE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm2', 'm1', 'm0' ], "testZREVRANGE");<LF> });<LF>}<LF><LF>function testZRANGEBYSCORE() {<LF> client.zadd('z0', 100, 'm0', expectNumber(1, "testZRANGEBYSCORE 1"));<LF> client.zadd('z0', 200, 'm1', expectNumber(1, "testZRANGEBYSCORE 2"));<LF> client.zadd('z0', 300, 'm2', expectNumber(1, "testZRANGEBYSCORE 3"));<LF><LF> client.zrangebyscore('z0', 200, 300, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGEBYSCORE 4");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm1', 'm2' ], "testZRANGEBYSCORE 5");<LF> });<LF><LF> client.zrangebyscore('z0', 100, 1000, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGEBYSCORE 6");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], "testZRANGEBYSCORE 7");<LF> });<LF><LF> client.zrangebyscore('z0', 10000, 100000, function (err, members) {<LF> if (err) assert.fail(err, "testZRANGEBYSCORE 8");<LF> checkEqual(members, null, "testZRANGEBYSCORE 9");<LF> });<LF>}<LF><LF>// zcount is undocumented as of Thu Apr 01 20:17:58 EDT 2010 <LF>// zcount key startScore endScore => number of elements in [startScore, endScore]<LF><LF>function testZCOUNT() {<LF> client.zcount('z0', 0, 100, expectNumber(0, "testZCOUNT"));<LF><LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZCOUNT"));<LF> client.zcount('z0', 0, 100, expectNumber(1, "testZCOUNT"));<LF><LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZCOUNT"));<LF> client.zcount('z0', 0, 100, expectNumber(2, "testZCOUNT"));<LF>}<LF><LF>function testZINCRBY() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZINCRBY"));<LF> client.zincrby('z0', 1, 'a', expectNumber(2, "testZINCRBY"));<LF>}<LF><LF>// This really should be called ZINTERSTORE.<LF><LF>function testZINTER() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZINTER"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZINTER"));<LF> client.zadd('z1', 3, 'a', expectNumber(1, "testZINTER"));<LF> client.zinter('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(1, "testZINTER"));<LF> client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZINTER");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> checkDeepEqual(members, [ 'a', 4 ], "testZINTER"); // score=1+3<LF> });<LF>}<LF><LF>function testZUNION() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZUNION"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZUNION"));<LF> client.zadd('z1', 3, 'a', expectNumber(1, "testZUNION"));<LF> client.zunion('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(2, "testZUNION"));<LF> client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZUNION");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> check(members.length % 2 == 0, "testZUNION");<LF> var set = {};<LF> for (var i=0; i<members.length; i += 2)<LF> set[members[i]] = members[i + 1];<LF> checkDeepEqual(set, { a:4, b:2 }, "testZUNION"); // a's score=1+3<LF> });<LF>}<LF><LF>function testZRANK() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZRANK"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZRANK"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZRANK"));<LF><LF> client.zrank('z0', 'a', expectNumber(0, "testZRANK"));<LF> client.zrank('z0', 'b', expectNumber(1, "testZRANK"));<LF> client.zrank('z0', 'c', expectNumber(2, "testZRANK"));<LF>}<LF><LF>function testZREVRANK() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZREVRANK"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZREVRANK"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZREVRANK"));<LF><LF> client.zrevrank('z0', 'a', expectNumber(2, "testZREVRANK"));<LF> client.zrevrank('z0', 'b', expectNumber(1, "testZREVRANK"));<LF> client.zrevrank('z0', 'c', expectNumber(0, "testZREVRANK"));<LF>}<LF><LF>function testZREMRANGEBYRANK() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZREMRANGEBYRANK"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZREMRANGEBYRANK"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZREMRANGEBYRANK"));<LF><LF> client.zremrangebyrank('z0', -1, -1, expectNumber(1, "testZREMRANGEBYRANK"));<LF><LF> client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZREMRANGEBYRANK");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> check(members.length % 2 == 0, "testZREMRANGEBYRANK");<LF> var set = {};<LF> for (var i=0; i<members.length; i += 2)<LF> set[members[i]] = members[i + 1];<LF> checkDeepEqual(set, { a:1, b:2 }, "testZREMRANGEBYRANK");<LF> });<LF>}<LF><LF>function testZREMRANGEBYSCORE() {<LF> client.zadd('z0', 1, 'a', expectNumber(1, "testZREMRANGEBYSCORE"));<LF> client.zadd('z0', 2, 'b', expectNumber(1, "testZREMRANGEBYSCORE"));<LF> client.zadd('z0', 3, 'c', expectNumber(1, "testZREMRANGEBYSCORE"));<LF><LF> // inclusive<LF> client.zremrangebyscore('z0', 2, 3, expectNumber(2, "testZREMRANGEBYSCORE"));<LF><LF> client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {<LF> if (err) assert.fail(err, "testZREMRANGEBYSCORE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(members);<LF> check(members.length % 2 == 0, "testZREMRANGEBYSCORE");<LF> var set = {};<LF> for (var i=0; i<members.length; i += 2)<LF> set[members[i]] = members[i + 1];<LF> checkDeepEqual(set, { a:1 }, "testZREMRANGEBYSCORE");<LF> });<LF>}<LF><LF>function testHDEL() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHDEL"));<LF> client.hdel("foo", "bar", expectNumber(1, "testHDEL"));<LF> client.hdel("foo", "bar", expectNumber(0, "testHDEL"));<LF>}<LF><LF>function testHEXISTS() {<LF> client.hset("hfoo", "bar", "baz", expectNumber(1, "testHEXISTS"));<LF> client.hexists("hfoo", "bar", expectNumber(1, "testHEXISTS"));<LF> client.hexists("hfoo", "baz", expectNumber(0, "testHEXISTS"));<LF>}<LF><LF>function testHGET() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHGET"));<LF> client.hget("foo", "bar", function (err, reply) {<LF> if (err) assert.fail(err, "testHGET");<LF> checkEqual("baz", reply, "testHGET");<LF> });<LF>}<LF><LF>function testHGETALL() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHGETALL"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHGETALL"));<LF> client.hgetall("foo", function (err, all) {<LF> if (err) assert.fail(err, "testHGETALL");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(all);<LF> checkDeepEqual(all, { bar:"baz", quux:"doo" }, "testHGETALL");<LF> });<LF>}<LF><LF>function testHINCRBY() {<LF> client.hincrby("foo", "bar", 1, expectNumber(1, "testHINCRBY 1"));<LF> client.hget("foo", "bar", expectNumber(1, "testHINCRBY 2"));<LF><LF> client.hincrby("foo", "bar", 1, expectNumber(2, "testHINCRBY 3"));<LF> client.hget("foo", "bar", expectNumber(2, "testHINCRBY 4"));<LF>}<LF><LF>function testHKEYS() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHKEYS"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHKEYS"));<LF> client.hkeys("foo", function (err, reply) {<LF> if (err) assert.fail(err, "testHKEYS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply.sort(), [ "bar", "quux" ], "testHKEYS");<LF> });<LF>}<LF><LF>function testHVALS() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHVALS"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHVALS"));<LF> client.hvals("foo", function (err, reply) {<LF> if (err) assert.fail(err, "testHVALS");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply.sort(), [ "baz", "doo" ], "testHVALS");<LF> });<LF>}<LF><LF>function testHLEN() {<LF> client.hlen("foo", expectNumber(0, "testHLEN"));<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHLEN"));<LF> client.hlen("foo", expectNumber(1, "testHLEN"));<LF> client.hset("foo", "quux", "doo", expectNumber(1, "testHLEN"));<LF> client.hlen("foo", expectNumber(2, "testHLEN"));<LF>}<LF><LF>function testHSET() {<LF> client.hset("foo", "bar", "baz", expectNumber(1, "testHSET"));<LF> client.hget("foo", "bar", function (err, reply) {<LF> if (err) assert.fail(err, "testHSET");<LF> checkEqual("baz", reply, "testHSET");<LF> });<LF>}<LF><LF>// Note that the user of this client should add a listener for "connect" via<LF>// client.stream.addListener("connect", function () { ... }); in order to<LF>// subscribe to channels/classes of interest after each connection is established<LF>// (subscriptions are not remembered across connections and reconnections).<LF><LF>// We need a 2nd client to act as publisher in order to test that a message<LF>// is received after SUBSCRIBE[ing] to a channel/class. We can at least test<LF>// that SUBSCRIBE itself does not fail (it shouldn't).<LF><LF>function testSUBSCRIBE() {<LF> client.subscribe("#redis", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "subscribe", "#redis", "1" ], "testSUBSCRIBE");<LF> });<LF><LF> client.subscribe("#Node.js", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "subscribe", "#Node.js", "2" ], "testSUBSCRIBE");<LF> });<LF><LF> client.unsubscribe("#redis", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "unsubscribe", "#redis", "1" ], "testSUBSCRIBE");<LF> });<LF><LF> client.unsubscribe("#Node.js", function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "unsubscribe", "#Node.js", "0" ], "testSUBSCRIBE");<LF> });<LF>}<LF><LF>function testUNSUBSCRIBE() {<LF> printDisclaimer();<LF>}<LF><LF>function testPSUBSCRIBE() {<LF> client.psubscribe("cooking.*", function (err, reply) {<LF> if (err) assert.fail(err, "testPSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "psubscribe", "cooking.*", "1" ], "testPSUBSCRIBE");<LF> });<LF><LF> client.punsubscribe("cooking.*", function (err, reply) {<LF> if (err) assert.fail(err, "testPSUBSCRIBE");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "punsubscribe", "cooking.*", "0" ], "testPSUBSCRIBE");<LF> });<LF>}<LF><LF>function testPUNSUBSCRIBE() {<LF> printDisclaimer();<LF>}<LF><LF>function testPUBLISH() {<LF> // No one is subscribed so 0<LF><LF> client.publish("#redis", "Hello, world!", expectNumber(0, "testPUBLISH"));<LF>}<LF><LF>var messageWasReceived = false;<LF><LF>function testSUBSCRIBEandPUBLISH() {<LF> var messagePayload = "I'm a lumberjack!";<LF> var channelName = "Monty"; <LF><LF> client.subscribeTo(channelName, function (channel, message) {<LF> checkEqual(channel, channelName, "testSUBSCRIBEandPUBLISH a0");<LF> checkEqual(message, messagePayload, "testSUBSCRIBEandPUBLISH a1");<LF> messageWasReceived = true;<LF> }); <LF><LF> // Create a 2nd client that publishes a message.<LF><LF> var publisher = redisclient.createClient();<LF> publisher.stream.addListener("connect", function () {<LF> publisher.publish(channelName, messagePayload, function (err, reply) {<LF> if (err) assert.fail(err, "testSUBSCRIBEandPUBLISH b0");<LF> expectNumber(1, "testSUBSCRIBEandPUBLISH b1");<LF> });<LF> });<LF>}<LF><LF>// We cannot test the blocking behavior of BLPOP and BRPOP from a single client<LF>// without using a timeout. That being said, we can test the non-blocking<LF>// behavior by ensuring there's an element in a list that we try to pop from.<LF><LF>function testBLPOP() {<LF> var timeout = 1;<LF><LF> // Non-blocking against a single key.<LF><LF> client.lpush('list0', 'ABC', expectNumber(1, "testBLPOP 1"));<LF> client.blpop('list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBLPOP 2");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "ABC" ], "testBLPOP 3");<LF> });<LF><LF> // Non-blocking against multiple keys.<LF> // Returns the first one that has something in it.<LF><LF> client.lpush('list0', 'ABC', expectNumber(1, "testBLPOP 4"));<LF> client.blpop('list1', 'list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBLPOP 5");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "ABC" ], "testBLPOP 6");<LF> });<LF><LF> // Non-blocking against a single key that does not exist.<LF> // This should timeout after 1 second and return a null reply.<LF><LF> client.blpop('listX', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBLPOP 7");<LF> checkEqual(reply, null, "testBLPOP 8");<LF> });<LF>}<LF><LF>function testBRPOP() {<LF> var timeout = 1;<LF><LF> // Non-blocking against a single key.<LF><LF> client.lpush('list0', 'ABC', expectNumber(1, "testBRPOP"));<LF> client.lpush('list0', 'DEF', expectNumber(2, "testBRPOP"));<LF> client.brpop('list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBRPOP");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "ABC" ], "testBRPOP");<LF> });<LF><LF> // Non-blocking against multiple keys.<LF> // Returns the first one that has something in it.<LF><LF> client.lpush('list0', 'ABC', expectNumber(2, "testBRPOP"));<LF> client.brpop('list1', 'list0', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBRPOP");<LF> redisclient.convertMultiBulkBuffersToUTF8Strings(reply);<LF> checkDeepEqual(reply, [ "list0", "DEF" ], "testBRPOP");<LF> });<LF><LF> // Non-blocking against a single key that does not exist.<LF> // This should timeout after 1 second and return a null reply.<LF><LF> client.brpop('listX', timeout, function (err, reply) {<LF> if (err) assert.fail(err, "testBRPOP");<LF> checkEqual(reply, null, "testBRPOP");<LF> });<LF>}<LF><LF>var allTestFunctions = [<LF> testAUTH,<LF> testBGSAVE,<LF> testBLPOP,<LF> testBRPOP,<LF> testDBSIZE,<LF> testDECR,<LF> testDECRBY,<LF> testDEL,<LF> testEXISTS,<LF> testEXPIRE,<LF> testFLUSHALL,<LF> testFLUSHDB,<LF> testGET,<LF> testGETSET,<LF> testHDEL, <LF> testHEXISTS,<LF> testHGET,<LF> testHGETALL,<LF> testHINCRBY,<LF> testHKEYS,<LF> testHLEN,<LF> testHSET,<LF> testHVALS,<LF> testINCR,<LF> testINCRBY,<LF> testINFO,<LF> testKEYS,<LF> testLASTSAVE,<LF> testLINDEX,<LF> testLLEN,<LF> testLPOP,<LF> testLPUSH,<LF> testLRANGE,<LF> testLREM,<LF> testLSET,<LF> testLTRIM,<LF> testMGET,<LF> testMOVE,<LF> testMSET,<LF> testMSETNX,<LF> testParseBulkReply,<LF> testParseErrorReply,<LF> testParseInlineReply,<LF> testParseIntegerReply,<LF> testParseMultiBulkReply,<LF> testPSUBSCRIBE,<LF> testPUBLISH,<LF> testPUNSUBSCRIBE,<LF> testRANDOMKEY,<LF> testRENAME,<LF> testRENAMENX,<LF> testRPOP,<LF> testRPOPLPUSH,<LF> testRPUSH,<LF> testSADD,<LF> testSAVE,<LF> testSCARD,<LF> testSDIFF,<LF> testSDIFFSTORE,<LF> testSELECT,<LF> testSET,<LF> testSETANDGETMULTIBYTE,<LF> testSETNX,<LF> testSHUTDOWN,<LF> testSINTER,<LF> testSINTERSTORE,<LF> testSISMEMBER,<LF> testSMEMBERS,<LF> testSMOVE,<LF> testSORT,<LF> testSPOP,<LF> testSREM,<LF> testSUBSCRIBE,<LF> testSUNION,<LF> testSUNIONSTORE,<LF> testTTL,<LF> testTYPE,<LF> testUNSUBSCRIBE,<LF> testZADD,<LF> testZCARD,<LF> testZCOUNT,<LF> testZINCRBY,<LF> testZINTER,<LF> testZRANGE,<LF> testZRANGEBYSCORE,<LF> testZRANK,<LF> testZREM,<LF> testZREMRANGEBYRANK,<LF> testZREMRANGEBYSCORE,<LF> testZREVRANGE,<LF> testZREVRANK,<LF> testZSCORE,<LF> testZUNION,<LF>];<LF><LF>function checkIfDone() {<LF> if (client.originalCommands.length == 0) {<LF> testSUBSCRIBEandPUBLISH();<LF> <LF> var checks = 0;<LF> setInterval(function () {<LF> if (messageWasReceived) {<LF> sys.error("\n");<LF> log("info", "All tests have passed.");<LF> process.exit(0);<LF> } else {<LF> assert.notEqual(++checks, 5, "testSUBSCRIBEandPUBLISH never received message");<LF> } <LF> }, 100);<LF> } else {<LF> if (verbose)<LF> log('info', client.originalCommands.length + " replies still pending...");<LF> else if (!quiet)<LF> sys.print("+");<LF> }<LF>}<LF><LF>function runAllTests() {<LF> allTestFunctions.forEach(function (testFunction) {<LF> if (verbose) {<LF> sys.error("");<LF> log("info", "Testing " + testFunction.name.replace(/^test/, ''));<LF> sys.error("=========================================");<LF> } else if (!quiet) {<LF> sys.print(".");<LF> }<LF><LF> clearTestDatabasesBeforeEachTest();<LF> testFunction();<LF> });<LF><LF> setInterval(checkIfDone, 1500);<LF> setTimeout(function() {<LF> log("error", "Tests timed out");<LF> process.exit(1);<LF> }, MAX_TEST_TIME);<LF>}<LF><LF>var connectionFailed = false;<LF>var client = redisclient.createClient();<LF>client.stream.addListener("connect", runAllTests);<LF>client.stream.addListener("close", function (inError) {<LF> connectionFailed = inError;<LF> if (inError)<LF> throw new Error("Connection to Redis failed. Not attempting reconnection.");<LF>});<LF><LF>function debugFilter(what) {<LF> var filtered = what;<LF><LF> filtered = filtered.replace(/\r\n/g, '<CRLF>');<LF> filtered = filtered.replace(/\r/g, '<CR>');<LF> filtered = filtered.replace(/\n/g, '<LF>');<LF><LF> return filtered;<LF>}<LF><LF>function printDisclaimer() {<LF> if (redisclient.debugMode) <LF> sys.debug("This test does not do anything");<LF>}<LF><LF><CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>$9<CRLF>getsetbar<CRLF>$4<CRLF>fuzz<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>$3<CRLF>baz<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>*4<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>$4<CRLF>quux<CRLF>$3<CRLF>doo<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>$1<CRLF>1<CRLF>:2<CRLF>$1<CRLF>2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>*2<CRLF>$3<CRLF>bar<CRLF>$4<CRLF>quux<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>$3<CRLF>baz<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>*2<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>doo<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:2<CRLF>:1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>$550<CRLF>redis_version:1.3.8<CRLF>arch_bits:32<CRLF>multiplexing_api:epoll<CRLF>process_id:7568<CRLF>uptime_in_seconds:86<CRLF>uptime_in_days:0<CRLF>connected_clients:1<CRLF>connected_slaves:0<CRLF>blocked_clients:0<CRLF>used_memory:2305613<CRLF>used_memory_human:2.20M<CRLF>changes_since_last_save:284<CRLF>bgsave_in_progress:0<CRLF>last_save_time:1271562403<CRLF>bgrewriteaof_in_progress:0<CRLF>total_connections_received:4<CRLF>total_commands_processed:2406<CRLF>expired_keys:0<CRLF>hash_max_zipmap_entries:64<CRLF>hash_max_zipmap_value:512<CRLF>pubsub_channels:0<CRLF>pubsub_patterns:0<CRLF>vm_enabled:0<CRLF>role:master<CRLF>db0:keys=2547,expires=0<CRLF><CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>*2<CRLF>$4<CRLF>foo1<CRLF>$4<CRLF>foo2<CRLF>+OK<CRLF>+OK<CRLF>*4<CRLF>$3<CRLF>boo<CRLF>$3<CRLF>baz<CRLF>$4<CRLF>foo1<CRLF>$4<CRLF>foo2<CRLF>*1<CRLF>$3<CRLF>boo<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1271562403<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>$11<CRLF>list0value0<CRLF>$11<CRLF>list0value1<CRLF>$-1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>:3<CRLF>$3<CRLF>GHI<CRLF>$3<CRLF>DEF<CRLF>*1<CRLF>$3<CRLF>ABC<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>:1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>*2<CRLF>$11<CRLF>list0value0<CRLF>$11<CRLF>list0value1<CRLF>*1<CRLF>$11<CRLF>list0value0<CRLF>*1<CRLF>$11<CRLF>list0value1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>:3<CRLF>:1<CRLF>*2<CRLF>$3<CRLF>DEF<CRLF>$3<CRLF>ABC<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>+OK<CRLF>*1<CRLF>$11<CRLF>LIST0VALUE0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>:3<CRLF>:3<CRLF>+OK<CRLF>:2<CRLF>*2<CRLF>$11<CRLF>list0value0<CRLF>$11<CRLF>list0value1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>*2<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>buz<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>+OK<CRLF>:1<CRLF>+OK<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>*3<CRLF>$10<CRLF>psubscribe<CRLF>$9<CRLF>cooking.*<CRLF>:1<CRLF>*3<CRLF>$12<CRLF>punsubscribe<CRLF>$9<CRLF>cooking.*<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+foo<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:0<CRLF>:1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>$3<CRLF>ABC<CRLF>$3<CRLF>DEF<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>$3<CRLF>DEF<CRLF>*1<CRLF>$3<CRLF>ABC<CRLF>*1<CRLF>$3<CRLF>DEF<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*2<CRLF>$1<CRLF>x<CRLF>$1<CRLF>b<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>*2<CRLF>$1<CRLF>x<CRLF>$1<CRLF>b<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>$11<CRLF>ö日本語<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*2<CRLF>$1<CRLF>c<CRLF>$1<CRLF>b<CRLF>*2<CRLF>$1<CRLF>c<CRLF>$1<CRLF>d<CRLF>*1<CRLF>$1<CRLF>c<CRLF>*1<CRLF>$1<CRLF>c<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*1<CRLF>$1<CRLF>c<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>*1<CRLF>$1<CRLF>x<CRLF>:1<CRLF>*2<CRLF>$1<CRLF>x<CRLF>$1<CRLF>y<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:0<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:2<CRLF>:3<CRLF>:4<CRLF>:1<CRLF>:2<CRLF>:3<CRLF>:4<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>*4<CRLF>$1<CRLF>a<CRLF>$1<CRLF>b<CRLF>$1<CRLF>c<CRLF>$1<CRLF>d<CRLF>*4<CRLF>$1<CRLF>d<CRLF>$1<CRLF>c<CRLF>$1<CRLF>b<CRLF>$1<CRLF>a<CRLF>*4<CRLF>$1<CRLF>2<CRLF>$1<CRLF>3<CRLF>$1<CRLF>4<CRLF>$1<CRLF>9<CRLF>*4<CRLF>$1<CRLF>9<CRLF>$1<CRLF>4<CRLF>$1<CRLF>3<CRLF>$1<CRLF>2<CRLF>*4<CRLF>$1<CRLF>3<CRLF>$1<CRLF>9<CRLF>$1<CRLF>4<CRLF>$1<CRLF>2<CRLF>*4<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>buz<CRLF>*8<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bux<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>tux<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>lux<CRLF>$3<CRLF>buz<CRLF>$3<CRLF>qux<CRLF>:8<CRLF>*8<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bux<CRLF>$3<CRLF>bar<CRLF>$3<CRLF>tux<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>lux<CRLF>$3<CRLF>buz<CRLF>$3<CRLF>qux<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>$7<CRLF>member0<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:0<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>*3<CRLF>$9<CRLF>subscribe<CRLF>$6<CRLF>#redis<CRLF>:1<CRLF>*3<CRLF>$9<CRLF>subscribe<CRLF>$8<CRLF>#Node.js<CRLF>:2<CRLF>*3<CRLF>$11<CRLF>unsubscribe<CRLF>$6<CRLF>#redis<CRLF>:1<CRLF>*3<CRLF>$11<CRLF>unsubscribe<CRLF>$8<CRLF>#Node.js<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*5<CRLF>$1<CRLF>b<CRLF>$1<CRLF>c<CRLF>$1<CRLF>d<CRLF>$1<CRLF>e<CRLF>$1<CRLF>a<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:5<CRLF>*5<CRLF>$1<CRLF>b<CRLF>$1<CRLF>c<CRLF>$1<CRLF>d<CRLF>$1<CRLF>e<CRLF>$1<CRLF>a<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:-1<CRLF>+OK<CRLF>:1<CRLF>:3<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>+set<CRLF>:1<CRLF>+list<CRLF>+OK<CRLF>+string<CRLF>+none<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:0<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>$1<CRLF>2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*2<CRLF>$1<CRLF>a<CRLF>$1<CRLF>4<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*3<CRLF>$2<CRLF>m0<CRLF>$2<CRLF>m1<CRLF>$2<CRLF>m2<CRLF>*1<CRLF>$2<CRLF>m2<CRLF>*2<CRLF>$2<CRLF>m1<CRLF>$2<CRLF>m2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*2<CRLF>$2<CRLF>m1<CRLF>$2<CRLF>m2<CRLF>*3<CRLF>$2<CRLF>m0<CRLF>$2<CRLF>m1<CRLF>$2<CRLF>m2<CRLF>*0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:0<CRLF>:1<CRLF>:2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*4<CRLF>$1<CRLF>a<CRLF>$1<CRLF>1<CRLF>$1<CRLF>b<CRLF>$1<CRLF>2<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>*2<CRLF>$1<CRLF>a<CRLF>$1<CRLF>1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>*3<CRLF>$2<CRLF>m2<CRLF>$2<CRLF>m1<CRLF>$2<CRLF>m0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>:1<CRLF>:0<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>$3<CRLF>100<CRLF>$3<CRLF>200<CRLF>$-1<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>+OK<CRLF>:1<CRLF>:1<CRLF>:1<CRLF>:2<CRLF>*4<CRLF>$1<CRLF>b<CRLF>$1<CRLF>2<CRLF>$1<CRLF>a<CRLF>$1<CRLF>4<CRLF>:0<CRLF>
[ERROR] testGET FAILED!
AssertionError: "#!/usr/bin/env node\n\n/*\n Redis client for Node.js -- tests\n\n Copyright (C) 2010 Fictorial LLC.\n\n Permission is hereby granted, free of charge, to any person obtaining\n a copy of this software and associated documentation files (the\n \"Software\"), to deal in the Software without restriction, including without\n limitation the rights to use, copy, modify, merge, publish, distribute,\n sublicense, and/or sell copies of the Software, and to permit persons to\n whom the Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n DEALINGS IN THE SOFTWARE.\n*/\n\n// http://github.com/fictorial/redis-node-client\n// Brian Hammond <brian at fictorial dot com>\n\n// NOTE: this test suite uses databases 14 and 15 for test purposes! \n// Make sure your Redis instance has at least this many databases; the default has 16.\n// These databases will be flushed these databases at the start of each test run. \n// If you want to use a different database number, update TEST_DB_NUMBER* below.\n\n// NOTE: each test is responsible for configuring the dataset needed to \n// run that test. There are no \"fixtures\" or similar.\n\nvar TEST_DB_NUMBER = 15,\n TEST_DB_NUMBER_FOR_MOVE = 14;\n\nvar MAX_TEST_TIME = 20000;\n\nvar sys = require(\"sys\"),\n assert = require(\"assert\"),\n redisclient = require(\"../lib/redis-client\"),\n fs = require(\"fs\"),\n Buffer = require(\"buffer\").Buffer;\n\nvar verbose = process.argv.indexOf(\"-v\") != -1;\nvar quiet = process.argv.indexOf(\"-q\") != -1;\n\nredisclient.debugMode = verbose && !quiet;\n\nfunction log(level, msg) {\n var colorsForLevel = { info:37, warn:33, error:31 };\n sys.error(\"\\033[\" + colorsForLevel[level || 'info'] + \"m[\" + \n level.toUpperCase() + \"] \" + msg + \"\\033[0m\");\n}\n\nfunction showContext(context) {\n sys.error(\"\\n\");\n log('error', context + \" FAILED!\");\n sys.error(\"\");\n}\n\n// These wrappers around the assert module exist because we generate functions\n// to test for expected conditions which lose context, and assert's functions\n// use the 'message' in place of the failed condition.\n\nfunction checkEqual(actual, expected, context) {\n try {\n assert.equal(actual, expected);\n } catch (e) {\n showContext(context);\n throw e;\n }\n}\n\nfunction check(what, context) {\n try {\n assert.ok(what);\n } catch (e) {\n showContext(context);\n throw e;\n }\n}\n\nfunction checkDeepEqual(actual, expected, context) {\n try {\n assert.deepEqual(actual, expected);\n } catch (e) {\n showContext(context);\n throw e;\n }\n}\n\n// Redis' protocol returns +OK for some operations to mean \"true\" or \"success\".\n// The client converts this into a boolean with value true.\n\nfunction expectOK(context) {\n return function (err, truthiness) {\n if (err) assert.fail(err, context);\n checkEqual(typeof(truthiness), 'boolean', context);\n checkEqual(truthiness, true, context);\n };\n}\n\nfunction maybeAsNumber(str) {\n var value = parseInt(str, 10);\n\n if (isNaN(value)) \n value = parseFloat(str);\n\n if (isNaN(value)) \n return str;\n\n return value;\n}\n\nfunction expectNumber(expectedValue, context) {\n return function (err, reply) {\n if (err) assert.fail(err, context);\n var value = maybeAsNumber(reply);\n checkEqual(value, expectedValue, context);\n };\n}\n\nfunction clearTestDatabasesBeforeEachTest() {\n client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK(\"select\"));\n client.flushdb(expectOK(\"flushdb\"));\n\n client.select(TEST_DB_NUMBER, expectOK(\"select\"));\n client.flushdb(expectOK(\"flushdb\"));\n}\n\nfunction bufferFromString(str, encoding) {\n var enc = encoding || 'utf8';\n var buf = new Buffer(str.length);\n switch (enc) {\n case 'utf8': buf.utf8Write(str); break;\n case 'ascii': buf.asciiWrite(str); break;\n case 'binary': buf.binaryWrite(str); break;\n default: \n assert.fail(\"unknown encoding: \" + encoding);\n }\n return buf;\n}\n\nfunction testParseBulkReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.BULK, \"testParseBulkReply a-0\");\n check(reply.value instanceof Buffer, \"testParseBulkReply a-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), \"FOOBAR\", \"testParseBulkReply a-2\");\n });\n a.feed(bufferFromString(\"$6\\r\\nFOOBAR\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.BULK, \"testParseBulkReply b-0\");\n checkEqual(reply.value, null, \"testParseBulkReply b-1\");\n });\n b.feed(bufferFromString(\"$-1\\r\\n\"));\n}\n\nBuffer.prototype.toString=function() {\n return this.utf8Slice(0,this.length);\n}\n\nfunction testParseMultiBulkReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply a-0\");\n check(reply.value instanceof Array, \"testParseMultiBulkReply a-1\");\n checkEqual(reply.value.length, 4, \"testParseMultiBulkReply a-2\");\n check(reply.value[0].type === redisclient.BULK, \"testParseMultiBulkReply a-3\");\n check(reply.value[1].type === redisclient.BULK, \"testParseMultiBulkReply a-4\");\n check(reply.value[2].type === redisclient.BULK, \"testParseMultiBulkReply a-5\");\n check(reply.value[3].type === redisclient.BULK, \"testParseMultiBulkReply a-6\");\n check(reply.value[0].value instanceof Buffer, \"testParseMultiBulkReply a-7\");\n check(reply.value[1].value instanceof Buffer, \"testParseMultiBulkReply a-8\");\n check(reply.value[2].value instanceof Buffer, \"testParseMultiBulkReply a-9\");\n check(reply.value[3].value instanceof Buffer, \"testParseMultiBulkReply a-10\");\n checkEqual(reply.value[0].value.length, 3, \"testParseMultiBulkReply a-11\");\n checkEqual(reply.value[1].value.length, 3, \"testParseMultiBulkReply a-12\");\n checkEqual(reply.value[2].value.length, 5, \"testParseMultiBulkReply a-13\");\n checkEqual(reply.value[3].value.length, 6, \"testParseMultiBulkReply a-14\");\n checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', \"testParseMultiBulkReply a-15\");\n checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), 'BAR', \"testParseMultiBulkReply a-16\");\n checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'HELLO', \"testParseMultiBulkReply a-17\");\n checkEqual(reply.value[3].value.utf8Slice(0, reply.value[3].value.length), 'WORLD!', \"testParseMultiBulkReply a-18\");\n });\n a.feed(bufferFromString(\"*4\\r\\n$3\\r\\nFOO\\r\\n$3\\r\\nBAR\\r\\n$5\\r\\nHELLO\\r\\n$6\\r\\nWORLD!\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply b-0\");\n checkEqual(reply.value, null, \"testParseMultiBulkReply b-1\");\n });\n b.feed(bufferFromString(\"*-1\\r\\n\"));\n\n var c = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply c-0\");\n check(reply.value instanceof Array, \"testParseMultiBulkReply c-1\");\n checkEqual(reply.value.length, 3, \"testParseMultiBulkReply c-2\");\n check(reply.value[0].type === redisclient.BULK, \"testParseMultiBulkReply c-3\");\n check(reply.value[1].type === redisclient.BULK, \"testParseMultiBulkReply c-4\");\n check(reply.value[2].type === redisclient.BULK, \"testParseMultiBulkReply c-5\");\n checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', \"testParseMultiBulkReply c-6\");\n checkEqual(reply.value[1].value, null, \"testParseMultiBulkReply c-7\");\n checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'BARZ', \"testParseMultiBulkReply c-8\");\n });\n c.feed(bufferFromString(\"*3\\r\\n$3\\r\\nFOO\\r\\n$-1\\r\\n$4\\r\\nBARZ\\r\\n\"));\n\n // Test with a multi-bulk reply containing a subreply that's non-bulk\n // but an inline/integer reply instead.\n\n var d = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply d-0\");\n check(reply.value instanceof Array, \"testParseMultiBulkReply d-1\");\n checkEqual(reply.value.length, 3, \"testParseMultiBulkReply d-2\");\n check(reply.value[0].type === redisclient.BULK, \"testParseMultiBulkReply d-3\");\n check(reply.value[1].type === redisclient.BULK, \"testParseMultiBulkReply d-4\");\n check(reply.value[2].type === redisclient.INTEGER, \"testParseMultiBulkReply d-5\");\n check(reply.value[0].value instanceof Buffer, \"testParseMultiBulkReply d-6\");\n check(reply.value[1].value instanceof Buffer, \"testParseMultiBulkReply d-7\");\n checkEqual(typeof(reply.value[2].value), \"number\", \"testParseMultiBulkReply d-8\");\n checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'subscribe', \"testParseMultiBulkReply d-9\");\n checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), '#redis', \"testParseMultiBulkReply d-10\");\n checkEqual(reply.value[2].value, 1, \"testParseMultiBulkReply d-11\");\n });\n d.feed(bufferFromString(\"*3\\r\\n$9\\r\\nsubscribe\\r\\n$6\\r\\n#redis\\r\\n:1\\r\\n*3\\r\\n$7\\r\\nmessage\\r\\n\"));\n\n var e = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply e-0\");\n checkEqual(reply.value, null, \"testParseMultiBulkReply e-1\");\n });\n e.feed(bufferFromString(\"*0\\r\\n\"));\n}\n\nfunction testParseInlineReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n // maybeConvertReplyValue is called by redisclient for non-test calls\n reply.value = redisclient.maybeConvertReplyValue_('N/A', reply); \n checkEqual(reply.type, redisclient.INLINE, \"testParseInlineReply a-0\");\n checkEqual(typeof(reply.value), 'boolean', \"testParseInlineReply a-1\");\n checkEqual(reply.value, true, \"testParseInlineReply a-2\");\n });\n a.feed(bufferFromString(\"+OK\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.INLINE, \"testParseInlineReply b-0\");\n check(reply.value instanceof Buffer, \"testParseInlineReply b-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), 'WHATEVER', \"testParseInlineReply b-2\");\n });\n b.feed(bufferFromString(\"+WHATEVER\\r\\n\"));\n}\n\nfunction testParseIntegerReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.INTEGER, \"testParseIntegerReply a-0\");\n checkEqual(typeof(reply.value), 'number', \"testParseIntegerReply a-1\");\n checkEqual(reply.value, -1, \"testParseIntegerReply a-2\");\n });\n a.feed(bufferFromString(\":-1\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.INTEGER, \"testParseIntegerReply b-0\");\n checkEqual(typeof(reply.value), 'number', \"testParseIntegerReply b-1\");\n checkEqual(reply.value, 1000, \"testParseIntegerReply b-2\");\n });\n b.feed(bufferFromString(\":1000\\r\\n\"));\n}\n\nfunction testParseErrorReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.ERROR, \"testParseErrorReply c-0\");\n check(reply.value instanceof Buffer, \"testParseErrorReply c-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), \"ERR solar flare\", \"testParseErrorReply c-2\");\n });\n a.feed(bufferFromString(\"-ERR solar flare\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.ERROR, \"testParseErrorReply b-0\");\n check(reply.value instanceof Buffer, \"testParseErrorReply b-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), \"hiccup\", \"testParseErrorReply b-2\");\n });\n b.feed(bufferFromString(\"-hiccup\\r\\n\"));\n}\n\nfunction testAUTH() {\n // You need to configure redis to enable auth.\n // This unit test suite assumes the auth feature is off/disabled.\n // Auth *would be* the first command required after connecting.\n\n printDisclaimer();\n}\n\nfunction testSELECT() {\n printDisclaimer();\n}\n\nfunction testFLUSHDB() {\n // no-op; tested in testSelect\n\n printDisclaimer();\n}\n\nfunction testSET() {\n client.set('foo', 'bar', expectOK(\"testSET\"));\n client.set('baz', 'buz', expectOK(\"testSET\"));\n client.set('ggg', '123', expectOK(\"testSET\"));\n}\n\nfunction testSETNX() {\n client.set('foo', 'bar', expectOK(\"testSETNX\"));\n client.setnx('foo', 'quux', expectNumber(0, \"testSETNX\")); // fails when already set\n client.setnx('boo', 'apple', expectNumber(1, \"testSETNX\")); // no such key already so OK\n}\n\nfunction testGET() {\n client.set('foo', 'bar', expectOK(\"testGET\"));\n client.set('baz', 'buz', expectOK(\"testGET\"));\n\n client.get('foo', function (err, value) {\n if (err) assert.fail(err, \"testGET\");\n checkEqual(value, 'bar', \"testGET\");\n });\n\n client.get('baz', function (err, value) {\n if (err) assert.fail(err, \"testGET\");\n checkEqual(value, 'buz', \"testGET\");\n });\n\n // Check buffer resizing of input buffer\n // by loading really large data and reading\n // it back. We use ourselves\n var large = fs.readFileSync(__filename);\n client.set('largetestfile', large);\n\n client.get('largetestfile', function(err, value) {\n if (err) assert.fail(err, \"testGET\");\n checkEqual(value.utf8Slice(0,value.length), large, \"testGET\");\n });\n}\n\nfunction testMGET() {\n client.set('foo', 'bar', expectOK(\"testMGET\"));\n client.set('baz', 'buz', expectOK(\"testMGET\"));\n\n client.mget('foo', 'baz', function (err, values) {\n if (err) assert.fail(err, \"testMGET\");\n checkEqual(values[0], 'bar', \"testMGET\");\n checkEqual(values[1], 'buz', \"testMGET\");\n });\n}\n\nfunction testGETSET() {\n client.set('getsetfoo', 'getsetbar', expectOK(\"testGETSET 0\"));\n\n client.getset('getsetfoo', 'fuzz', function (err, previousValue) {\n if (err) assert.fail(err, \"testGETSET 1\");\n checkEqual(previousValue, 'getsetbar', \"testGETSET 2\");\n });\n\n client.get('getsetfoo', function (err, value) {\n if (err) assert.fail(err, \"testGETSET 3\");\n checkEqual(value, 'fuzz', \"testGETSET 4\");\n });\n}\n\nfunction testSETANDGETMULTIBYTE() {\n var testValue = '\\u00F6\\u65E5\\u672C\\u8A9E'; // \u00f6\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n var buffer = new Buffer(32);\n var size = buffer.utf8Write(testValue,0);\n client.set('testUtf8Key', buffer.slice(0,size), expectOK(\"testSETANDGETMULTIBYTE\"))\n\n client.get('testUtf8Key', function (err, value) {\n if (err) assert.fail(err, \"testSETANDGETMULTIBYTE\");\n checkEqual(value.utf8Slice(0, value.length), testValue, \"testSETANDGETMULTIBYTE\");\n });\n}\n\nfunction testINFO() {\n client.info(function (err, info) {\n check(info instanceof Object, \"testINFO\");\n check(info.hasOwnProperty('redis_version'), \"testINFO\");\n check(info.hasOwnProperty('connected_clients'), \"testINFO\");\n check(info.hasOwnProperty('uptime_in_seconds'), \"testINFO\");\n checkEqual(typeof(info.uptime_in_seconds), 'string', \"testINFO\");\n checkEqual(typeof(info.connected_clients), 'string', \"testINFO\");\n });\n}\n\nfunction testINCR() {\n client.incr('counter', expectNumber(1, \"testINCR\"))\n client.incr('counter', expectNumber(2, \"testINCR\"))\n}\n\nfunction testINCRBY() {\n client.incrby('counter', 2, expectNumber(2, \"testINCRBY\"))\n client.incrby('counter', -1, expectNumber(1, \"testINCRBY\"))\n}\n\nfunction testDECR() {\n client.decr('counter', expectNumber(-1, \"testDECR\"))\n client.decr('counter', expectNumber(-2, \"testDECR\"))\n}\n\nfunction testDECRBY() {\n client.decrby('counter', '1', expectNumber(-1, \"testDECRBY\"))\n client.decrby('counter', '2', expectNumber(-3, \"testDECRBY\"))\n client.decrby('counter', '-3', expectNumber(0, \"testDECRBY\"))\n}\n\nfunction testEXISTS() {\n client.set('foo', 'bar', expectOK(\"testEXISTS\"));\n client.exists('foo', expectNumber(1, \"testEXISTS\"))\n client.exists('foo2', expectNumber(0, \"testEXISTS\"))\n}\n\nfunction testDEL() {\n client.set('goo', 'bar', expectOK(\"testDEL\"));\n client.del('goo', expectNumber(1, \"testDEL\"));\n client.exists('goo', expectNumber(0, \"testDEL\"));\n client.del('goo', expectNumber(0, \"testDEL\"));\n}\n\nfunction testKEYS() {\n client.set('foo1', 'foo1Value', expectOK(\"testKEYS\"))\n client.set('foo2', 'foo2Value', expectOK(\"testKEYS\"))\n\n client.keys('foo*', function (err, keys) {\n if (err) assert.fail(err, \"testKEYS\");\n checkEqual(keys.length, 2, \"testKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(keys);\n checkDeepEqual(keys.sort(), ['foo1', 'foo2'], \"testKEYS\");\n });\n\n client.set('baz', 'bazValue', expectOK(\"testKEYS\"))\n client.set('boo', 'booValue', expectOK(\"testKEYS\"))\n\n // At this point we have foo1, foo2, baz, boo\n\n client.keys('*', function (err, keys) {\n if (err) assert.fail(err, \"testKEYS\");\n checkEqual(keys.length, 4, \"testKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(keys);\n checkDeepEqual(keys.sort(), ['baz', 'boo', 'foo1', 'foo2'], \"testKEYS\");\n });\n\n client.keys('?oo', function (err, keys) {\n if (err) assert.fail(err, \"testKEYS\");\n checkEqual(keys.length, 1, \"testKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(keys);\n checkDeepEqual(keys.sort(), ['boo'], \"testKEYS\");\n });\n}\n\nfunction testRANDOMKEY() {\n client.set('foo', 'bar', expectOK(\"testRANDOMKEY\"));\n client.set('baz', 'buz', expectOK(\"testRANDOMKEY\"));\n\n client.randomkey(function (err, someKey) {\n if (err) assert.fail(err, \"testRANDOMKEY\");\n check(/^(foo|baz)$/.test(someKey), \"testRANDOMKEY\");\n });\n}\n\nfunction testRENAME() {\n client.set('foo', 'bar', expectOK(\"testRENAME\"));\n client.rename('foo', 'zoo', expectOK(\"testRENAME\"));\n client.exists('foo', expectNumber(0, \"testRENAME\"));\n client.exists('zoo', expectNumber(1, \"testRENAME\"));\n}\n\nfunction testRENAMENX() {\n client.set('roo', 'bar', expectOK(\"testRENAMENX\"));\n client.set('bar', 'baz', expectOK(\"testRENAMENX\"));\n client.renamenx('roo', 'bar', expectNumber(0, \"testRENAMENX\")); // bar already exists\n client.exists('roo', expectNumber(1, \"testRENAMENX\")); // was not renamed\n client.exists('bar', expectNumber(1, \"testRENAMENX\")); // was not touched\n client.renamenx('roo', 'too', expectNumber(1, \"testRENAMENX\")); // too did not exist... OK\n client.exists('roo', expectNumber(0, \"testRENAMENX\")); // was renamed\n client.exists('too', expectNumber(1, \"testRENAMENX\")); // was created\n}\n\nfunction testDBSIZE() {\n client.set('foo', 'bar', expectOK(\"testDBSIZE\"));\n client.set('bar', 'baz', expectOK(\"testDBSIZE\"));\n\n client.dbsize(function (err, value) {\n if (err) assert.fail(err, \"testDBSIZE\");\n checkEqual(value, 2, \"testDBSIZE\");\n });\n}\n\nfunction testEXPIRE() {\n // set 'expfoo' to expire in 2 seconds\n\n client.set('expfoo', 'bar', expectOK(\"testEXPIRE\"));\n client.expire('expfoo', 2, expectNumber(1, \"testEXPIRE\"));\n\n // subsequent expirations cannot be set.\n\n client.expire('expfoo', 2, expectNumber(0, \"testEXPIRE\"));\n\n setTimeout(function () {\n client.exists('expfoo', expectNumber(0, \"testEXPIRE\"));\n }, 2500);\n}\n\nfunction testTTL() {\n client.set('ttlfoo', 'bar', expectOK(\"testTTL\"));\n\n // ttlfoo is not set to expire\n\n client.ttl('ttlfoo', function (err, value) {\n if (err) assert.fail(err, \"testTTL\");\n checkEqual(value, -1, \"testTTL\");\n });\n\n client.set('ttlbar', 'baz', expectOK(\"testTTL\"));\n client.expire('ttlbar', 3, expectNumber(1, \"testTTL\"));\n\n client.ttl('ttlbar', function (err, value) {\n if (err) assert.fail(err, \"testTTL\");\n check(value > 0, \"testTTL\");\n });\n}\n\nfunction testRPUSH() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testRPUSH\"));\n client.exists('list0', expectNumber(1, \"testRPUSH\"));\n}\n\nfunction testLPUSH() {\n client.exists('list1', expectNumber(0, \"testLPUSH\"));\n client.lpush('list1', 'list1value0', expectNumber(1, \"testLPUSH\"));\n client.exists('list1', expectNumber(1, \"testLPUSH\"));\n}\n\nfunction testLLEN() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLLEN\"));\n client.llen('list0', expectNumber(1, \"testLLEN\"));\n\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLLEN\"));\n client.llen('list0', expectNumber(2, \"testLLEN\"));\n}\n\nfunction testLRANGE() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLRANGE\"));\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLRANGE\"));\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLRANGE\");\n checkEqual(values.length, 2, \"testLRANGE\");\n checkEqual(values[0], 'list0value0', \"testLRANGE\");\n checkEqual(values[1], 'list0value1', \"testLRANGE\");\n });\n\n client.lrange('list0', 0, 0, function (err, values) {\n if (err) assert.fail(err, \"testLRANGE\");\n checkEqual(values.length, 1, \"testLRANGE\");\n checkEqual(values[0], 'list0value0', \"testLRANGE\");\n });\n\n client.lrange('list0', -1, -1, function (err, values) {\n if (err) assert.fail(err, \"testLRANGE\");\n checkEqual(values.length, 1, \"testLRANGE\");\n checkEqual(values[0], 'list0value1', \"testLRANGE\");\n });\n}\n\nfunction testLTRIM() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLTRIM\"));\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLTRIM\"));\n client.rpush('list0', 'list0value2', expectNumber(3, \"testLTRIM\"));\n\n client.llen('list0', function (err, len) {\n if (err) assert.fail(err, \"testLTRIM\");\n checkEqual(len, 3, \"testLTRIM\");\n });\n\n client.ltrim('list0', 0, 1, expectOK(\"testLTRIM\"))\n\n client.llen('list0', function (err, len) {\n if (err) assert.fail(err, \"testLTRIM\");\n checkEqual(len, 2, \"testLTRIM\");\n });\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLTRIM\");\n checkEqual(values.length, 2, \"testLTRIM\");\n checkEqual(values[0], 'list0value0', \"testLTRIM\");\n checkEqual(values[1], 'list0value1', \"testLTRIM\");\n });\n}\n\nfunction testLINDEX() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLINDEX\"));\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLINDEX\"));\n\n client.lindex('list0', 0, function (err, value) {\n if (err) assert.fail(err, \"testLINDEX\");\n checkEqual(value, 'list0value0', \"testLINDEX\");\n });\n\n client.lindex('list0', 1, function (err, value) {\n if (err) assert.fail(err, \"testLINDEX\");\n checkEqual(value, 'list0value1', \"testLINDEX\");\n });\n\n // out of range => null\n\n client.lindex('list0', 2, function (err, value) {\n if (err) assert.fail(err, \"testLINDEX\");\n checkEqual(value, null, \"testLINDEX\");\n });\n}\n\nfunction testLSET() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLSET\"));\n client.lset('list0', 0, 'LIST0VALUE0', expectOK(\"testLSET\"));\n\n client.lrange('list0', 0, 0, function (err, values) {\n if (err) assert.fail(err, \"testLSET\");\n checkEqual(values.length, 1, \"testLSET\");\n checkEqual(values[0], 'LIST0VALUE0', \"testLSET\");\n });\n}\n\nfunction testLREM() {\n client.lpush('list0', 'ABC', expectNumber(1, \"testLREM\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testLREM\"));\n client.lpush('list0', 'ABC', expectNumber(3, \"testLREM\"));\n\n client.lrem('list0', 1, 'ABC', expectNumber(1, \"testLREM\"));\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLREM\");\n checkEqual(values.length, 2, \"testLREM\");\n checkEqual(values[0], 'DEF', \"testLREM\");\n checkEqual(values[1], 'ABC', \"testLREM\");\n });\n}\n\nfunction testLPOP() {\n client.lpush('list0', 'ABC', expectNumber(1, \"testLPOP\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testLPOP\"));\n client.lpush('list0', 'GHI', expectNumber(3, \"testLPOP\"));\n\n client.lpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testLPOP\");\n checkEqual(value, 'GHI', \"testLPOP\");\n });\n\n client.lpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testLPOP\");\n checkEqual(value, 'DEF', \"testLPOP\");\n });\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLPOP\");\n checkEqual(values.length, 1, \"testLPOP\");\n checkEqual(values[0], 'ABC', \"testLPOP\");\n });\n}\n\nfunction testRPOP() {\n client.lpush('list0', 'ABC', expectNumber(1, \"testRPOP\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testRPOP\"));\n\n client.rpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testRPOP\");\n checkEqual(value, 'ABC', \"testRPOP\");\n });\n\n client.rpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testRPOP\");\n checkEqual(value, 'DEF', \"testRPOP\");\n });\n\n client.llen('list0', function (err, len) {\n if (err) assert.fail(err, \"testRPOP\");\n checkEqual(len, 0, \"testRPOP\");\n });\n}\n\nfunction testRPOPLPUSH() {\n client.rpush('src', 'ABC', expectNumber(1, \"testRPOPLPUSH\"));\n client.rpush('src', 'DEF', expectNumber(2, \"testRPOPLPUSH\"));\n\n client.rpoplpush('src', 'dst', function (err, value) {\n if (err) assert.fail(err, \"testRPOPLPUSH\");\n checkEqual(value, 'DEF', \"testRPOPLPUSH\");\n });\n\n client.lrange('src', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testRPOPLPUSH\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(values);\n checkDeepEqual(values, [ 'ABC' ], \"testRPOPLPUSH\");\n });\n\n client.lrange('dst', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testRPOPLPUSH\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(values);\n checkDeepEqual(values, [ 'DEF' ], \"testRPOPLPUSH\");\n });\n}\n\nfunction testSADD() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSADD\"));\n client.sadd('set0', 'member0', expectNumber(0, \"testSADD\")); // already member\n}\n\nfunction testSISMEMBER() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSISMEMBER\"));\n client.sismember('set0', 'member0', expectNumber(1, \"testSISMEMBER\"));\n client.sismember('set0', 'member1', expectNumber(0, \"testSISMEMBER\"));\n}\n\nfunction testSCARD() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSCARD\"));\n client.scard('set0', expectNumber(1, \"testSCARD\"));\n\n client.sadd('set0', 'member1', expectNumber(1, \"testSCARD\"));\n client.scard('set0', expectNumber(2, \"testSCARD\"));\n}\n\nfunction testSREM() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSREM\"));\n client.srem('set0', 'foobar', expectNumber(0, \"testSREM\"))\n client.srem('set0', 'member0', expectNumber(1, \"testSREM\"))\n client.scard('set0', expectNumber(0, \"testSREM\"));\n}\n\nfunction testSPOP() {\n client.sadd('zzz', 'member0', expectNumber(1, \"testSPOP\"));\n client.scard('zzz', expectNumber(1, \"testSPOP\"));\n\n client.spop('zzz', function (err, value) {\n if (err) assert.fail(err, \"testSPOP\");\n checkEqual(value, 'member0', \"testSPOP\");\n });\n\n client.scard('zzz', expectNumber(0, \"testSPOP\"));\n}\n\nfunction testSDIFF() {\n client.sadd('foo', 'x', expectNumber(1, \"testSDIFF\"));\n client.sadd('foo', 'a', expectNumber(1, \"testSDIFF\"));\n client.sadd('foo', 'b', expectNumber(1, \"testSDIFF\"));\n client.sadd('foo', 'c', expectNumber(1, \"testSDIFF\"));\n\n client.sadd('bar', 'c', expectNumber(1, \"testSDIFF\"));\n\n client.sadd('baz', 'a', expectNumber(1, \"testSDIFF\"));\n client.sadd('baz', 'd', expectNumber(1, \"testSDIFF\"));\n\n client.sdiff('foo', 'bar', 'baz', function (err, values) {\n if (err) assert.fail(err, \"testSDIFF\");\n values.sort();\n checkEqual(values.length, 2, \"testSDIFF\");\n checkEqual(values[0], 'b', \"testSDIFF\");\n checkEqual(values[1], 'x', \"testSDIFF\");\n });\n}\n\nfunction testSDIFFSTORE() {\n client.sadd('foo', 'x', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('foo', 'a', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('foo', 'b', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('foo', 'c', expectNumber(1, \"testSDIFFSTORE\"))\n\n client.sadd('bar', 'c', expectNumber(1, \"testSDIFFSTORE\"))\n\n client.sadd('baz', 'a', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('baz', 'd', expectNumber(1, \"testSDIFFSTORE\"))\n\n // NB: SDIFFSTORE returns the number of elements in the dstkey \n\n client.sdiffstore('quux', 'foo', 'bar', 'baz', expectNumber(2, \"testSDIFFSTORE\"))\n\n client.smembers('quux', function (err, members) {\n if (err) assert.fail(err, \"testSDIFFSTORE\");\n members.sort();\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'b', 'x' ], \"testSDIFFSTORE\");\n });\n}\n\nfunction testSMEMBERS() {\n client.sadd('foo', 'x', expectNumber(1, \"testSMEMBERS\"));\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testSMEMBERS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'x' ], \"testSMEMBERS\");\n });\n\n client.sadd('foo', 'y', expectNumber(1, \"testSMEMBERS\"));\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testSMEMBERS\");\n checkEqual(members.length, 2, \"testSMEMBERS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members.sort(), [ 'x', 'y' ], \"testSMEMBERS\");\n });\n}\n\nfunction testSMOVE() {\n client.sadd('foo', 'x', expectNumber(1, \"testSMOVE\"));\n client.smove('foo', 'bar', 'x', expectNumber(1, \"testSMOVE\"));\n client.sismember('foo', 'x', expectNumber(0, \"testSMOVE\"));\n client.sismember('bar', 'x', expectNumber(1, \"testSMOVE\"));\n client.smove('foo', 'bar', 'x', expectNumber(0, \"testSMOVE\"));\n}\n\nfunction testSINTER() {\n client.sadd('sa', 'a', expectNumber(1, \"testSINTER\"));\n client.sadd('sa', 'b', expectNumber(1, \"testSINTER\"));\n client.sadd('sa', 'c', expectNumber(1, \"testSINTER\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testSINTER\"));\n client.sadd('sb', 'c', expectNumber(1, \"testSINTER\"));\n client.sadd('sb', 'd', expectNumber(1, \"testSINTER\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testSINTER\"));\n client.sadd('sc', 'd', expectNumber(1, \"testSINTER\"));\n client.sadd('sc', 'e', expectNumber(1, \"testSINTER\"));\n\n client.sinter('sa', 'sb', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 2, \"testSINTER\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);\n checkDeepEqual(intersection.sort(), [ 'b', 'c' ], \"testSINTER\");\n });\n\n client.sinter('sb', 'sc', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 2, \"testSINTER\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);\n checkDeepEqual(intersection.sort(), [ 'c', 'd' ], \"testSINTER\");\n });\n\n client.sinter('sa', 'sc', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 1, \"testSINTER\");\n checkEqual(intersection[0], 'c', \"testSINTER\");\n });\n\n // 3-way\n\n client.sinter('sa', 'sb', 'sc', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 1, \"testSINTER\");\n checkEqual(intersection[0], 'c', \"testSINTER\");\n });\n}\n\nfunction testSINTERSTORE() {\n client.sadd('sa', 'a', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sa', 'b', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sa', 'c', expectNumber(1, \"testSINTERSTORE\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sb', 'c', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sb', 'd', expectNumber(1, \"testSINTERSTORE\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sc', 'd', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sc', 'e', expectNumber(1, \"testSINTERSTORE\"));\n\n client.sinterstore('foo', 'sa', 'sb', 'sc', expectNumber(1, \"testSINTERSTORE\"))\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testSINTERSTORE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'c' ], \"testSINTERSTORE\");\n });\n}\n\nfunction testSUNION() {\n client.sadd('sa', 'a', expectNumber(1, \"testUNION\"));\n client.sadd('sa', 'b', expectNumber(1, \"testUNION\"));\n client.sadd('sa', 'c', expectNumber(1, \"testUNION\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testUNION\"));\n client.sadd('sb', 'c', expectNumber(1, \"testUNION\"));\n client.sadd('sb', 'd', expectNumber(1, \"testUNION\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testUNION\"));\n client.sadd('sc', 'd', expectNumber(1, \"testUNION\"));\n client.sadd('sc', 'e', expectNumber(1, \"testUNION\"));\n\n client.sunion('sa', 'sb', 'sc', function (err, union) {\n if (err) assert.fail(err, \"testUNION\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(union);\n checkDeepEqual(union.sort(), ['a', 'b', 'c', 'd', 'e'], \"testUNION\");\n });\n}\n\nfunction testSUNIONSTORE() {\n client.sadd('sa', 'a', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sa', 'b', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sa', 'c', expectNumber(1, \"testUNIONSTORE\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sb', 'c', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sb', 'd', expectNumber(1, \"testUNIONSTORE\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sc', 'd', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sc', 'e', expectNumber(1, \"testUNIONSTORE\"));\n\n client.sunionstore('foo', 'sa', 'sb', 'sc', function (err, cardinality) {\n if (err) assert.fail(err, \"testUNIONSTORE\");\n checkEqual(cardinality, 5, \"testUNIONSTORE\");\n });\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testUNIONSTORE\");\n checkEqual(members.length, 5, \"testUNIONSTORE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members.sort(), ['a', 'b', 'c', 'd', 'e'], \"testUNIONSTORE\");\n });\n}\n\nfunction testTYPE() {\n client.sadd('sa', 'a', expectNumber(1, \"testTYPE\"));\n client.type('sa', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'set', \"testTYPE\");\n });\n\n client.rpush('list0', 'x', expectNumber(1, \"testTYPE\"));\n client.type('list0', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'list', \"testTYPE\");\n });\n\n client.set('foo', 'bar', expectOK(\"testTYPE\"));\n client.type('foo', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'string', \"testTYPE\");\n });\n\n client.type('xxx', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'none', \"testTYPE\");\n });\n}\n\nfunction testMOVE() {\n client.rpush('list0', 'x', expectNumber(1, \"testMOVE\"));\n client.move('list0', TEST_DB_NUMBER_FOR_MOVE, expectNumber(1, \"testMOVE\"));\n\n client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK(\"testMOVE\"));\n client.exists('list0', expectNumber(1, \"testMOVE\"));\n\n client.select(TEST_DB_NUMBER, expectOK(\"testMOVE\"));\n client.exists('list0', expectNumber(0, \"testMOVE\"));\n}\n\n// TODO sort with STORE option.\n\n// Sort is a beast.\n//\n// $ redis-cli lrange x 0 -1\n// 1. 3\n// 2. 9\n// 3. 2\n// 4. 4\n//\n// $ redis-cli mget w3 w9 w2 w4\n// 1. 4\n// 2. 5\n// 3. 12\n// 4. 6\n//\n// $ redis-cli sort x by w*\n// 1. 3\n// 2. 9\n// 3. 4\n// 4. 2\n//\n// When using 'by w*' value x[i]'s effective value is w{x[i]}.\n//\n// sort [ w3, w9, w2, w4 ] = sort [ 4, 5, 12, 6 ]\n// = [ 4, 5, 6, 12 ]\n// = [ w3, w9, w4, w2 ]\n//\n// Thus, sorting x 'by w*' results in [ 3, 9, 4, 2 ]\n//\n// Once sorted redis can fetch entries at the keys indicated by the 'get'\n// pattern. If we specify 'get o*', redis would fetch [ o3, o9, o4, o2 ] \n// since our sorted list was [ 3, 9, 4, 2 ].\n//\n// $ redis-cli mget o2 o3 o4 o9\n// 1. buz\n// 2. foo\n// 3. baz\n// 4. bar\n//\n// $ redis-cli sort x by w* get o*\n// 1. foo\n// 2. bar\n// 3. baz\n// 4. buz\n//\n// One can specify multiple get patterns and the keys for each get pattern\n// are interlaced in the results.\n//\n// $ redis-cli mget p2 p3 p4 p9\n// 1. qux\n// 2. bux\n// 3. lux\n// 4. tux\n//\n// $ redis-cli sort x by w* get o* get p*\n// 1. foo\n// 2. bux\n// 3. bar\n// 4. tux\n// 5. baz\n// 6. lux\n// 7. buz\n// 8. qux\n//\n// Phew! Now, let's test all that.\n\nfunction testSORT() {\n client.rpush('y', 'd', expectNumber(1, \"testSORT\"));\n client.rpush('y', 'b', expectNumber(2, \"testSORT\"));\n client.rpush('y', 'a', expectNumber(3, \"testSORT\"));\n client.rpush('y', 'c', expectNumber(4, \"testSORT\"));\n\n client.rpush('x', '3', expectNumber(1, \"testSORT\"));\n client.rpush('x', '9', expectNumber(2, \"testSORT\"));\n client.rpush('x', '2', expectNumber(3, \"testSORT\"));\n client.rpush('x', '4', expectNumber(4, \"testSORT\"));\n\n client.set('w3', '4', expectOK(\"testSORT\"));\n client.set('w9', '5', expectOK(\"testSORT\"));\n client.set('w2', '12', expectOK(\"testSORT\"));\n client.set('w4', '6', expectOK(\"testSORT\"));\n\n client.set('o2', 'buz', expectOK(\"testSORT\"));\n client.set('o3', 'foo', expectOK(\"testSORT\"));\n client.set('o4', 'baz', expectOK(\"testSORT\"));\n client.set('o9', 'bar', expectOK(\"testSORT\"));\n\n client.set('p2', 'qux', expectOK(\"testSORT\"));\n client.set('p3', 'bux', expectOK(\"testSORT\"));\n client.set('p4', 'lux', expectOK(\"testSORT\"));\n client.set('p9', 'tux', expectOK(\"testSORT\"));\n\n // Now the data has been setup, we can test.\n\n // But first, test basic sorting.\n\n // y = [ d b a c ]\n // sort y ascending = [ a b c d ]\n // sort y descending = [ d c b a ]\n\n client.sort('y', 'asc', 'alpha', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['a', 'b', 'c', 'd'], \"testSORT\");\n });\n\n client.sort('y', 'desc', 'alpha', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['d', 'c', 'b', 'a'], \"testSORT\");\n });\n\n // Now try sorting numbers in a list.\n // x = [ 3, 9, 2, 4 ]\n\n client.sort('x', 'asc', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, [2, 3, 4, 9], \"testSORT\");\n });\n\n client.sort('x', 'desc', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, [9, 4, 3, 2], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern.\n\n client.sort('x', 'by', 'w*', 'asc', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, [3, 9, 4, 2], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern and 1 'get' pattern.\n\n client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['foo', 'bar', 'baz', 'buz'], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern and 2 'get' patterns.\n\n client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern and 2 'get' patterns.\n // Instead of getting back the sorted set/list, store the values to a list.\n // Then check that the values are there in the expected order.\n\n client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', 'store', 'bacon', function (err) {\n if (err) assert.fail(err, \"testSORT\");\n });\n\n client.lrange('bacon', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(values);\n checkDeepEqual(values, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], \"testSORT\");\n });\n}\n\nfunction testSAVE() {\n client.save(expectOK(\"testSAVE\"));\n}\n\nfunction testBGSAVE() {\n printDisclaimer();\n}\n\nfunction testLASTSAVE() {\n client.lastsave( function (err, value) {\n if (err) assert.fail(err, \"testLASTSAVE\");\n checkEqual(typeof(value), 'number', \"testLASTSAVE\");\n check(value > 0, \"testLASTSAVE\");\n });\n}\n\nfunction testFLUSHALL() {\n printDisclaimer();\n}\n\nfunction testSHUTDOWN() {\n printDisclaimer();\n}\n\nfunction testMSET() {\n // set a=b, c=d, e=100\n\n client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK(\"testMSET\"));\n}\n\nfunction testMSETNX() {\n client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK(\"testMSET\"));\n\n // should fail since as 'a' already exists.\n\n client.msetnx('g', 'h', 'a', 'i', expectNumber(0, \"testMSETNX\"));\n\n // should pass as key 'g' was NOT set in prev. command\n // since it failed due to key 'a' already existing.\n\n client.msetnx('g', 'h', 'i', 'j', expectNumber(1, \"testMSETNX\"));\n}\n\nfunction testZADD() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZADD\"));\n\n // Already added m0; just update the score to 50.\n // Redis returns 0 in this case.\n\n client.zadd('z0', 50, 'm0', expectNumber(0, \"testZADD\"));\n}\n\nfunction testZREM() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZREM\"));\n client.zrem('z0', 'm0', expectNumber(1, \"testZREM\"));\n client.zrem('z0', 'm0', expectNumber(0, \"testZREM\"));\n}\n\nfunction testZCARD() {\n client.zcard('zzzzzz', expectNumber(0, \"testZCARD\")); // doesn't exist.\n\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZCARD\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZCARD\"));\n\n client.zcard('z0', expectNumber(2, \"testZCARD\"));\n}\n\nfunction testZSCORE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZSCORE\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZSCORE\"));\n\n client.zscore('z0', 'm0', expectNumber(100, \"testZSCORE\"));\n client.zscore('z0', 'm1', expectNumber(200, \"testZSCORE\"));\n\n client.zscore('z0', 'zzzzzzz', function (err, score) {\n if (err) assert.fail(err, \"testZSCORE\");\n checkEqual(score, null, \"testZSCORE\");\n });\n}\n\nfunction testZRANGE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZRANGE\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZRANGE\"));\n client.zadd('z0', 300, 'm2', expectNumber(1, \"testZRANGE\"));\n\n client.zrange('z0', 0, -1, function (err, members) {\n if (err) assert.fail(err, \"testZRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], \"testZRANGE\");\n });\n\n client.zrange('z0', -1, -1, function (err, members) {\n if (err) assert.fail(err, \"testZRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm2' ], \"testZRANGE\");\n });\n\n client.zrange('z0', -2, -1, function (err, members) {\n if (err) assert.fail(err, \"testZRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm1', 'm2' ], \"testZRANGE\");\n });\n}\n\nfunction testZREVRANGE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZREVRANGE\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZREVRANGE\"));\n client.zadd('z0', 300, 'm2', expectNumber(1, \"testZREVRANGE\"));\n\n client.zrevrange('z0', 0, 1000, function (err, members) {\n if (err) assert.fail(err, \"testZREVRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm2', 'm1', 'm0' ], \"testZREVRANGE\");\n });\n}\n\nfunction testZRANGEBYSCORE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZRANGEBYSCORE 1\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZRANGEBYSCORE 2\"));\n client.zadd('z0', 300, 'm2', expectNumber(1, \"testZRANGEBYSCORE 3\"));\n\n client.zrangebyscore('z0', 200, 300, function (err, members) {\n if (err) assert.fail(err, \"testZRANGEBYSCORE 4\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm1', 'm2' ], \"testZRANGEBYSCORE 5\");\n });\n\n client.zrangebyscore('z0', 100, 1000, function (err, members) {\n if (err) assert.fail(err, \"testZRANGEBYSCORE 6\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], \"testZRANGEBYSCORE 7\");\n });\n\n client.zrangebyscore('z0', 10000, 100000, function (err, members) {\n if (err) assert.fail(err, \"testZRANGEBYSCORE 8\");\n checkEqual(members, null, \"testZRANGEBYSCORE 9\");\n });\n}\n\n// zcount is undocumented as of Thu Apr 01 20:17:58 EDT 2010 \n// zcount key startScore endScore => number of elements in [startScore, endScore]\n\nfunction testZCOUNT() {\n client.zcount('z0', 0, 100, expectNumber(0, \"testZCOUNT\"));\n\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZCOUNT\"));\n client.zcount('z0', 0, 100, expectNumber(1, \"testZCOUNT\"));\n\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZCOUNT\"));\n client.zcount('z0', 0, 100, expectNumber(2, \"testZCOUNT\"));\n}\n\nfunction testZINCRBY() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZINCRBY\"));\n client.zincrby('z0', 1, 'a', expectNumber(2, \"testZINCRBY\"));\n}\n\n// This really should be called ZINTERSTORE.\n\nfunction testZINTER() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZINTER\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZINTER\"));\n client.zadd('z1', 3, 'a', expectNumber(1, \"testZINTER\"));\n client.zinter('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(1, \"testZINTER\"));\n client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZINTER\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'a', 4 ], \"testZINTER\"); // score=1+3\n });\n}\n\nfunction testZUNION() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZUNION\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZUNION\"));\n client.zadd('z1', 3, 'a', expectNumber(1, \"testZUNION\"));\n client.zunion('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(2, \"testZUNION\"));\n client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZUNION\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n check(members.length % 2 == 0, \"testZUNION\");\n var set = {};\n for (var i=0; i<members.length; i += 2)\n set[members[i]] = members[i + 1];\n checkDeepEqual(set, { a:4, b:2 }, \"testZUNION\"); // a's score=1+3\n });\n}\n\nfunction testZRANK() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZRANK\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZRANK\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZRANK\"));\n\n client.zrank('z0', 'a', expectNumber(0, \"testZRANK\"));\n client.zrank('z0', 'b', expectNumber(1, \"testZRANK\"));\n client.zrank('z0', 'c', expectNumber(2, \"testZRANK\"));\n}\n\nfunction testZREVRANK() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZREVRANK\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZREVRANK\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZREVRANK\"));\n\n client.zrevrank('z0', 'a', expectNumber(2, \"testZREVRANK\"));\n client.zrevrank('z0', 'b', expectNumber(1, \"testZREVRANK\"));\n client.zrevrank('z0', 'c', expectNumber(0, \"testZREVRANK\"));\n}\n\nfunction testZREMRANGEBYRANK() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZREMRANGEBYRANK\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZREMRANGEBYRANK\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZREMRANGEBYRANK\"));\n\n client.zremrangebyrank('z0', -1, -1, expectNumber(1, \"testZREMRANGEBYRANK\"));\n\n client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZREMRANGEBYRANK\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n check(members.length % 2 == 0, \"testZREMRANGEBYRANK\");\n var set = {};\n for (var i=0; i<members.length; i += 2)\n set[members[i]] = members[i + 1];\n checkDeepEqual(set, { a:1, b:2 }, \"testZREMRANGEBYRANK\");\n });\n}\n\nfunction testZREMRANGEBYSCORE() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZREMRANGEBYSCORE\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZREMRANGEBYSCORE\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZREMRANGEBYSCORE\"));\n\n // inclusive\n client.zremrangebyscore('z0', 2, 3, expectNumber(2, \"testZREMRANGEBYSCORE\"));\n\n client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZREMRANGEBYSCORE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n check(members.length % 2 == 0, \"testZREMRANGEBYSCORE\");\n var set = {};\n for (var i=0; i<members.length; i += 2)\n set[members[i]] = members[i + 1];\n checkDeepEqual(set, { a:1 }, \"testZREMRANGEBYSCORE\");\n });\n}\n\nfunction testHDEL() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHDEL\"));\n client.hdel(\"foo\", \"bar\", expectNumber(1, \"testHDEL\"));\n client.hdel(\"foo\", \"bar\", expectNumber(0, \"testHDEL\"));\n}\n\nfunction testHEXISTS() {\n client.hset(\"hfoo\", \"bar\", \"baz\", expectNumber(1, \"testHEXISTS\"));\n client.hexists(\"hfoo\", \"bar\", expectNumber(1, \"testHEXISTS\"));\n client.hexists(\"hfoo\", \"baz\", expectNumber(0, \"testHEXISTS\"));\n}\n\nfunction testHGET() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHGET\"));\n client.hget(\"foo\", \"bar\", function (err, reply) {\n if (err) assert.fail(err, \"testHGET\");\n checkEqual(\"baz\", reply, \"testHGET\");\n });\n}\n\nfunction testHGETALL() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHGETALL\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHGETALL\"));\n client.hgetall(\"foo\", function (err, all) {\n if (err) assert.fail(err, \"testHGETALL\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(all);\n checkDeepEqual(all, { bar:\"baz\", quux:\"doo\" }, \"testHGETALL\");\n });\n}\n\nfunction testHINCRBY() {\n client.hincrby(\"foo\", \"bar\", 1, expectNumber(1, \"testHINCRBY 1\"));\n client.hget(\"foo\", \"bar\", expectNumber(1, \"testHINCRBY 2\"));\n\n client.hincrby(\"foo\", \"bar\", 1, expectNumber(2, \"testHINCRBY 3\"));\n client.hget(\"foo\", \"bar\", expectNumber(2, \"testHINCRBY 4\"));\n}\n\nfunction testHKEYS() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHKEYS\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHKEYS\"));\n client.hkeys(\"foo\", function (err, reply) {\n if (err) assert.fail(err, \"testHKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply.sort(), [ \"bar\", \"quux\" ], \"testHKEYS\");\n });\n}\n\nfunction testHVALS() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHVALS\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHVALS\"));\n client.hvals(\"foo\", function (err, reply) {\n if (err) assert.fail(err, \"testHVALS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply.sort(), [ \"baz\", \"doo\" ], \"testHVALS\");\n });\n}\n\nfunction testHLEN() {\n client.hlen(\"foo\", expectNumber(0, \"testHLEN\"));\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHLEN\"));\n client.hlen(\"foo\", expectNumber(1, \"testHLEN\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHLEN\"));\n client.hlen(\"foo\", expectNumber(2, \"testHLEN\"));\n}\n\nfunction testHSET() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHSET\"));\n client.hget(\"foo\", \"bar\", function (err, reply) {\n if (err) assert.fail(err, \"testHSET\");\n checkEqual(\"baz\", reply, \"testHSET\");\n });\n}\n\n// Note that the user of this client should add a listener for \"connect\" via\n// client.stream.addListener(\"connect\", function () { ... }); in order to\n// subscribe to channels/classes of interest after each connection is established\n// (subscriptions are not remembered across connections and reconnections).\n\n// We need a 2nd client to act as publisher in order to test that a message\n// is received after SUBSCRIBE[ing] to a channel/class. We can at least test\n// that SUBSCRIBE itself does not fail (it shouldn't).\n\nfunction testSUBSCRIBE() {\n client.subscribe(\"#redis\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"subscribe\", \"#redis\", \"1\" ], \"testSUBSCRIBE\");\n });\n\n client.subscribe(\"#Node.js\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"subscribe\", \"#Node.js\", \"2\" ], \"testSUBSCRIBE\");\n });\n\n client.unsubscribe(\"#redis\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"unsubscribe\", \"#redis\", \"1\" ], \"testSUBSCRIBE\");\n });\n\n client.unsubscribe(\"#Node.js\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"unsubscribe\", \"#Node.js\", \"0\" ], \"testSUBSCRIBE\");\n });\n}\n\nfunction testUNSUBSCRIBE() {\n printDisclaimer();\n}\n\nfunction testPSUBSCRIBE() {\n client.psubscribe(\"cooking.*\", function (err, reply) {\n if (err) assert.fail(err, \"testPSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"psubscribe\", \"cooking.*\", \"1\" ], \"testPSUBSCRIBE\");\n });\n\n client.punsubscribe(\"cooking.*\", function (err, reply) {\n if (err) assert.fail(err, \"testPSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"punsubscribe\", \"cooking.*\", \"0\" ], \"testPSUBSCRIBE\");\n });\n}\n\nfunction testPUNSUBSCRIBE() {\n printDisclaimer();\n}\n\nfunction testPUBLISH() {\n // No one is subscribed so 0\n\n client.publish(\"#redis\", \"Hello, world!\", expectNumber(0, \"testPUBLISH\"));\n}\n\nvar messageWasReceived = false;\n\nfunction testSUBSCRIBEandPUBLISH() {\n var messagePayload = \"I'm a lumberjack!\";\n var channelName = \"Monty\"; \n\n client.subscribeTo(channelName, function (channel, message) {\n checkEqual(channel, channelName, \"testSUBSCRIBEandPUBLISH a0\");\n checkEqual(message, messagePayload, \"testSUBSCRIBEandPUBLISH a1\");\n messageWasReceived = true;\n }); \n\n // Create a 2nd client that publishes a message.\n\n var publisher = redisclient.createClient();\n publisher.stream.addListener(\"connect\", function () {\n publisher.publish(channelName, messagePayload, function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBEandPUBLISH b0\");\n expectNumber(1, \"testSUBSCRIBEandPUBLISH b1\");\n });\n });\n}\n\n// We cannot test the blocking behavior of BLPOP and BRPOP from a single client\n// without using a timeout. That being said, we can test the non-blocking\n// behavior by ensuring there's an element in a list that we try to pop from.\n\nfunction testBLPOP() {\n var timeout = 1;\n\n // Non-blocking against a single key.\n\n client.lpush('list0', 'ABC', expectNumber(1, \"testBLPOP 1\"));\n client.blpop('list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBLPOP 2\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"ABC\" ], \"testBLPOP 3\");\n });\n\n // Non-blocking against multiple keys.\n // Returns the first one that has something in it.\n\n client.lpush('list0', 'ABC', expectNumber(1, \"testBLPOP 4\"));\n client.blpop('list1', 'list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBLPOP 5\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"ABC\" ], \"testBLPOP 6\");\n });\n\n // Non-blocking against a single key that does not exist.\n // This should timeout after 1 second and return a null reply.\n\n client.blpop('listX', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBLPOP 7\");\n checkEqual(reply, null, \"testBLPOP 8\");\n });\n}\n\nfunction testBRPOP() {\n var timeout = 1;\n\n // Non-blocking against a single key.\n\n client.lpush('list0', 'ABC', expectNumber(1, \"testBRPOP\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testBRPOP\"));\n client.brpop('list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBRPOP\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"ABC\" ], \"testBRPOP\");\n });\n\n // Non-blocking against multiple keys.\n // Returns the first one that has something in it.\n\n client.lpush('list0', 'ABC', expectNumber(2, \"testBRPOP\"));\n client.brpop('list1', 'list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBRPOP\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"DEF\" ], \"testBRPOP\");\n });\n\n // Non-blocking against a single key that does not exist.\n // This should timeout after 1 second and return a null reply.\n\n client.brpop('listX', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBRPOP\");\n checkEqual(reply, null, \"testBRPOP\");\n });\n}\n\nvar allTestFunctions = [\n testAUTH,\n testBGSAVE,\n testBLPOP,\n testBRPOP,\n testDBSIZE,\n testDECR,\n testDECRBY,\n testDEL,\n testEXISTS,\n testEXPIRE,\n testFLUSHALL,\n testFLUSHDB,\n testGET,\n testGETSET,\n testHDEL, \n testHEXISTS,\n testHGET,\n testHGETALL,\n testHINCRBY,\n testHKEYS,\n testHLEN,\n testHSET,\n testHVALS,\n testINCR,\n testINCRBY,\n testINFO,\n testKEYS,\n testLASTSAVE,\n testLINDEX,\n testLLEN,\n testLPOP,\n testLPUSH,\n testLRANGE,\n testLREM,\n testLSET,\n testLTRIM,\n testMGET,\n testMOVE,\n testMSET,\n testMSETNX,\n testParseBulkReply,\n testParseErrorReply,\n testParseInlineReply,\n testParseIntegerReply,\n testParseMultiBulkReply,\n testPSUBSCRIBE,\n testPUBLISH,\n testPUNSUBSCRIBE,\n testRANDOMKEY,\n testRENAME,\n testRENAMENX,\n testRPOP,\n testRPOPLPUSH,\n testRPUSH,\n testSADD,\n testSAVE,\n testSCARD,\n testSDIFF,\n testSDIFFSTORE,\n testSELECT,\n testSET,\n testSETANDGETMULTIBYTE,\n testSETNX,\n testSHUTDOWN,\n testSINTER,\n testSINTERSTORE,\n testSISMEMBER,\n testSMEMBERS,\n testSMOVE,\n testSORT,\n testSPOP,\n testSREM,\n testSUBSCRIBE,\n testSUNION,\n testSUNIONSTORE,\n testTTL,\n testTYPE,\n testUNSUBSCRIBE,\n testZADD,\n testZCARD,\n testZCOUNT,\n testZINCRBY,\n testZINTER,\n testZRANGE,\n testZRANGEBYSCORE,\n testZRANK,\n testZREM,\n testZREMRANGEBYRANK,\n testZREMRANGEBYSCORE,\n testZREVRANGE,\n testZREVRANK,\n testZSCORE,\n testZUNION,\n];\n\nfunction checkIfDone() {\n if (client.originalCommands.length == 0) {\n testSUBSCRIBEandPUBLISH();\n \n var checks = 0;\n setInterval(function () {\n if (messageWasReceived) {\n sys.error(\"\\n\");\n log(\"info\", \"All tests have passed.\");\n process.exit(0);\n } else {\n assert.notEqual(++checks, 5, \"testSUBSCRIBEandPUBLISH never received message\");\n } \n }, 100);\n } else {\n if (verbose)\n log('info', client.originalCommands.length + \" replies still pending...\");\n else if (!quiet)\n sys.print(\"+\");\n }\n}\n\nfunction runAllTests() {\n allTestFunctions.forEach(function (testFunction) {\n if (verbose) {\n sys.error(\"\");\n log(\"info\", \"Testing \" + testFunction.name.replace(/^test/, ''));\n sys.error(\"=========================================\");\n } else if (!quiet) {\n sys.print(\".\");\n }\n\n clearTestDatabasesBeforeEachTest();\n testFunction();\n });\n\n setInterval(checkIfDone, 1500);\n setTimeout(function() {\n log(\"error\", \"Tests timed out\");\n process.exit(1);\n }, MAX_TEST_TIME);\n}\n\nvar connectionFailed = false;\nvar client = redisclient.createClient();\nclient.stream.addListener(\"connect\", runAllTests);\nclient.stream.addListener(\"close\", function (inError) {\n connectionFailed = inError;\n if (inError)\n throw new Error(\"Connection to Redis failed. Not attempting reconnection.\");\n});\n\nfunction debugFilter(what) {\n var filtered = what;\n\n filtered = filtered.replace(/\\r\\n/g, '<CRLF>');\n filtered = filtered.replace(/\\r/g, '<CR>');\n filtered = filtered.replace(/\\n/g, '<LF>');\n\n return filtered;\n}\n\nfunction printDisclaimer() {\n if (redisclient.debugMode) \n sys.debug(\"This test does not do anything\");\n}\n\n" == "#!/usr/bin/env node\n\n/*\n Redis client for Node.js -- tests\n\n Copyright (C) 2010 Fictorial LLC.\n\n Permission is hereby granted, free of charge, to any person obtaining\n a copy of this software and associated documentation files (the\n \"Software\"), to deal in the Software without restriction, including without\n limitation the rights to use, copy, modify, merge, publish, distribute,\n sublicense, and/or sell copies of the Software, and to permit persons to\n whom the Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n DEALINGS IN THE SOFTWARE.\n*/\n\n// http://github.com/fictorial/redis-node-client\n// Brian Hammond <brian at fictorial dot com>\n\n// NOTE: this test suite uses databases 14 and 15 for test purposes! \n// Make sure your Redis instance has at least this many databases; the default has 16.\n// These databases will be flushed these databases at the start of each test run. \n// If you want to use a different database number, update TEST_DB_NUMBER* below.\n\n// NOTE: each test is responsible for configuring the dataset needed to \n// run that test. There are no \"fixtures\" or similar.\n\nvar TEST_DB_NUMBER = 15,\n TEST_DB_NUMBER_FOR_MOVE = 14;\n\nvar MAX_TEST_TIME = 20000;\n\nvar sys = require(\"sys\"),\n assert = require(\"assert\"),\n redisclient = require(\"../lib/redis-client\"),\n fs = require(\"fs\"),\n Buffer = require(\"buffer\").Buffer;\n\nvar verbose = process.argv.indexOf(\"-v\") != -1;\nvar quiet = process.argv.indexOf(\"-q\") != -1;\n\nredisclient.debugMode = verbose && !quiet;\n\nfunction log(level, msg) {\n var colorsForLevel = { info:37, warn:33, error:31 };\n sys.error(\"\\033[\" + colorsForLevel[level || 'info'] + \"m[\" + \n level.toUpperCase() + \"] \" + msg + \"\\033[0m\");\n}\n\nfunction showContext(context) {\n sys.error(\"\\n\");\n log('error', context + \" FAILED!\");\n sys.error(\"\");\n}\n\n// These wrappers around the assert module exist because we generate functions\n// to test for expected conditions which lose context, and assert's functions\n// use the 'message' in place of the failed condition.\n\nfunction checkEqual(actual, expected, context) {\n try {\n assert.equal(actual, expected);\n } catch (e) {\n showContext(context);\n throw e;\n }\n}\n\nfunction check(what, context) {\n try {\n assert.ok(what);\n } catch (e) {\n showContext(context);\n throw e;\n }\n}\n\nfunction checkDeepEqual(actual, expected, context) {\n try {\n assert.deepEqual(actual, expected);\n } catch (e) {\n showContext(context);\n throw e;\n }\n}\n\n// Redis' protocol returns +OK for some operations to mean \"true\" or \"success\".\n// The client converts this into a boolean with value true.\n\nfunction expectOK(context) {\n return function (err, truthiness) {\n if (err) assert.fail(err, context);\n checkEqual(typeof(truthiness), 'boolean', context);\n checkEqual(truthiness, true, context);\n };\n}\n\nfunction maybeAsNumber(str) {\n var value = parseInt(str, 10);\n\n if (isNaN(value)) \n value = parseFloat(str);\n\n if (isNaN(value)) \n return str;\n\n return value;\n}\n\nfunction expectNumber(expectedValue, context) {\n return function (err, reply) {\n if (err) assert.fail(err, context);\n var value = maybeAsNumber(reply);\n checkEqual(value, expectedValue, context);\n };\n}\n\nfunction clearTestDatabasesBeforeEachTest() {\n client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK(\"select\"));\n client.flushdb(expectOK(\"flushdb\"));\n\n client.select(TEST_DB_NUMBER, expectOK(\"select\"));\n client.flushdb(expectOK(\"flushdb\"));\n}\n\nfunction bufferFromString(str, encoding) {\n var enc = encoding || 'utf8';\n var buf = new Buffer(str.length);\n switch (enc) {\n case 'utf8': buf.utf8Write(str); break;\n case 'ascii': buf.asciiWrite(str); break;\n case 'binary': buf.binaryWrite(str); break;\n default: \n assert.fail(\"unknown encoding: \" + encoding);\n }\n return buf;\n}\n\nfunction testParseBulkReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.BULK, \"testParseBulkReply a-0\");\n check(reply.value instanceof Buffer, \"testParseBulkReply a-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), \"FOOBAR\", \"testParseBulkReply a-2\");\n });\n a.feed(bufferFromString(\"$6\\r\\nFOOBAR\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.BULK, \"testParseBulkReply b-0\");\n checkEqual(reply.value, null, \"testParseBulkReply b-1\");\n });\n b.feed(bufferFromString(\"$-1\\r\\n\"));\n}\n\nBuffer.prototype.toString=function() {\n return this.utf8Slice(0,this.length);\n}\n\nfunction testParseMultiBulkReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply a-0\");\n check(reply.value instanceof Array, \"testParseMultiBulkReply a-1\");\n checkEqual(reply.value.length, 4, \"testParseMultiBulkReply a-2\");\n check(reply.value[0].type === redisclient.BULK, \"testParseMultiBulkReply a-3\");\n check(reply.value[1].type === redisclient.BULK, \"testParseMultiBulkReply a-4\");\n check(reply.value[2].type === redisclient.BULK, \"testParseMultiBulkReply a-5\");\n check(reply.value[3].type === redisclient.BULK, \"testParseMultiBulkReply a-6\");\n check(reply.value[0].value instanceof Buffer, \"testParseMultiBulkReply a-7\");\n check(reply.value[1].value instanceof Buffer, \"testParseMultiBulkReply a-8\");\n check(reply.value[2].value instanceof Buffer, \"testParseMultiBulkReply a-9\");\n check(reply.value[3].value instanceof Buffer, \"testParseMultiBulkReply a-10\");\n checkEqual(reply.value[0].value.length, 3, \"testParseMultiBulkReply a-11\");\n checkEqual(reply.value[1].value.length, 3, \"testParseMultiBulkReply a-12\");\n checkEqual(reply.value[2].value.length, 5, \"testParseMultiBulkReply a-13\");\n checkEqual(reply.value[3].value.length, 6, \"testParseMultiBulkReply a-14\");\n checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', \"testParseMultiBulkReply a-15\");\n checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), 'BAR', \"testParseMultiBulkReply a-16\");\n checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'HELLO', \"testParseMultiBulkReply a-17\");\n checkEqual(reply.value[3].value.utf8Slice(0, reply.value[3].value.length), 'WORLD!', \"testParseMultiBulkReply a-18\");\n });\n a.feed(bufferFromString(\"*4\\r\\n$3\\r\\nFOO\\r\\n$3\\r\\nBAR\\r\\n$5\\r\\nHELLO\\r\\n$6\\r\\nWORLD!\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply b-0\");\n checkEqual(reply.value, null, \"testParseMultiBulkReply b-1\");\n });\n b.feed(bufferFromString(\"*-1\\r\\n\"));\n\n var c = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply c-0\");\n check(reply.value instanceof Array, \"testParseMultiBulkReply c-1\");\n checkEqual(reply.value.length, 3, \"testParseMultiBulkReply c-2\");\n check(reply.value[0].type === redisclient.BULK, \"testParseMultiBulkReply c-3\");\n check(reply.value[1].type === redisclient.BULK, \"testParseMultiBulkReply c-4\");\n check(reply.value[2].type === redisclient.BULK, \"testParseMultiBulkReply c-5\");\n checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'FOO', \"testParseMultiBulkReply c-6\");\n checkEqual(reply.value[1].value, null, \"testParseMultiBulkReply c-7\");\n checkEqual(reply.value[2].value.utf8Slice(0, reply.value[2].value.length), 'BARZ', \"testParseMultiBulkReply c-8\");\n });\n c.feed(bufferFromString(\"*3\\r\\n$3\\r\\nFOO\\r\\n$-1\\r\\n$4\\r\\nBARZ\\r\\n\"));\n\n // Test with a multi-bulk reply containing a subreply that's non-bulk\n // but an inline/integer reply instead.\n\n var d = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply d-0\");\n check(reply.value instanceof Array, \"testParseMultiBulkReply d-1\");\n checkEqual(reply.value.length, 3, \"testParseMultiBulkReply d-2\");\n check(reply.value[0].type === redisclient.BULK, \"testParseMultiBulkReply d-3\");\n check(reply.value[1].type === redisclient.BULK, \"testParseMultiBulkReply d-4\");\n check(reply.value[2].type === redisclient.INTEGER, \"testParseMultiBulkReply d-5\");\n check(reply.value[0].value instanceof Buffer, \"testParseMultiBulkReply d-6\");\n check(reply.value[1].value instanceof Buffer, \"testParseMultiBulkReply d-7\");\n checkEqual(typeof(reply.value[2].value), \"number\", \"testParseMultiBulkReply d-8\");\n checkEqual(reply.value[0].value.utf8Slice(0, reply.value[0].value.length), 'subscribe', \"testParseMultiBulkReply d-9\");\n checkEqual(reply.value[1].value.utf8Slice(0, reply.value[1].value.length), '#redis', \"testParseMultiBulkReply d-10\");\n checkEqual(reply.value[2].value, 1, \"testParseMultiBulkReply d-11\");\n });\n d.feed(bufferFromString(\"*3\\r\\n$9\\r\\nsubscribe\\r\\n$6\\r\\n#redis\\r\\n:1\\r\\n*3\\r\\n$7\\r\\nmessage\\r\\n\"));\n\n var e = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.MULTIBULK, \"testParseMultiBulkReply e-0\");\n checkEqual(reply.value, null, \"testParseMultiBulkReply e-1\");\n });\n e.feed(bufferFromString(\"*0\\r\\n\"));\n}\n\nfunction testParseInlineReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n // maybeConvertReplyValue is called by redisclient for non-test calls\n reply.value = redisclient.maybeConvertReplyValue_('N/A', reply); \n checkEqual(reply.type, redisclient.INLINE, \"testParseInlineReply a-0\");\n checkEqual(typeof(reply.value), 'boolean', \"testParseInlineReply a-1\");\n checkEqual(reply.value, true, \"testParseInlineReply a-2\");\n });\n a.feed(bufferFromString(\"+OK\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.INLINE, \"testParseInlineReply b-0\");\n check(reply.value instanceof Buffer, \"testParseInlineReply b-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), 'WHATEVER', \"testParseInlineReply b-2\");\n });\n b.feed(bufferFromString(\"+WHATEVER\\r\\n\"));\n}\n\nfunction testParseIntegerReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.INTEGER, \"testParseIntegerReply a-0\");\n checkEqual(typeof(reply.value), 'number', \"testParseIntegerReply a-1\");\n checkEqual(reply.value, -1, \"testParseIntegerReply a-2\");\n });\n a.feed(bufferFromString(\":-1\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.INTEGER, \"testParseIntegerReply b-0\");\n checkEqual(typeof(reply.value), 'number', \"testParseIntegerReply b-1\");\n checkEqual(reply.value, 1000, \"testParseIntegerReply b-2\");\n });\n b.feed(bufferFromString(\":1000\\r\\n\"));\n}\n\nfunction testParseErrorReply() {\n var a = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.ERROR, \"testParseErrorReply c-0\");\n check(reply.value instanceof Buffer, \"testParseErrorReply c-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), \"ERR solar flare\", \"testParseErrorReply c-2\");\n });\n a.feed(bufferFromString(\"-ERR solar flare\\r\\n\"));\n\n var b = new redisclient.ReplyParser(function (reply) {\n checkEqual(reply.type, redisclient.ERROR, \"testParseErrorReply b-0\");\n check(reply.value instanceof Buffer, \"testParseErrorReply b-1\");\n checkEqual(reply.value.utf8Slice(0, reply.value.length), \"hiccup\", \"testParseErrorReply b-2\");\n });\n b.feed(bufferFromString(\"-hiccup\\r\\n\"));\n}\n\nfunction testAUTH() {\n // You need to configure redis to enable auth.\n // This unit test suite assumes the auth feature is off/disabled.\n // Auth *would be* the first command required after connecting.\n\n printDisclaimer();\n}\n\nfunction testSELECT() {\n printDisclaimer();\n}\n\nfunction testFLUSHDB() {\n // no-op; tested in testSelect\n\n printDisclaimer();\n}\n\nfunction testSET() {\n client.set('foo', 'bar', expectOK(\"testSET\"));\n client.set('baz', 'buz', expectOK(\"testSET\"));\n client.set('ggg', '123', expectOK(\"testSET\"));\n}\n\nfunction testSETNX() {\n client.set('foo', 'bar', expectOK(\"testSETNX\"));\n client.setnx('foo', 'quux', expectNumber(0, \"testSETNX\")); // fails when already set\n client.setnx('boo', 'apple', expectNumber(1, \"testSETNX\")); // no such key already so OK\n}\n\nfunction testGET() {\n client.set('foo', 'bar', expectOK(\"testGET\"));\n client.set('baz', 'buz', expectOK(\"testGET\"));\n\n client.get('foo', function (err, value) {\n if (err) assert.fail(err, \"testGET\");\n checkEqual(value, 'bar', \"testGET\");\n });\n\n client.get('baz', function (err, value) {\n if (err) assert.fail(err, \"testGET\");\n checkEqual(value, 'buz', \"testGET\");\n });\n\n // Check buffer resizing of input buffer\n // by loading really large data and reading\n // it back. We use ourselves\n var large = fs.readFileSync(__filename);\n client.set('largetestfile', large);\n\n client.get('largetestfile', function(err, value) {\n if (err) assert.fail(err, \"testGET\");\n checkEqual(value.utf8Slice(0,value.length), large, \"testGET\");\n });\n}\n\nfunction testMGET() {\n client.set('foo', 'bar', expectOK(\"testMGET\"));\n client.set('baz', 'buz', expectOK(\"testMGET\"));\n\n client.mget('foo', 'baz', function (err, values) {\n if (err) assert.fail(err, \"testMGET\");\n checkEqual(values[0], 'bar', \"testMGET\");\n checkEqual(values[1], 'buz', \"testMGET\");\n });\n}\n\nfunction testGETSET() {\n client.set('getsetfoo', 'getsetbar', expectOK(\"testGETSET 0\"));\n\n client.getset('getsetfoo', 'fuzz', function (err, previousValue) {\n if (err) assert.fail(err, \"testGETSET 1\");\n checkEqual(previousValue, 'getsetbar', \"testGETSET 2\");\n });\n\n client.get('getsetfoo', function (err, value) {\n if (err) assert.fail(err, \"testGETSET 3\");\n checkEqual(value, 'fuzz', \"testGETSET 4\");\n });\n}\n\nfunction testSETANDGETMULTIBYTE() {\n var testValue = '\\u00F6\\u65E5\\u672C\\u8A9E'; // \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n var buffer = new Buffer(32);\n var size = buffer.utf8Write(testValue,0);\n client.set('testUtf8Key', buffer.slice(0,size), expectOK(\"testSETANDGETMULTIBYTE\"))\n\n client.get('testUtf8Key', function (err, value) {\n if (err) assert.fail(err, \"testSETANDGETMULTIBYTE\");\n checkEqual(value.utf8Slice(0, value.length), testValue, \"testSETANDGETMULTIBYTE\");\n });\n}\n\nfunction testINFO() {\n client.info(function (err, info) {\n check(info instanceof Object, \"testINFO\");\n check(info.hasOwnProperty('redis_version'), \"testINFO\");\n check(info.hasOwnProperty('connected_clients'), \"testINFO\");\n check(info.hasOwnProperty('uptime_in_seconds'), \"testINFO\");\n checkEqual(typeof(info.uptime_in_seconds), 'string', \"testINFO\");\n checkEqual(typeof(info.connected_clients), 'string', \"testINFO\");\n });\n}\n\nfunction testINCR() {\n client.incr('counter', expectNumber(1, \"testINCR\"))\n client.incr('counter', expectNumber(2, \"testINCR\"))\n}\n\nfunction testINCRBY() {\n client.incrby('counter', 2, expectNumber(2, \"testINCRBY\"))\n client.incrby('counter', -1, expectNumber(1, \"testINCRBY\"))\n}\n\nfunction testDECR() {\n client.decr('counter', expectNumber(-1, \"testDECR\"))\n client.decr('counter', expectNumber(-2, \"testDECR\"))\n}\n\nfunction testDECRBY() {\n client.decrby('counter', '1', expectNumber(-1, \"testDECRBY\"))\n client.decrby('counter', '2', expectNumber(-3, \"testDECRBY\"))\n client.decrby('counter', '-3', expectNumber(0, \"testDECRBY\"))\n}\n\nfunction testEXISTS() {\n client.set('foo', 'bar', expectOK(\"testEXISTS\"));\n client.exists('foo', expectNumber(1, \"testEXISTS\"))\n client.exists('foo2', expectNumber(0, \"testEXISTS\"))\n}\n\nfunction testDEL() {\n client.set('goo', 'bar', expectOK(\"testDEL\"));\n client.del('goo', expectNumber(1, \"testDEL\"));\n client.exists('goo', expectNumber(0, \"testDEL\"));\n client.del('goo', expectNumber(0, \"testDEL\"));\n}\n\nfunction testKEYS() {\n client.set('foo1', 'foo1Value', expectOK(\"testKEYS\"))\n client.set('foo2', 'foo2Value', expectOK(\"testKEYS\"))\n\n client.keys('foo*', function (err, keys) {\n if (err) assert.fail(err, \"testKEYS\");\n checkEqual(keys.length, 2, \"testKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(keys);\n checkDeepEqual(keys.sort(), ['foo1', 'foo2'], \"testKEYS\");\n });\n\n client.set('baz', 'bazValue', expectOK(\"testKEYS\"))\n client.set('boo', 'booValue', expectOK(\"testKEYS\"))\n\n // At this point we have foo1, foo2, baz, boo\n\n client.keys('*', function (err, keys) {\n if (err) assert.fail(err, \"testKEYS\");\n checkEqual(keys.length, 4, \"testKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(keys);\n checkDeepEqual(keys.sort(), ['baz', 'boo', 'foo1', 'foo2'], \"testKEYS\");\n });\n\n client.keys('?oo', function (err, keys) {\n if (err) assert.fail(err, \"testKEYS\");\n checkEqual(keys.length, 1, \"testKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(keys);\n checkDeepEqual(keys.sort(), ['boo'], \"testKEYS\");\n });\n}\n\nfunction testRANDOMKEY() {\n client.set('foo', 'bar', expectOK(\"testRANDOMKEY\"));\n client.set('baz', 'buz', expectOK(\"testRANDOMKEY\"));\n\n client.randomkey(function (err, someKey) {\n if (err) assert.fail(err, \"testRANDOMKEY\");\n check(/^(foo|baz)$/.test(someKey), \"testRANDOMKEY\");\n });\n}\n\nfunction testRENAME() {\n client.set('foo', 'bar', expectOK(\"testRENAME\"));\n client.rename('foo', 'zoo', expectOK(\"testRENAME\"));\n client.exists('foo', expectNumber(0, \"testRENAME\"));\n client.exists('zoo', expectNumber(1, \"testRENAME\"));\n}\n\nfunction testRENAMENX() {\n client.set('roo', 'bar', expectOK(\"testRENAMENX\"));\n client.set('bar', 'baz', expectOK(\"testRENAMENX\"));\n client.renamenx('roo', 'bar', expectNumber(0, \"testRENAMENX\")); // bar already exists\n client.exists('roo', expectNumber(1, \"testRENAMENX\")); // was not renamed\n client.exists('bar', expectNumber(1, \"testRENAMENX\")); // was not touched\n client.renamenx('roo', 'too', expectNumber(1, \"testRENAMENX\")); // too did not exist... OK\n client.exists('roo', expectNumber(0, \"testRENAMENX\")); // was renamed\n client.exists('too', expectNumber(1, \"testRENAMENX\")); // was created\n}\n\nfunction testDBSIZE() {\n client.set('foo', 'bar', expectOK(\"testDBSIZE\"));\n client.set('bar', 'baz', expectOK(\"testDBSIZE\"));\n\n client.dbsize(function (err, value) {\n if (err) assert.fail(err, \"testDBSIZE\");\n checkEqual(value, 2, \"testDBSIZE\");\n });\n}\n\nfunction testEXPIRE() {\n // set 'expfoo' to expire in 2 seconds\n\n client.set('expfoo', 'bar', expectOK(\"testEXPIRE\"));\n client.expire('expfoo', 2, expectNumber(1, \"testEXPIRE\"));\n\n // subsequent expirations cannot be set.\n\n client.expire('expfoo', 2, expectNumber(0, \"testEXPIRE\"));\n\n setTimeout(function () {\n client.exists('expfoo', expectNumber(0, \"testEXPIRE\"));\n }, 2500);\n}\n\nfunction testTTL() {\n client.set('ttlfoo', 'bar', expectOK(\"testTTL\"));\n\n // ttlfoo is not set to expire\n\n client.ttl('ttlfoo', function (err, value) {\n if (err) assert.fail(err, \"testTTL\");\n checkEqual(value, -1, \"testTTL\");\n });\n\n client.set('ttlbar', 'baz', expectOK(\"testTTL\"));\n client.expire('ttlbar', 3, expectNumber(1, \"testTTL\"));\n\n client.ttl('ttlbar', function (err, value) {\n if (err) assert.fail(err, \"testTTL\");\n check(value > 0, \"testTTL\");\n });\n}\n\nfunction testRPUSH() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testRPUSH\"));\n client.exists('list0', expectNumber(1, \"testRPUSH\"));\n}\n\nfunction testLPUSH() {\n client.exists('list1', expectNumber(0, \"testLPUSH\"));\n client.lpush('list1', 'list1value0', expectNumber(1, \"testLPUSH\"));\n client.exists('list1', expectNumber(1, \"testLPUSH\"));\n}\n\nfunction testLLEN() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLLEN\"));\n client.llen('list0', expectNumber(1, \"testLLEN\"));\n\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLLEN\"));\n client.llen('list0', expectNumber(2, \"testLLEN\"));\n}\n\nfunction testLRANGE() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLRANGE\"));\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLRANGE\"));\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLRANGE\");\n checkEqual(values.length, 2, \"testLRANGE\");\n checkEqual(values[0], 'list0value0', \"testLRANGE\");\n checkEqual(values[1], 'list0value1', \"testLRANGE\");\n });\n\n client.lrange('list0', 0, 0, function (err, values) {\n if (err) assert.fail(err, \"testLRANGE\");\n checkEqual(values.length, 1, \"testLRANGE\");\n checkEqual(values[0], 'list0value0', \"testLRANGE\");\n });\n\n client.lrange('list0', -1, -1, function (err, values) {\n if (err) assert.fail(err, \"testLRANGE\");\n checkEqual(values.length, 1, \"testLRANGE\");\n checkEqual(values[0], 'list0value1', \"testLRANGE\");\n });\n}\n\nfunction testLTRIM() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLTRIM\"));\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLTRIM\"));\n client.rpush('list0', 'list0value2', expectNumber(3, \"testLTRIM\"));\n\n client.llen('list0', function (err, len) {\n if (err) assert.fail(err, \"testLTRIM\");\n checkEqual(len, 3, \"testLTRIM\");\n });\n\n client.ltrim('list0', 0, 1, expectOK(\"testLTRIM\"))\n\n client.llen('list0', function (err, len) {\n if (err) assert.fail(err, \"testLTRIM\");\n checkEqual(len, 2, \"testLTRIM\");\n });\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLTRIM\");\n checkEqual(values.length, 2, \"testLTRIM\");\n checkEqual(values[0], 'list0value0', \"testLTRIM\");\n checkEqual(values[1], 'list0value1', \"testLTRIM\");\n });\n}\n\nfunction testLINDEX() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLINDEX\"));\n client.rpush('list0', 'list0value1', expectNumber(2, \"testLINDEX\"));\n\n client.lindex('list0', 0, function (err, value) {\n if (err) assert.fail(err, \"testLINDEX\");\n checkEqual(value, 'list0value0', \"testLINDEX\");\n });\n\n client.lindex('list0', 1, function (err, value) {\n if (err) assert.fail(err, \"testLINDEX\");\n checkEqual(value, 'list0value1', \"testLINDEX\");\n });\n\n // out of range => null\n\n client.lindex('list0', 2, function (err, value) {\n if (err) assert.fail(err, \"testLINDEX\");\n checkEqual(value, null, \"testLINDEX\");\n });\n}\n\nfunction testLSET() {\n client.rpush('list0', 'list0value0', expectNumber(1, \"testLSET\"));\n client.lset('list0', 0, 'LIST0VALUE0', expectOK(\"testLSET\"));\n\n client.lrange('list0', 0, 0, function (err, values) {\n if (err) assert.fail(err, \"testLSET\");\n checkEqual(values.length, 1, \"testLSET\");\n checkEqual(values[0], 'LIST0VALUE0', \"testLSET\");\n });\n}\n\nfunction testLREM() {\n client.lpush('list0', 'ABC', expectNumber(1, \"testLREM\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testLREM\"));\n client.lpush('list0', 'ABC', expectNumber(3, \"testLREM\"));\n\n client.lrem('list0', 1, 'ABC', expectNumber(1, \"testLREM\"));\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLREM\");\n checkEqual(values.length, 2, \"testLREM\");\n checkEqual(values[0], 'DEF', \"testLREM\");\n checkEqual(values[1], 'ABC', \"testLREM\");\n });\n}\n\nfunction testLPOP() {\n client.lpush('list0', 'ABC', expectNumber(1, \"testLPOP\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testLPOP\"));\n client.lpush('list0', 'GHI', expectNumber(3, \"testLPOP\"));\n\n client.lpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testLPOP\");\n checkEqual(value, 'GHI', \"testLPOP\");\n });\n\n client.lpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testLPOP\");\n checkEqual(value, 'DEF', \"testLPOP\");\n });\n\n client.lrange('list0', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testLPOP\");\n checkEqual(values.length, 1, \"testLPOP\");\n checkEqual(values[0], 'ABC', \"testLPOP\");\n });\n}\n\nfunction testRPOP() {\n client.lpush('list0', 'ABC', expectNumber(1, \"testRPOP\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testRPOP\"));\n\n client.rpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testRPOP\");\n checkEqual(value, 'ABC', \"testRPOP\");\n });\n\n client.rpop('list0', function (err, value) {\n if (err) assert.fail(err, \"testRPOP\");\n checkEqual(value, 'DEF', \"testRPOP\");\n });\n\n client.llen('list0', function (err, len) {\n if (err) assert.fail(err, \"testRPOP\");\n checkEqual(len, 0, \"testRPOP\");\n });\n}\n\nfunction testRPOPLPUSH() {\n client.rpush('src', 'ABC', expectNumber(1, \"testRPOPLPUSH\"));\n client.rpush('src', 'DEF', expectNumber(2, \"testRPOPLPUSH\"));\n\n client.rpoplpush('src', 'dst', function (err, value) {\n if (err) assert.fail(err, \"testRPOPLPUSH\");\n checkEqual(value, 'DEF', \"testRPOPLPUSH\");\n });\n\n client.lrange('src', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testRPOPLPUSH\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(values);\n checkDeepEqual(values, [ 'ABC' ], \"testRPOPLPUSH\");\n });\n\n client.lrange('dst', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testRPOPLPUSH\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(values);\n checkDeepEqual(values, [ 'DEF' ], \"testRPOPLPUSH\");\n });\n}\n\nfunction testSADD() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSADD\"));\n client.sadd('set0', 'member0', expectNumber(0, \"testSADD\")); // already member\n}\n\nfunction testSISMEMBER() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSISMEMBER\"));\n client.sismember('set0', 'member0', expectNumber(1, \"testSISMEMBER\"));\n client.sismember('set0', 'member1', expectNumber(0, \"testSISMEMBER\"));\n}\n\nfunction testSCARD() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSCARD\"));\n client.scard('set0', expectNumber(1, \"testSCARD\"));\n\n client.sadd('set0', 'member1', expectNumber(1, \"testSCARD\"));\n client.scard('set0', expectNumber(2, \"testSCARD\"));\n}\n\nfunction testSREM() {\n client.sadd('set0', 'member0', expectNumber(1, \"testSREM\"));\n client.srem('set0', 'foobar', expectNumber(0, \"testSREM\"))\n client.srem('set0', 'member0', expectNumber(1, \"testSREM\"))\n client.scard('set0', expectNumber(0, \"testSREM\"));\n}\n\nfunction testSPOP() {\n client.sadd('zzz', 'member0', expectNumber(1, \"testSPOP\"));\n client.scard('zzz', expectNumber(1, \"testSPOP\"));\n\n client.spop('zzz', function (err, value) {\n if (err) assert.fail(err, \"testSPOP\");\n checkEqual(value, 'member0', \"testSPOP\");\n });\n\n client.scard('zzz', expectNumber(0, \"testSPOP\"));\n}\n\nfunction testSDIFF() {\n client.sadd('foo', 'x', expectNumber(1, \"testSDIFF\"));\n client.sadd('foo', 'a', expectNumber(1, \"testSDIFF\"));\n client.sadd('foo', 'b', expectNumber(1, \"testSDIFF\"));\n client.sadd('foo', 'c', expectNumber(1, \"testSDIFF\"));\n\n client.sadd('bar', 'c', expectNumber(1, \"testSDIFF\"));\n\n client.sadd('baz', 'a', expectNumber(1, \"testSDIFF\"));\n client.sadd('baz', 'd', expectNumber(1, \"testSDIFF\"));\n\n client.sdiff('foo', 'bar', 'baz', function (err, values) {\n if (err) assert.fail(err, \"testSDIFF\");\n values.sort();\n checkEqual(values.length, 2, \"testSDIFF\");\n checkEqual(values[0], 'b', \"testSDIFF\");\n checkEqual(values[1], 'x', \"testSDIFF\");\n });\n}\n\nfunction testSDIFFSTORE() {\n client.sadd('foo', 'x', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('foo', 'a', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('foo', 'b', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('foo', 'c', expectNumber(1, \"testSDIFFSTORE\"))\n\n client.sadd('bar', 'c', expectNumber(1, \"testSDIFFSTORE\"))\n\n client.sadd('baz', 'a', expectNumber(1, \"testSDIFFSTORE\"))\n client.sadd('baz', 'd', expectNumber(1, \"testSDIFFSTORE\"))\n\n // NB: SDIFFSTORE returns the number of elements in the dstkey \n\n client.sdiffstore('quux', 'foo', 'bar', 'baz', expectNumber(2, \"testSDIFFSTORE\"))\n\n client.smembers('quux', function (err, members) {\n if (err) assert.fail(err, \"testSDIFFSTORE\");\n members.sort();\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'b', 'x' ], \"testSDIFFSTORE\");\n });\n}\n\nfunction testSMEMBERS() {\n client.sadd('foo', 'x', expectNumber(1, \"testSMEMBERS\"));\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testSMEMBERS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'x' ], \"testSMEMBERS\");\n });\n\n client.sadd('foo', 'y', expectNumber(1, \"testSMEMBERS\"));\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testSMEMBERS\");\n checkEqual(members.length, 2, \"testSMEMBERS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members.sort(), [ 'x', 'y' ], \"testSMEMBERS\");\n });\n}\n\nfunction testSMOVE() {\n client.sadd('foo', 'x', expectNumber(1, \"testSMOVE\"));\n client.smove('foo', 'bar', 'x', expectNumber(1, \"testSMOVE\"));\n client.sismember('foo', 'x', expectNumber(0, \"testSMOVE\"));\n client.sismember('bar', 'x', expectNumber(1, \"testSMOVE\"));\n client.smove('foo', 'bar', 'x', expectNumber(0, \"testSMOVE\"));\n}\n\nfunction testSINTER() {\n client.sadd('sa', 'a', expectNumber(1, \"testSINTER\"));\n client.sadd('sa', 'b', expectNumber(1, \"testSINTER\"));\n client.sadd('sa', 'c', expectNumber(1, \"testSINTER\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testSINTER\"));\n client.sadd('sb', 'c', expectNumber(1, \"testSINTER\"));\n client.sadd('sb', 'd', expectNumber(1, \"testSINTER\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testSINTER\"));\n client.sadd('sc', 'd', expectNumber(1, \"testSINTER\"));\n client.sadd('sc', 'e', expectNumber(1, \"testSINTER\"));\n\n client.sinter('sa', 'sb', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 2, \"testSINTER\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);\n checkDeepEqual(intersection.sort(), [ 'b', 'c' ], \"testSINTER\");\n });\n\n client.sinter('sb', 'sc', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 2, \"testSINTER\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(intersection);\n checkDeepEqual(intersection.sort(), [ 'c', 'd' ], \"testSINTER\");\n });\n\n client.sinter('sa', 'sc', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 1, \"testSINTER\");\n checkEqual(intersection[0], 'c', \"testSINTER\");\n });\n\n // 3-way\n\n client.sinter('sa', 'sb', 'sc', function (err, intersection) {\n if (err) assert.fail(err, \"testSINTER\");\n checkEqual(intersection.length, 1, \"testSINTER\");\n checkEqual(intersection[0], 'c', \"testSINTER\");\n });\n}\n\nfunction testSINTERSTORE() {\n client.sadd('sa', 'a', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sa', 'b', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sa', 'c', expectNumber(1, \"testSINTERSTORE\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sb', 'c', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sb', 'd', expectNumber(1, \"testSINTERSTORE\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sc', 'd', expectNumber(1, \"testSINTERSTORE\"));\n client.sadd('sc', 'e', expectNumber(1, \"testSINTERSTORE\"));\n\n client.sinterstore('foo', 'sa', 'sb', 'sc', expectNumber(1, \"testSINTERSTORE\"))\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testSINTERSTORE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'c' ], \"testSINTERSTORE\");\n });\n}\n\nfunction testSUNION() {\n client.sadd('sa', 'a', expectNumber(1, \"testUNION\"));\n client.sadd('sa', 'b', expectNumber(1, \"testUNION\"));\n client.sadd('sa', 'c', expectNumber(1, \"testUNION\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testUNION\"));\n client.sadd('sb', 'c', expectNumber(1, \"testUNION\"));\n client.sadd('sb', 'd', expectNumber(1, \"testUNION\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testUNION\"));\n client.sadd('sc', 'd', expectNumber(1, \"testUNION\"));\n client.sadd('sc', 'e', expectNumber(1, \"testUNION\"));\n\n client.sunion('sa', 'sb', 'sc', function (err, union) {\n if (err) assert.fail(err, \"testUNION\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(union);\n checkDeepEqual(union.sort(), ['a', 'b', 'c', 'd', 'e'], \"testUNION\");\n });\n}\n\nfunction testSUNIONSTORE() {\n client.sadd('sa', 'a', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sa', 'b', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sa', 'c', expectNumber(1, \"testUNIONSTORE\"));\n\n client.sadd('sb', 'b', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sb', 'c', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sb', 'd', expectNumber(1, \"testUNIONSTORE\"));\n\n client.sadd('sc', 'c', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sc', 'd', expectNumber(1, \"testUNIONSTORE\"));\n client.sadd('sc', 'e', expectNumber(1, \"testUNIONSTORE\"));\n\n client.sunionstore('foo', 'sa', 'sb', 'sc', function (err, cardinality) {\n if (err) assert.fail(err, \"testUNIONSTORE\");\n checkEqual(cardinality, 5, \"testUNIONSTORE\");\n });\n\n client.smembers('foo', function (err, members) {\n if (err) assert.fail(err, \"testUNIONSTORE\");\n checkEqual(members.length, 5, \"testUNIONSTORE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members.sort(), ['a', 'b', 'c', 'd', 'e'], \"testUNIONSTORE\");\n });\n}\n\nfunction testTYPE() {\n client.sadd('sa', 'a', expectNumber(1, \"testTYPE\"));\n client.type('sa', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'set', \"testTYPE\");\n });\n\n client.rpush('list0', 'x', expectNumber(1, \"testTYPE\"));\n client.type('list0', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'list', \"testTYPE\");\n });\n\n client.set('foo', 'bar', expectOK(\"testTYPE\"));\n client.type('foo', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'string', \"testTYPE\");\n });\n\n client.type('xxx', function (err, type) {\n if (err) assert.fail(err, \"testTYPE\");\n checkEqual(type, 'none', \"testTYPE\");\n });\n}\n\nfunction testMOVE() {\n client.rpush('list0', 'x', expectNumber(1, \"testMOVE\"));\n client.move('list0', TEST_DB_NUMBER_FOR_MOVE, expectNumber(1, \"testMOVE\"));\n\n client.select(TEST_DB_NUMBER_FOR_MOVE, expectOK(\"testMOVE\"));\n client.exists('list0', expectNumber(1, \"testMOVE\"));\n\n client.select(TEST_DB_NUMBER, expectOK(\"testMOVE\"));\n client.exists('list0', expectNumber(0, \"testMOVE\"));\n}\n\n// TODO sort with STORE option.\n\n// Sort is a beast.\n//\n// $ redis-cli lrange x 0 -1\n// 1. 3\n// 2. 9\n// 3. 2\n// 4. 4\n//\n// $ redis-cli mget w3 w9 w2 w4\n// 1. 4\n// 2. 5\n// 3. 12\n// 4. 6\n//\n// $ redis-cli sort x by w*\n// 1. 3\n// 2. 9\n// 3. 4\n// 4. 2\n//\n// When using 'by w*' value x[i]'s effective value is w{x[i]}.\n//\n// sort [ w3, w9, w2, w4 ] = sort [ 4, 5, 12, 6 ]\n// = [ 4, 5, 6, 12 ]\n// = [ w3, w9, w4, w2 ]\n//\n// Thus, sorting x 'by w*' results in [ 3, 9, 4, 2 ]\n//\n// Once sorted redis can fetch entries at the keys indicated by the 'get'\n// pattern. If we specify 'get o*', redis would fetch [ o3, o9, o4, o2 ] \n// since our sorted list was [ 3, 9, 4, 2 ].\n//\n// $ redis-cli mget o2 o3 o4 o9\n// 1. buz\n// 2. foo\n// 3. baz\n// 4. bar\n//\n// $ redis-cli sort x by w* get o*\n// 1. foo\n// 2. bar\n// 3. baz\n// 4. buz\n//\n// One can specify multiple get patterns and the keys for each get pattern\n// are interlaced in the results.\n//\n// $ redis-cli mget p2 p3 p4 p9\n// 1. qux\n// 2. bux\n// 3. lux\n// 4. tux\n//\n// $ redis-cli sort x by w* get o* get p*\n// 1. foo\n// 2. bux\n// 3. bar\n// 4. tux\n// 5. baz\n// 6. lux\n// 7. buz\n// 8. qux\n//\n// Phew! Now, let's test all that.\n\nfunction testSORT() {\n client.rpush('y', 'd', expectNumber(1, \"testSORT\"));\n client.rpush('y', 'b', expectNumber(2, \"testSORT\"));\n client.rpush('y', 'a', expectNumber(3, \"testSORT\"));\n client.rpush('y', 'c', expectNumber(4, \"testSORT\"));\n\n client.rpush('x', '3', expectNumber(1, \"testSORT\"));\n client.rpush('x', '9', expectNumber(2, \"testSORT\"));\n client.rpush('x', '2', expectNumber(3, \"testSORT\"));\n client.rpush('x', '4', expectNumber(4, \"testSORT\"));\n\n client.set('w3', '4', expectOK(\"testSORT\"));\n client.set('w9', '5', expectOK(\"testSORT\"));\n client.set('w2', '12', expectOK(\"testSORT\"));\n client.set('w4', '6', expectOK(\"testSORT\"));\n\n client.set('o2', 'buz', expectOK(\"testSORT\"));\n client.set('o3', 'foo', expectOK(\"testSORT\"));\n client.set('o4', 'baz', expectOK(\"testSORT\"));\n client.set('o9', 'bar', expectOK(\"testSORT\"));\n\n client.set('p2', 'qux', expectOK(\"testSORT\"));\n client.set('p3', 'bux', expectOK(\"testSORT\"));\n client.set('p4', 'lux', expectOK(\"testSORT\"));\n client.set('p9', 'tux', expectOK(\"testSORT\"));\n\n // Now the data has been setup, we can test.\n\n // But first, test basic sorting.\n\n // y = [ d b a c ]\n // sort y ascending = [ a b c d ]\n // sort y descending = [ d c b a ]\n\n client.sort('y', 'asc', 'alpha', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['a', 'b', 'c', 'd'], \"testSORT\");\n });\n\n client.sort('y', 'desc', 'alpha', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['d', 'c', 'b', 'a'], \"testSORT\");\n });\n\n // Now try sorting numbers in a list.\n // x = [ 3, 9, 2, 4 ]\n\n client.sort('x', 'asc', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, [2, 3, 4, 9], \"testSORT\");\n });\n\n client.sort('x', 'desc', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, [9, 4, 3, 2], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern.\n\n client.sort('x', 'by', 'w*', 'asc', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, [3, 9, 4, 2], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern and 1 'get' pattern.\n\n client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['foo', 'bar', 'baz', 'buz'], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern and 2 'get' patterns.\n\n client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', function (err, sorted) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(sorted);\n checkDeepEqual(sorted, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], \"testSORT\");\n });\n\n // Try sorting with a 'by' pattern and 2 'get' patterns.\n // Instead of getting back the sorted set/list, store the values to a list.\n // Then check that the values are there in the expected order.\n\n client.sort('x', 'by', 'w*', 'asc', 'get', 'o*', 'get', 'p*', 'store', 'bacon', function (err) {\n if (err) assert.fail(err, \"testSORT\");\n });\n\n client.lrange('bacon', 0, -1, function (err, values) {\n if (err) assert.fail(err, \"testSORT\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(values);\n checkDeepEqual(values, ['foo', 'bux', 'bar', 'tux', 'baz', 'lux', 'buz', 'qux'], \"testSORT\");\n });\n}\n\nfunction testSAVE() {\n client.save(expectOK(\"testSAVE\"));\n}\n\nfunction testBGSAVE() {\n printDisclaimer();\n}\n\nfunction testLASTSAVE() {\n client.lastsave( function (err, value) {\n if (err) assert.fail(err, \"testLASTSAVE\");\n checkEqual(typeof(value), 'number', \"testLASTSAVE\");\n check(value > 0, \"testLASTSAVE\");\n });\n}\n\nfunction testFLUSHALL() {\n printDisclaimer();\n}\n\nfunction testSHUTDOWN() {\n printDisclaimer();\n}\n\nfunction testMSET() {\n // set a=b, c=d, e=100\n\n client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK(\"testMSET\"));\n}\n\nfunction testMSETNX() {\n client.mset('a', 'b', 'c', 'd', 'e', 100, expectOK(\"testMSET\"));\n\n // should fail since as 'a' already exists.\n\n client.msetnx('g', 'h', 'a', 'i', expectNumber(0, \"testMSETNX\"));\n\n // should pass as key 'g' was NOT set in prev. command\n // since it failed due to key 'a' already existing.\n\n client.msetnx('g', 'h', 'i', 'j', expectNumber(1, \"testMSETNX\"));\n}\n\nfunction testZADD() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZADD\"));\n\n // Already added m0; just update the score to 50.\n // Redis returns 0 in this case.\n\n client.zadd('z0', 50, 'm0', expectNumber(0, \"testZADD\"));\n}\n\nfunction testZREM() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZREM\"));\n client.zrem('z0', 'm0', expectNumber(1, \"testZREM\"));\n client.zrem('z0', 'm0', expectNumber(0, \"testZREM\"));\n}\n\nfunction testZCARD() {\n client.zcard('zzzzzz', expectNumber(0, \"testZCARD\")); // doesn't exist.\n\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZCARD\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZCARD\"));\n\n client.zcard('z0', expectNumber(2, \"testZCARD\"));\n}\n\nfunction testZSCORE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZSCORE\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZSCORE\"));\n\n client.zscore('z0', 'm0', expectNumber(100, \"testZSCORE\"));\n client.zscore('z0', 'm1', expectNumber(200, \"testZSCORE\"));\n\n client.zscore('z0', 'zzzzzzz', function (err, score) {\n if (err) assert.fail(err, \"testZSCORE\");\n checkEqual(score, null, \"testZSCORE\");\n });\n}\n\nfunction testZRANGE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZRANGE\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZRANGE\"));\n client.zadd('z0', 300, 'm2', expectNumber(1, \"testZRANGE\"));\n\n client.zrange('z0', 0, -1, function (err, members) {\n if (err) assert.fail(err, \"testZRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], \"testZRANGE\");\n });\n\n client.zrange('z0', -1, -1, function (err, members) {\n if (err) assert.fail(err, \"testZRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm2' ], \"testZRANGE\");\n });\n\n client.zrange('z0', -2, -1, function (err, members) {\n if (err) assert.fail(err, \"testZRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm1', 'm2' ], \"testZRANGE\");\n });\n}\n\nfunction testZREVRANGE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZREVRANGE\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZREVRANGE\"));\n client.zadd('z0', 300, 'm2', expectNumber(1, \"testZREVRANGE\"));\n\n client.zrevrange('z0', 0, 1000, function (err, members) {\n if (err) assert.fail(err, \"testZREVRANGE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm2', 'm1', 'm0' ], \"testZREVRANGE\");\n });\n}\n\nfunction testZRANGEBYSCORE() {\n client.zadd('z0', 100, 'm0', expectNumber(1, \"testZRANGEBYSCORE 1\"));\n client.zadd('z0', 200, 'm1', expectNumber(1, \"testZRANGEBYSCORE 2\"));\n client.zadd('z0', 300, 'm2', expectNumber(1, \"testZRANGEBYSCORE 3\"));\n\n client.zrangebyscore('z0', 200, 300, function (err, members) {\n if (err) assert.fail(err, \"testZRANGEBYSCORE 4\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm1', 'm2' ], \"testZRANGEBYSCORE 5\");\n });\n\n client.zrangebyscore('z0', 100, 1000, function (err, members) {\n if (err) assert.fail(err, \"testZRANGEBYSCORE 6\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'm0', 'm1', 'm2' ], \"testZRANGEBYSCORE 7\");\n });\n\n client.zrangebyscore('z0', 10000, 100000, function (err, members) {\n if (err) assert.fail(err, \"testZRANGEBYSCORE 8\");\n checkEqual(members, null, \"testZRANGEBYSCORE 9\");\n });\n}\n\n// zcount is undocumented as of Thu Apr 01 20:17:58 EDT 2010 \n// zcount key startScore endScore => number of elements in [startScore, endScore]\n\nfunction testZCOUNT() {\n client.zcount('z0', 0, 100, expectNumber(0, \"testZCOUNT\"));\n\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZCOUNT\"));\n client.zcount('z0', 0, 100, expectNumber(1, \"testZCOUNT\"));\n\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZCOUNT\"));\n client.zcount('z0', 0, 100, expectNumber(2, \"testZCOUNT\"));\n}\n\nfunction testZINCRBY() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZINCRBY\"));\n client.zincrby('z0', 1, 'a', expectNumber(2, \"testZINCRBY\"));\n}\n\n// This really should be called ZINTERSTORE.\n\nfunction testZINTER() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZINTER\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZINTER\"));\n client.zadd('z1', 3, 'a', expectNumber(1, \"testZINTER\"));\n client.zinter('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(1, \"testZINTER\"));\n client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZINTER\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n checkDeepEqual(members, [ 'a', 4 ], \"testZINTER\"); // score=1+3\n });\n}\n\nfunction testZUNION() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZUNION\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZUNION\"));\n client.zadd('z1', 3, 'a', expectNumber(1, \"testZUNION\"));\n client.zunion('z2', 2, 'z0', 'z1', 'AGGREGATE', 'SUM', expectNumber(2, \"testZUNION\"));\n client.zrange('z2', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZUNION\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n check(members.length % 2 == 0, \"testZUNION\");\n var set = {};\n for (var i=0; i<members.length; i += 2)\n set[members[i]] = members[i + 1];\n checkDeepEqual(set, { a:4, b:2 }, \"testZUNION\"); // a's score=1+3\n });\n}\n\nfunction testZRANK() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZRANK\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZRANK\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZRANK\"));\n\n client.zrank('z0', 'a', expectNumber(0, \"testZRANK\"));\n client.zrank('z0', 'b', expectNumber(1, \"testZRANK\"));\n client.zrank('z0', 'c', expectNumber(2, \"testZRANK\"));\n}\n\nfunction testZREVRANK() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZREVRANK\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZREVRANK\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZREVRANK\"));\n\n client.zrevrank('z0', 'a', expectNumber(2, \"testZREVRANK\"));\n client.zrevrank('z0', 'b', expectNumber(1, \"testZREVRANK\"));\n client.zrevrank('z0', 'c', expectNumber(0, \"testZREVRANK\"));\n}\n\nfunction testZREMRANGEBYRANK() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZREMRANGEBYRANK\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZREMRANGEBYRANK\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZREMRANGEBYRANK\"));\n\n client.zremrangebyrank('z0', -1, -1, expectNumber(1, \"testZREMRANGEBYRANK\"));\n\n client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZREMRANGEBYRANK\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n check(members.length % 2 == 0, \"testZREMRANGEBYRANK\");\n var set = {};\n for (var i=0; i<members.length; i += 2)\n set[members[i]] = members[i + 1];\n checkDeepEqual(set, { a:1, b:2 }, \"testZREMRANGEBYRANK\");\n });\n}\n\nfunction testZREMRANGEBYSCORE() {\n client.zadd('z0', 1, 'a', expectNumber(1, \"testZREMRANGEBYSCORE\"));\n client.zadd('z0', 2, 'b', expectNumber(1, \"testZREMRANGEBYSCORE\"));\n client.zadd('z0', 3, 'c', expectNumber(1, \"testZREMRANGEBYSCORE\"));\n\n // inclusive\n client.zremrangebyscore('z0', 2, 3, expectNumber(2, \"testZREMRANGEBYSCORE\"));\n\n client.zrange('z0', 0, -1, 'WITHSCORES', function (err, members) {\n if (err) assert.fail(err, \"testZREMRANGEBYSCORE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(members);\n check(members.length % 2 == 0, \"testZREMRANGEBYSCORE\");\n var set = {};\n for (var i=0; i<members.length; i += 2)\n set[members[i]] = members[i + 1];\n checkDeepEqual(set, { a:1 }, \"testZREMRANGEBYSCORE\");\n });\n}\n\nfunction testHDEL() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHDEL\"));\n client.hdel(\"foo\", \"bar\", expectNumber(1, \"testHDEL\"));\n client.hdel(\"foo\", \"bar\", expectNumber(0, \"testHDEL\"));\n}\n\nfunction testHEXISTS() {\n client.hset(\"hfoo\", \"bar\", \"baz\", expectNumber(1, \"testHEXISTS\"));\n client.hexists(\"hfoo\", \"bar\", expectNumber(1, \"testHEXISTS\"));\n client.hexists(\"hfoo\", \"baz\", expectNumber(0, \"testHEXISTS\"));\n}\n\nfunction testHGET() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHGET\"));\n client.hget(\"foo\", \"bar\", function (err, reply) {\n if (err) assert.fail(err, \"testHGET\");\n checkEqual(\"baz\", reply, \"testHGET\");\n });\n}\n\nfunction testHGETALL() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHGETALL\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHGETALL\"));\n client.hgetall(\"foo\", function (err, all) {\n if (err) assert.fail(err, \"testHGETALL\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(all);\n checkDeepEqual(all, { bar:\"baz\", quux:\"doo\" }, \"testHGETALL\");\n });\n}\n\nfunction testHINCRBY() {\n client.hincrby(\"foo\", \"bar\", 1, expectNumber(1, \"testHINCRBY 1\"));\n client.hget(\"foo\", \"bar\", expectNumber(1, \"testHINCRBY 2\"));\n\n client.hincrby(\"foo\", \"bar\", 1, expectNumber(2, \"testHINCRBY 3\"));\n client.hget(\"foo\", \"bar\", expectNumber(2, \"testHINCRBY 4\"));\n}\n\nfunction testHKEYS() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHKEYS\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHKEYS\"));\n client.hkeys(\"foo\", function (err, reply) {\n if (err) assert.fail(err, \"testHKEYS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply.sort(), [ \"bar\", \"quux\" ], \"testHKEYS\");\n });\n}\n\nfunction testHVALS() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHVALS\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHVALS\"));\n client.hvals(\"foo\", function (err, reply) {\n if (err) assert.fail(err, \"testHVALS\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply.sort(), [ \"baz\", \"doo\" ], \"testHVALS\");\n });\n}\n\nfunction testHLEN() {\n client.hlen(\"foo\", expectNumber(0, \"testHLEN\"));\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHLEN\"));\n client.hlen(\"foo\", expectNumber(1, \"testHLEN\"));\n client.hset(\"foo\", \"quux\", \"doo\", expectNumber(1, \"testHLEN\"));\n client.hlen(\"foo\", expectNumber(2, \"testHLEN\"));\n}\n\nfunction testHSET() {\n client.hset(\"foo\", \"bar\", \"baz\", expectNumber(1, \"testHSET\"));\n client.hget(\"foo\", \"bar\", function (err, reply) {\n if (err) assert.fail(err, \"testHSET\");\n checkEqual(\"baz\", reply, \"testHSET\");\n });\n}\n\n// Note that the user of this client should add a listener for \"connect\" via\n// client.stream.addListener(\"connect\", function () { ... }); in order to\n// subscribe to channels/classes of interest after each connection is established\n// (subscriptions are not remembered across connections and reconnections).\n\n// We need a 2nd client to act as publisher in order to test that a message\n// is received after SUBSCRIBE[ing] to a channel/class. We can at least test\n// that SUBSCRIBE itself does not fail (it shouldn't).\n\nfunction testSUBSCRIBE() {\n client.subscribe(\"#redis\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"subscribe\", \"#redis\", \"1\" ], \"testSUBSCRIBE\");\n });\n\n client.subscribe(\"#Node.js\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"subscribe\", \"#Node.js\", \"2\" ], \"testSUBSCRIBE\");\n });\n\n client.unsubscribe(\"#redis\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"unsubscribe\", \"#redis\", \"1\" ], \"testSUBSCRIBE\");\n });\n\n client.unsubscribe(\"#Node.js\", function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"unsubscribe\", \"#Node.js\", \"0\" ], \"testSUBSCRIBE\");\n });\n}\n\nfunction testUNSUBSCRIBE() {\n printDisclaimer();\n}\n\nfunction testPSUBSCRIBE() {\n client.psubscribe(\"cooking.*\", function (err, reply) {\n if (err) assert.fail(err, \"testPSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"psubscribe\", \"cooking.*\", \"1\" ], \"testPSUBSCRIBE\");\n });\n\n client.punsubscribe(\"cooking.*\", function (err, reply) {\n if (err) assert.fail(err, \"testPSUBSCRIBE\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"punsubscribe\", \"cooking.*\", \"0\" ], \"testPSUBSCRIBE\");\n });\n}\n\nfunction testPUNSUBSCRIBE() {\n printDisclaimer();\n}\n\nfunction testPUBLISH() {\n // No one is subscribed so 0\n\n client.publish(\"#redis\", \"Hello, world!\", expectNumber(0, \"testPUBLISH\"));\n}\n\nvar messageWasReceived = false;\n\nfunction testSUBSCRIBEandPUBLISH() {\n var messagePayload = \"I'm a lumberjack!\";\n var channelName = \"Monty\"; \n\n client.subscribeTo(channelName, function (channel, message) {\n checkEqual(channel, channelName, \"testSUBSCRIBEandPUBLISH a0\");\n checkEqual(message, messagePayload, \"testSUBSCRIBEandPUBLISH a1\");\n messageWasReceived = true;\n }); \n\n // Create a 2nd client that publishes a message.\n\n var publisher = redisclient.createClient();\n publisher.stream.addListener(\"connect\", function () {\n publisher.publish(channelName, messagePayload, function (err, reply) {\n if (err) assert.fail(err, \"testSUBSCRIBEandPUBLISH b0\");\n expectNumber(1, \"testSUBSCRIBEandPUBLISH b1\");\n });\n });\n}\n\n// We cannot test the blocking behavior of BLPOP and BRPOP from a single client\n// without using a timeout. That being said, we can test the non-blocking\n// behavior by ensuring there's an element in a list that we try to pop from.\n\nfunction testBLPOP() {\n var timeout = 1;\n\n // Non-blocking against a single key.\n\n client.lpush('list0', 'ABC', expectNumber(1, \"testBLPOP 1\"));\n client.blpop('list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBLPOP 2\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"ABC\" ], \"testBLPOP 3\");\n });\n\n // Non-blocking against multiple keys.\n // Returns the first one that has something in it.\n\n client.lpush('list0', 'ABC', expectNumber(1, \"testBLPOP 4\"));\n client.blpop('list1', 'list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBLPOP 5\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"ABC\" ], \"testBLPOP 6\");\n });\n\n // Non-blocking against a single key that does not exist.\n // This should timeout after 1 second and return a null reply.\n\n client.blpop('listX', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBLPOP 7\");\n checkEqual(reply, null, \"testBLPOP 8\");\n });\n}\n\nfunction testBRPOP() {\n var timeout = 1;\n\n // Non-blocking against a single key.\n\n client.lpush('list0', 'ABC', expectNumber(1, \"testBRPOP\"));\n client.lpush('list0', 'DEF', expectNumber(2, \"testBRPOP\"));\n client.brpop('list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBRPOP\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"ABC\" ], \"testBRPOP\");\n });\n\n // Non-blocking against multiple keys.\n // Returns the first one that has something in it.\n\n client.lpush('list0', 'ABC', expectNumber(2, \"testBRPOP\"));\n client.brpop('list1', 'list0', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBRPOP\");\n redisclient.convertMultiBulkBuffersToUTF8Strings(reply);\n checkDeepEqual(reply, [ \"list0\", \"DEF\" ], \"testBRPOP\");\n });\n\n // Non-blocking against a single key that does not exist.\n // This should timeout after 1 second and return a null reply.\n\n client.brpop('listX', timeout, function (err, reply) {\n if (err) assert.fail(err, \"testBRPOP\");\n checkEqual(reply, null, \"testBRPOP\");\n });\n}\n\nvar allTestFunctions = [\n testAUTH,\n testBGSAVE,\n testBLPOP,\n testBRPOP,\n testDBSIZE,\n testDECR,\n testDECRBY,\n testDEL,\n testEXISTS,\n testEXPIRE,\n testFLUSHALL,\n testFLUSHDB,\n testGET,\n testGETSET,\n testHDEL, \n testHEXISTS,\n testHGET,\n testHGETALL,\n testHINCRBY,\n testHKEYS,\n testHLEN,\n testHSET,\n testHVALS,\n testINCR,\n testINCRBY,\n testINFO,\n testKEYS,\n testLASTSAVE,\n testLINDEX,\n testLLEN,\n testLPOP,\n testLPUSH,\n testLRANGE,\n testLREM,\n testLSET,\n testLTRIM,\n testMGET,\n testMOVE,\n testMSET,\n testMSETNX,\n testParseBulkReply,\n testParseErrorReply,\n testParseInlineReply,\n testParseIntegerReply,\n testParseMultiBulkReply,\n testPSUBSCRIBE,\n testPUBLISH,\n testPUNSUBSCRIBE,\n testRANDOMKEY,\n testRENAME,\n testRENAMENX,\n testRPOP,\n testRPOPLPUSH,\n testRPUSH,\n testSADD,\n testSAVE,\n testSCARD,\n testSDIFF,\n testSDIFFSTORE,\n testSELECT,\n testSET,\n testSETANDGETMULTIBYTE,\n testSETNX,\n testSHUTDOWN,\n testSINTER,\n testSINTERSTORE,\n testSISMEMBER,\n testSMEMBERS,\n testSMOVE,\n testSORT,\n testSPOP,\n testSREM,\n testSUBSCRIBE,\n testSUNION,\n testSUNIONSTORE,\n testTTL,\n testTYPE,\n testUNSUBSCRIBE,\n testZADD,\n testZCARD,\n testZCOUNT,\n testZINCRBY,\n testZINTER,\n testZRANGE,\n testZRANGEBYSCORE,\n testZRANK,\n testZREM,\n testZREMRANGEBYRANK,\n testZREMRANGEBYSCORE,\n testZREVRANGE,\n testZREVRANK,\n testZSCORE,\n testZUNION,\n];\n\nfunction checkIfDone() {\n if (client.originalCommands.length == 0) {\n testSUBSCRIBEandPUBLISH();\n \n var checks = 0;\n setInterval(function () {\n if (messageWasReceived) {\n sys.error(\"\\n\");\n log(\"info\", \"All tests have passed.\");\n process.exit(0);\n } else {\n assert.notEqual(++checks, 5, \"testSUBSCRIBEandPUBLISH never received message\");\n } \n }, 100);\n } else {\n if (verbose)\n log('info', client.originalCommands.length + \" replies still pending...\");\n else if (!quiet)\n sys.print(\"+\");\n }\n}\n\nfunction runAllTests() {\n allTestFunctions.forEach(function (testFunction) {\n if (verbose) {\n sys.error(\"\");\n log(\"info\", \"Testing \" + testFunction.name.replace(/^test/, ''));\n sys.error(\"=========================================\");\n } else if (!quiet) {\n sys.print(\".\");\n }\n\n clearTestDatabasesBeforeEachTest();\n testFunction();\n });\n\n setInterval(checkIfDone, 1500);\n setTimeout(function() {\n log(\"error\", \"Tests timed out\");\n process.exit(1);\n }, MAX_TEST_TIME);\n}\n\nvar connectionFailed = false;\nvar client = redisclient.createClient();\nclient.stream.addListener(\"connect\", runAllTests);\nclient.stream.addListener(\"close\", function (inError) {\n connectionFailed = inError;\n if (inError)\n throw new Error(\"Connection to Redis failed. Not attempting reconnection.\");\n});\n\nfunction debugFilter(what) {\n var filtered = what;\n\n filtered = filtered.replace(/\\r\\n/g, '<CRLF>');\n filtered = filtered.replace(/\\r/g, '<CR>');\n filtered = filtered.replace(/\\n/g, '<LF>');\n\n return filtered;\n}\n\nfunction printDisclaimer() {\n if (redisclient.debugMode) \n sys.debug(\"This test does not do anything\");\n}\n\n"
at checkEqual (/home/nikhil/workspace/node-libraries/redis-node-client/test/test.js:73:16)
at /home/nikhil/workspace/node-libraries/redis-node-client/test/test.js:340:26
at Client.onReply_ (/home/nikhil/workspace/node-libraries/redis-node-client/lib/redis-client.js:330:28)
at /home/nikhil/workspace/node-libraries/redis-node-client/lib/redis-client.js:152:30
at ReplyParser.feed (/home/nikhil/workspace/node-libraries/redis-node-client/lib/redis-client.js:207:25)
at Stream.<anonymous> (/home/nikhil/workspace/node-libraries/redis-node-client/lib/redis-client.js:279:28)
at IOWatcher.callback (net:353:16)
at node.js:748:9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment