1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Remove send_command safety checks

This checks are only important for users who use send_command directly instead of using the convience method.
As the readme clearly stats how send_command should work and any user would have run into errors if misused, these checks can be removed. If any user might misuse the function anyway, it is very likely that another error will be thrown because of that

Fix #629 and insert tests
This commit is contained in:
Ruben Bridgewater
2015-09-04 15:14:57 +02:00
parent e24f056b2d
commit 005e869d83
2 changed files with 55 additions and 28 deletions

View File

@@ -117,6 +117,44 @@ describe("The node_redis client", function () {
client.end();
});
describe("send_command", function () {
it("omitting args should be fine in some cases", function (done) {
client.send_command("info", undefined, function(err, res) {
assert(/redis_version/.test(res));
done();
});
});
it("using another type as cb should just work as if there were no callback parameter", function (done) {
client.send_command('set', ['test', 'bla'], [true]);
client.get('test', function(err, res) {
assert.equal(res, 'bla');
done();
});
});
it("misusing the function should eventually throw (no command)", function (done) {
var mochaListener = helper.removeMochaListener();
process.once('uncaughtException', function (err) {
process.on('uncaughtException', mochaListener);
assert(/is not a function|toUpperCase/.test(err));
done();
});
client.send_command(true, 'info');
});
it("misusing the function should eventually throw (wrong args)", function (done) {
client.send_command('info', false, function(err, res) {
assert.equal(err.message, 'ERR Protocol error: invalid multibulk length');
done();
});
});
});
describe("when redis closes unexpectedly", function () {
it("reconnects and can retrieve the pre-existing data", function (done) {
client.on("reconnecting", function on_recon(params) {