You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Client to emit errors now instead of throwing them asynchronously where they're uncatchable.
This commit is contained in:
66
test.js
66
test.js
@@ -402,6 +402,72 @@ tests.FWD_ERRORS_1 = function () {
|
||||
}, 150);
|
||||
};
|
||||
|
||||
tests.FWD_ERRORS_2 = function () {
|
||||
var name = "FWD_ERRORS_2";
|
||||
|
||||
var toThrow = new Error("Forced exception");
|
||||
var recordedError = null;
|
||||
|
||||
var originalHandler = client.listeners("error").pop();
|
||||
client.removeAllListeners("error");
|
||||
client.once("error", function (err) {
|
||||
recordedError = err;
|
||||
});
|
||||
|
||||
client.get("no_such_key", function (err, reply) {
|
||||
throw toThrow;
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
client.listeners("error").push(originalHandler);
|
||||
assert.equal(recordedError, toThrow, "Should have caught our forced exception");
|
||||
next(name);
|
||||
}, 150);
|
||||
};
|
||||
|
||||
tests.FWD_ERRORS_3 = function () {
|
||||
var name = "FWD_ERRORS_3";
|
||||
|
||||
var recordedError = null;
|
||||
|
||||
var originalHandler = client.listeners("error").pop();
|
||||
client.removeAllListeners("error");
|
||||
client.once("error", function (err) {
|
||||
recordedError = err;
|
||||
});
|
||||
|
||||
client.send_command("no_such_command", []);
|
||||
|
||||
setTimeout(function () {
|
||||
client.listeners("error").push(originalHandler);
|
||||
assert.ok(recordedError instanceof Error);
|
||||
next(name);
|
||||
}, 150);
|
||||
};
|
||||
|
||||
tests.FWD_ERRORS_4 = function () {
|
||||
var name = "FWD_ERRORS_4";
|
||||
|
||||
var toThrow = new Error("Forced exception");
|
||||
var recordedError = null;
|
||||
|
||||
var originalHandler = client.listeners("error").pop();
|
||||
client.removeAllListeners("error");
|
||||
client.once("error", function (err) {
|
||||
recordedError = err;
|
||||
});
|
||||
|
||||
client.send_command("no_such_command", [], function () {
|
||||
throw toThrow;
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
client.listeners("error").push(originalHandler);
|
||||
assert.equal(recordedError, toThrow, "Should have caught our forced exception");
|
||||
next(name);
|
||||
}, 150);
|
||||
};
|
||||
|
||||
tests.EVAL_1 = function () {
|
||||
var name = "EVAL_1";
|
||||
|
||||
|
Reference in New Issue
Block a user