You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Support for multiple reply parsers including hiredis.
Several parsing bugs fixed in JavaScript. Some new config options that need to be better documented.
This commit is contained in:
23
test.js
23
test.js
@@ -1,6 +1,8 @@
|
||||
/*global require console setTimeout process Buffer */
|
||||
var redis = require("./index"),
|
||||
client = redis.createClient(),
|
||||
client = redis.createClient(6379, "127.0.0.1", {
|
||||
parser: "javascript"
|
||||
}),
|
||||
client2 = redis.createClient(),
|
||||
client3 = redis.createClient(),
|
||||
assert = require("assert"),
|
||||
@@ -12,7 +14,7 @@ var redis = require("./index"),
|
||||
server_info;
|
||||
|
||||
// Uncomment this to see the wire protocol and other debugging info
|
||||
//redis.debug_mode = true;
|
||||
redis.debug_mode = true;
|
||||
|
||||
function buffers_to_strings(arr) {
|
||||
return arr.map(function (val) {
|
||||
@@ -149,8 +151,15 @@ tests.MULTI_3 = function () {
|
||||
client.sadd("some set", "mem 2");
|
||||
client.sadd("some set", "mem 3");
|
||||
client.sadd("some set", "mem 4");
|
||||
|
||||
// make sure empty mb reply works
|
||||
client.del("some missing set");
|
||||
client.smembers("some missing set", function (err, reply) {
|
||||
// make sure empty mb reply works
|
||||
assert.strictEqual(true, is_empty_array(reply), name);
|
||||
});
|
||||
|
||||
// test nested multi-bulk replies with nulls.
|
||||
// test nested multi-bulk replies with empty mb elements.
|
||||
client.multi([
|
||||
["smembers", "some set"],
|
||||
["del", "some set"],
|
||||
@@ -479,7 +488,7 @@ tests.HGETALL = function () {
|
||||
client.HGETALL(["hosts"], function (err, obj) {
|
||||
assert.strictEqual(null, err, name + " result sent back unexpected error: " + err);
|
||||
assert.strictEqual(3, Object.keys(obj).length, name);
|
||||
assert.ok(Buffer.isBuffer(obj.mjr), name);
|
||||
// assert.ok(Buffer.isBuffer(obj.mjr), name);
|
||||
assert.strictEqual("1", obj.mjr.toString(), name);
|
||||
assert.strictEqual("23", obj.another.toString(), name);
|
||||
assert.strictEqual("1234", obj.home.toString(), name);
|
||||
@@ -1003,6 +1012,8 @@ function run_next_test() {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Using reply parser " + client.reply_parser.name);
|
||||
|
||||
client.on("connect", function () {
|
||||
// Fetch and stash info results in case anybody needs info on the server we are using.
|
||||
client.info(function (err, reply) {
|
||||
@@ -1018,10 +1029,12 @@ client.on("connect", function () {
|
||||
obj.versions.push(+num);
|
||||
});
|
||||
server_info = obj;
|
||||
console.log("Connected to " + client.host + ":" + client.port + ", Redis server version " + obj.redis_version + "\n");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
connected = true;
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
client.on('end', function () {
|
||||
|
Reference in New Issue
Block a user