1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

chore: remove support for UPPER_CASE commands

This commit is contained in:
Ruben Bridgewater
2017-05-06 01:46:29 +02:00
parent f92bc18c16
commit 19f3d20b47
41 changed files with 136 additions and 137 deletions

View File

@@ -15,7 +15,7 @@ commands.list.forEach(function (command) {
// Do not override existing functions
if (!RedisClient.prototype[command]) {
RedisClient.prototype[command.toUpperCase()] = RedisClient.prototype[command] = function () {
RedisClient.prototype[command] = function () {
var arr;
var len = arguments.length;
var callback;
@@ -57,7 +57,7 @@ commands.list.forEach(function (command) {
// Do not override existing functions
if (!Multi.prototype[command]) {
Multi.prototype[command.toUpperCase()] = Multi.prototype[command] = function () {
Multi.prototype[command] = function () {
var arr;
var len = arguments.length;
var callback;

View File

@@ -21,14 +21,14 @@ var RedisClient = require('../').RedisClient;
on single and multi calls!
********************************************************************************************/
RedisClient.prototype.multi = RedisClient.prototype.MULTI = function multi (args) {
RedisClient.prototype.multi = function multi (args) {
var multi = new Multi(this, args);
multi.exec = multi.EXEC = multi.execTransaction;
return multi;
};
// ATTENTION: This is not a native function but is still handled as a individual command as it behaves just the same as multi
RedisClient.prototype.batch = RedisClient.prototype.BATCH = function batch (args) {
RedisClient.prototype.batch = function batch (args) {
return new Multi(this, args);
};
@@ -42,11 +42,11 @@ function selectCallback (self, db, callback) {
};
}
RedisClient.prototype.select = RedisClient.prototype.SELECT = function select (db, callback) {
RedisClient.prototype.select = function select (db, callback) {
return this.internalSendCommand(new Command('select', [db], selectCallback(this, db, callback)));
};
Multi.prototype.select = Multi.prototype.SELECT = function select (db, callback) {
Multi.prototype.select = function select (db, callback) {
this.queue.push(new Command('select', [db], selectCallback(this._client, db, callback)));
return this;
};
@@ -63,7 +63,7 @@ RedisClient.prototype.monitor = RedisClient.prototype.MONITOR = function monitor
};
// Only works with batch, not in a transaction
Multi.prototype.monitor = Multi.prototype.MONITOR = function monitor (callback) {
Multi.prototype.monitor = function monitor (callback) {
// Use a individual command, as this is a special case that does not has to be checked for any other command
if (this.exec !== this.execTransaction) {
var self = this;
@@ -98,7 +98,7 @@ function quitCallback (self, callback) {
};
}
RedisClient.prototype.QUIT = RedisClient.prototype.quit = function quit (callback) {
RedisClient.prototype.quit = function quit (callback) {
// TODO: Consider this for v.3
// Allow the quit command to be fired as soon as possible to prevent it landing in the offline queue.
// this.ready = this.offlineQueue.length === 0;
@@ -110,7 +110,7 @@ RedisClient.prototype.QUIT = RedisClient.prototype.quit = function quit (callbac
};
// Only works with batch, not in a transaction
Multi.prototype.QUIT = Multi.prototype.quit = function quit (callback) {
Multi.prototype.quit = function quit (callback) {
var self = this._client;
var callOnWrite = function () {
// If called in a multi context, we expect redis is available
@@ -159,7 +159,7 @@ function infoCallback (self, callback) {
}
// Store info in this.serverInfo after each call
RedisClient.prototype.info = RedisClient.prototype.INFO = function info (section, callback) {
RedisClient.prototype.info = function info (section, callback) {
var args = [];
if (typeof section === 'function') {
callback = section;
@@ -169,7 +169,7 @@ RedisClient.prototype.info = RedisClient.prototype.INFO = function info (section
return this.internalSendCommand(new Command('info', args, infoCallback(this, callback)));
};
Multi.prototype.info = Multi.prototype.INFO = function info (section, callback) {
Multi.prototype.info = function info (section, callback) {
var args = [];
if (typeof section === 'function') {
callback = section;
@@ -200,7 +200,7 @@ function authCallback (self, pass, callback) {
};
}
RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, callback) {
RedisClient.prototype.auth = function auth (pass, callback) {
debug('Sending auth to ' + this.address + ' id ' + this.connectionId);
// Stash auth for connect and reconnect.
@@ -213,7 +213,7 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, c
};
// Only works with batch, not in a transaction
Multi.prototype.auth = Multi.prototype.AUTH = function auth (pass, callback) {
Multi.prototype.auth = function auth (pass, callback) {
debug('Sending auth to ' + this.address + ' id ' + this.connectionId);
// Stash auth for connect and reconnect.
@@ -222,7 +222,7 @@ Multi.prototype.auth = Multi.prototype.AUTH = function auth (pass, callback) {
return this;
};
RedisClient.prototype.client = RedisClient.prototype.CLIENT = function client () {
RedisClient.prototype.client = function client () {
var arr,
len = arguments.length,
callback,
@@ -267,7 +267,7 @@ RedisClient.prototype.client = RedisClient.prototype.CLIENT = function client ()
return this.internalSendCommand(new Command('client', arr, callback, callOnWrite));
};
Multi.prototype.client = Multi.prototype.CLIENT = function client () {
Multi.prototype.client = function client () {
var arr,
len = arguments.length,
callback,
@@ -313,7 +313,7 @@ Multi.prototype.client = Multi.prototype.CLIENT = function client () {
return this;
};
RedisClient.prototype.hmset = RedisClient.prototype.HMSET = function hmset () {
RedisClient.prototype.hmset = function hmset () {
var arr,
len = arguments.length,
callback,
@@ -352,7 +352,7 @@ RedisClient.prototype.hmset = RedisClient.prototype.HMSET = function hmset () {
return this.internalSendCommand(new Command('hmset', arr, callback));
};
Multi.prototype.hmset = Multi.prototype.HMSET = function hmset () {
Multi.prototype.hmset = function hmset () {
var arr,
len = arguments.length,
callback,
@@ -392,7 +392,7 @@ Multi.prototype.hmset = Multi.prototype.HMSET = function hmset () {
return this;
};
RedisClient.prototype.subscribe = RedisClient.prototype.SUBSCRIBE = function subscribe () {
RedisClient.prototype.subscribe = function subscribe () {
var arr,
len = arguments.length,
callback,
@@ -419,7 +419,7 @@ RedisClient.prototype.subscribe = RedisClient.prototype.SUBSCRIBE = function sub
return this.internalSendCommand(new Command('subscribe', arr, callback, callOnWrite));
};
Multi.prototype.subscribe = Multi.prototype.SUBSCRIBE = function subscribe () {
Multi.prototype.subscribe = function subscribe () {
var arr,
len = arguments.length,
callback,
@@ -447,7 +447,7 @@ Multi.prototype.subscribe = Multi.prototype.SUBSCRIBE = function subscribe () {
return this;
};
RedisClient.prototype.unsubscribe = RedisClient.prototype.UNSUBSCRIBE = function unsubscribe () {
RedisClient.prototype.unsubscribe = function unsubscribe () {
var arr,
len = arguments.length,
callback,
@@ -475,7 +475,7 @@ RedisClient.prototype.unsubscribe = RedisClient.prototype.UNSUBSCRIBE = function
return this.internalSendCommand(new Command('unsubscribe', arr, callback, callOnWrite));
};
Multi.prototype.unsubscribe = Multi.prototype.UNSUBSCRIBE = function unsubscribe () {
Multi.prototype.unsubscribe = function unsubscribe () {
var arr,
len = arguments.length,
callback,
@@ -504,7 +504,7 @@ Multi.prototype.unsubscribe = Multi.prototype.UNSUBSCRIBE = function unsubscribe
return this;
};
RedisClient.prototype.psubscribe = RedisClient.prototype.PSUBSCRIBE = function psubscribe () {
RedisClient.prototype.psubscribe = function psubscribe () {
var arr,
len = arguments.length,
callback,
@@ -531,7 +531,7 @@ RedisClient.prototype.psubscribe = RedisClient.prototype.PSUBSCRIBE = function p
return this.internalSendCommand(new Command('psubscribe', arr, callback, callOnWrite));
};
Multi.prototype.psubscribe = Multi.prototype.PSUBSCRIBE = function psubscribe () {
Multi.prototype.psubscribe = function psubscribe () {
var arr,
len = arguments.length,
callback,
@@ -559,7 +559,7 @@ Multi.prototype.psubscribe = Multi.prototype.PSUBSCRIBE = function psubscribe ()
return this;
};
RedisClient.prototype.punsubscribe = RedisClient.prototype.PUNSUBSCRIBE = function punsubscribe () {
RedisClient.prototype.punsubscribe = function punsubscribe () {
var arr,
len = arguments.length,
callback,
@@ -587,7 +587,7 @@ RedisClient.prototype.punsubscribe = RedisClient.prototype.PUNSUBSCRIBE = functi
return this.internalSendCommand(new Command('punsubscribe', arr, callback, callOnWrite));
};
Multi.prototype.punsubscribe = Multi.prototype.PUNSUBSCRIBE = function punsubscribe () {
Multi.prototype.punsubscribe = function punsubscribe () {
var arr,
len = arguments.length,
callback,

View File

@@ -41,7 +41,7 @@ function pipelineTransactionCommand (self, commandObj, index) {
self._client.internalSendCommand(commandObj);
}
Multi.prototype.execAtomic = Multi.prototype.EXEC_ATOMIC = Multi.prototype.execAtomic = function execAtomic (callback) {
Multi.prototype.execAtomic = function execAtomic (callback) {
if (this.queue.length < 2) {
return this.execBatch(callback);
}
@@ -132,7 +132,7 @@ function batchCallback (self, cb, i) {
};
}
Multi.prototype.exec = Multi.prototype.EXEC = Multi.prototype.execBatch = function execBatch (callback) {
Multi.prototype.exec = Multi.prototype.execBatch = function execBatch (callback) {
var self = this;
var len = self.queue.length;
var index = 0;

View File

@@ -309,21 +309,21 @@ describe('client authentication', function () {
});
client.batch()
.auth(auth)
.SELECT(5, function (err, res) {
.select(5, function (err, res) {
assert.strictEqual(client.selectedDb, 5);
assert.strictEqual(res, 'OK');
assert.notDeepEqual(client.serverInfo.db5, { avgTtl: 0, expires: 0, keys: 1 });
})
.monitor()
.set('foo', 'bar', helper.isString('OK'))
.INFO('stats', function (err, res) {
.info('stats', function (err, res) {
assert.strictEqual(res.indexOf('# Stats\r\n'), 0);
assert.strictEqual(client.serverInfo.sync_full, '0');
})
.get('foo', helper.isString('bar'))
.subscribe(['foo', 'bar', 'foo'], helper.isUnSubscribe(2, ['foo', 'bar', 'foo']))
.unsubscribe('foo')
.SUBSCRIBE('/foo', helper.isUnSubscribe(2, '/foo'))
.subscribe('/foo', helper.isUnSubscribe(2, '/foo'))
.psubscribe('*')
.quit(helper.isString('OK'))
.exec(function (err, res) {

View File

@@ -182,7 +182,7 @@ describe("The 'batch' method", function () {
});
// test nested batch-bulk replies with empty mb elements.
client.BATCH([
client.batch([
['smembers', ['some set']],
['del', 'some set'],
['smembers', 'some set', undefined] // The explicit undefined is handled as a callback that is undefined
@@ -210,7 +210,7 @@ describe("The 'batch' method", function () {
['hmset', arr3, helper.isString('OK')],
['hmset', now, {123456789: 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}],
['hmset', 'key2', {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 999}, helper.isString('OK')],
['HMSET', 'batchhmset', ['batchbar', 'batchbaz']],
['hmset', 'batchhmset', ['batchbar', 'batchbaz']],
['hmset', 'batchhmset', ['batchbar', 'batchbaz'], helper.isString('OK')],
])
.hmget(now, 123456789, 'otherTypes')

View File

@@ -62,7 +62,7 @@ describe("The 'blpop' method", function () {
it('times out after specified time', function (done) {
bclient = redis.createClient.apply(null, args);
bclient.BLPOP('blocking list', 1, function (err, res) {
bclient.blpop('blocking list', 1, function (err, res) {
assert.strictEqual(res, null);
return done(err);
});

View File

@@ -55,7 +55,7 @@ describe("The 'dbsize' method", function () {
});
it('returns a zero db size', function (done) {
client.DBSIZE([], function (err, res) {
client.dbsize([], function (err, res) {
helper.isNotError()(err, res);
helper.isType.number()(err, res);
assert.strictEqual(res, 0, 'Initial db size should be 0');

View File

@@ -20,7 +20,7 @@ describe("The 'del' method", function () {
it('allows a single key to be deleted', function (done) {
client.set('foo', 'bar');
client.DEL('foo', helper.isNumber(1));
client.del('foo', helper.isNumber(1));
client.get('foo', helper.isNull(done));
});

View File

@@ -20,12 +20,12 @@ describe("The 'exists' method", function () {
it('returns 1 if the key exists', function (done) {
client.set('foo', 'bar');
client.EXISTS('foo', helper.isNumber(1, done));
client.exists('foo', helper.isNumber(1, done));
});
it('returns 1 if the key exists with array syntax', function (done) {
client.set('foo', 'bar');
client.EXISTS(['foo'], helper.isNumber(1, done));
client.exists(['foo'], helper.isNumber(1, done));
});
it('returns 0 if the key does not exist', function (done) {

View File

@@ -20,7 +20,7 @@ describe("The 'expire' method", function () {
it('expires key after timeout', function (done) {
client.set(['expiry key', 'bar'], helper.isString('OK'));
client.EXPIRE('expiry key', '1', helper.isNumber(1));
client.expire('expiry key', '1', helper.isNumber(1));
setTimeout(function () {
client.exists(['expiry key'], helper.isNumber(0, done));
}, 1050);
@@ -28,7 +28,7 @@ describe("The 'expire' method", function () {
it('expires key after timeout with array syntax', function (done) {
client.set(['expiry key', 'bar'], helper.isString('OK'));
client.EXPIRE(['expiry key', '1'], helper.isNumber(1));
client.expire(['expiry key', '1'], helper.isNumber(1));
setTimeout(function () {
client.exists(['expiry key'], helper.isNumber(0, done));
}, 1050);

View File

@@ -66,14 +66,14 @@ describe("The 'get' method", function () {
});
it('gets the value correctly', function (done) {
client.GET(key, function (err, res) {
client.get(key, function (err, res) {
helper.isString(value)(err, res);
done(err);
});
});
it("should not throw on a get without callback (even if it's not useful)", function (done) {
client.GET(key);
client.get(key);
client.on('error', function (err) {
throw err;
});

View File

@@ -61,7 +61,7 @@ describe("The 'getset' method", function () {
});
it('gets the value correctly', function (done) {
client.GETSET(key, value2, function (err, res) {
client.getset(key, value2, function (err, res) {
helper.isString(value)(err, res);
client.get(key, function (err, res) {
helper.isString(value2)(err, res);
@@ -71,7 +71,7 @@ describe("The 'getset' method", function () {
});
it('gets the value correctly with array syntax', function (done) {
client.GETSET([key, value2], function (err, res) {
client.getset([key, value2], function (err, res) {
helper.isString(value)(err, res);
client.get(key, function (err, res) {
helper.isString(value2)(err, res);
@@ -81,7 +81,7 @@ describe("The 'getset' method", function () {
});
it('gets the value correctly with array syntax style 2', function (done) {
client.GETSET(key, [value2], function (err, res) {
client.getset(key, [value2], function (err, res) {
helper.isString(value)(err, res);
client.get(key, function (err, res) {
helper.isString(value2)(err, res);

View File

@@ -23,7 +23,7 @@ describe("The 'hgetall' method", function () {
it('handles simple keys and values', function (done) {
client.hmset(['hosts', 'hasOwnProperty', '1', 'another', '23', 'home', '1234'], helper.isString('OK'));
client.HGETALL(['hosts'], function (err, obj) {
client.hgetall(['hosts'], function (err, obj) {
assert.strictEqual(3, Object.keys(obj).length);
assert.strictEqual('1', obj.hasOwnProperty.toString());
assert.strictEqual('23', obj.another.toString());
@@ -33,7 +33,7 @@ describe("The 'hgetall' method", function () {
});
it('handles fetching keys set using an object', function (done) {
client.batch().HMSET('msgTest', { message: 'hello' }, undefined).exec();
client.batch().hmset('msgTest', { message: 'hello' }, undefined).exec();
client.hgetall('msgTest', function (err, obj) {
assert.strictEqual(1, Object.keys(obj).length);
assert.strictEqual(obj.message, 'hello');
@@ -64,7 +64,7 @@ describe("The 'hgetall' method", function () {
it('returns binary results', function (done) {
client.hmset(['bhosts', 'mjr', '1', 'another', '23', 'home', '1234', new Buffer([0xAA, 0xBB, 0x00, 0xF0]), new Buffer([0xCC, 0xDD, 0x00, 0xF0])], helper.isString('OK'));
client.HGETALL('bhosts', function (err, obj) {
client.hgetall('bhosts', function (err, obj) {
assert.strictEqual(4, Object.keys(obj).length);
assert.strictEqual('1', obj.mjr.toString());
assert.strictEqual('23', obj.another.toString());

View File

@@ -22,14 +22,14 @@ describe("The 'hincrby' method", function () {
it('increments a key that has already been set', function (done) {
var field = 'field 1';
client.HSET(hash, field, 33);
client.hset(hash, field, 33);
client.hincrby(hash, field, 10, helper.isNumber(43, done));
});
it('increments a key that has not been set', function (done) {
var field = 'field 2';
client.HINCRBY(hash, field, 10, helper.isNumber(10, done));
client.hincrby(hash, field, 10, helper.isNumber(10, done));
});
afterEach(function () {

View File

@@ -25,9 +25,9 @@ describe("The 'hlen' method", function () {
var field2 = new Buffer(0);
var value2 = new Buffer(0);
client.HSET(hash, field1, value1, helper.isNumber(1));
client.HSET(hash, field2, value2, helper.isNumber(1));
client.HLEN(hash, helper.isNumber(2, done));
client.hset(hash, field1, value1, helper.isNumber(1));
client.hset(hash, field2, value2, helper.isNumber(1));
client.hlen(hash, helper.isNumber(2, done));
});
afterEach(function () {

View File

@@ -18,7 +18,7 @@ describe("The 'hmget' method", function () {
client.once('error', done);
client.once('ready', function () {
client.flushdb();
client.HMSET(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value'}, helper.isString('OK', done));
client.hmset(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value'}, helper.isString('OK', done));
});
});
@@ -32,7 +32,7 @@ describe("The 'hmget' method", function () {
it('allows keys to be specified by passing an array without manipulating the array', function (done) {
var data = ['0123456789', 'some manner of key'];
client.HMGET(hash, data, function (err, reply) {
client.hmget(hash, data, function (err, reply) {
assert.strictEqual(data.length, 2);
assert.strictEqual('abcdefghij', reply[0].toString());
assert.strictEqual('a type of value', reply[1].toString());
@@ -41,7 +41,7 @@ describe("The 'hmget' method", function () {
});
it('allows keys to be specified by passing an array as first argument', function (done) {
client.HMGET([hash, '0123456789', 'some manner of key'], function (err, reply) {
client.hmget([hash, '0123456789', 'some manner of key'], function (err, reply) {
assert.strictEqual('abcdefghij', reply[0].toString());
assert.strictEqual('a type of value', reply[1].toString());
return done(err);
@@ -49,14 +49,14 @@ describe("The 'hmget' method", function () {
});
it('allows a single key to be specified in an array', function (done) {
client.HMGET(hash, ['0123456789'], function (err, reply) {
client.hmget(hash, ['0123456789'], function (err, reply) {
assert.strictEqual('abcdefghij', reply[0].toString());
return done(err);
});
});
it('allows keys to be specified that have not yet been set', function (done) {
client.HMGET(hash, 'missing thing', 'another missing thing', function (err, reply) {
client.hmget(hash, 'missing thing', 'another missing thing', function (err, reply) {
assert.strictEqual(null, reply[0]);
assert.strictEqual(null, reply[1]);
return done(err);

View File

@@ -21,8 +21,8 @@ describe("The 'hmset' method", function () {
});
it('handles redis-style syntax', function (done) {
client.HMSET(hash, '0123456789', 'abcdefghij', 'some manner of key', 'a type of value', 'otherTypes', 555, helper.isString('OK'));
client.HGETALL(hash, function (err, obj) {
client.hmset(hash, '0123456789', 'abcdefghij', 'some manner of key', 'a type of value', 'otherTypes', 555, helper.isString('OK'));
client.hgetall(hash, function (err, obj) {
assert.equal(obj['0123456789'], 'abcdefghij');
assert.equal(obj['some manner of key'], 'a type of value');
return done(err);
@@ -31,7 +31,7 @@ describe("The 'hmset' method", function () {
it('handles object-style syntax', function (done) {
client.hmset(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}, helper.isString('OK'));
client.HGETALL(hash, function (err, obj) {
client.hgetall(hash, function (err, obj) {
assert.equal(obj['0123456789'], 'abcdefghij');
assert.equal(obj['some manner of key'], 'a type of value');
return done(err);
@@ -39,8 +39,8 @@ describe("The 'hmset' method", function () {
});
it('handles object-style syntax and the key being a number', function (done) {
client.HMSET(231232, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}, undefined);
client.HGETALL(231232, function (err, obj) {
client.hmset(231232, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}, undefined);
client.hgetall(231232, function (err, obj) {
assert.equal(obj['0123456789'], 'abcdefghij');
assert.equal(obj['some manner of key'], 'a type of value');
return done(err);
@@ -48,16 +48,16 @@ describe("The 'hmset' method", function () {
});
it('allows a numeric key', function (done) {
client.HMSET(hash, 99, 'banana', helper.isString('OK'));
client.HGETALL(hash, function (err, obj) {
client.hmset(hash, 99, 'banana', helper.isString('OK'));
client.hgetall(hash, function (err, obj) {
assert.equal(obj['99'], 'banana');
return done(err);
});
});
it('allows a numeric key without callback', function (done) {
client.HMSET(hash, 99, 'banana', 'test', 25);
client.HGETALL(hash, function (err, obj) {
client.hmset(hash, 99, 'banana', 'test', 25);
client.hgetall(hash, function (err, obj) {
assert.equal(obj['99'], 'banana');
assert.equal(obj.test, '25');
return done(err);
@@ -65,8 +65,8 @@ describe("The 'hmset' method", function () {
});
it('allows an array without callback', function (done) {
client.HMSET([hash, 99, 'banana', 'test', 25]);
client.HGETALL(hash, function (err, obj) {
client.hmset([hash, 99, 'banana', 'test', 25]);
client.hgetall(hash, function (err, obj) {
assert.equal(obj['99'], 'banana');
assert.equal(obj.test, '25');
return done(err);
@@ -74,8 +74,8 @@ describe("The 'hmset' method", function () {
});
it('allows an array and a callback', function (done) {
client.HMSET([hash, 99, 'banana', 'test', 25], helper.isString('OK'));
client.HGETALL(hash, function (err, obj) {
client.hmset([hash, 99, 'banana', 'test', 25], helper.isString('OK'));
client.hgetall(hash, function (err, obj) {
assert.equal(obj['99'], 'banana');
assert.equal(obj.test, '25');
return done(err);
@@ -83,8 +83,8 @@ describe("The 'hmset' method", function () {
});
it('allows a key plus array without callback', function (done) {
client.HMSET(hash, [99, 'banana', 'test', 25]);
client.HGETALL(hash, function (err, obj) {
client.hmset(hash, [99, 'banana', 'test', 25]);
client.hgetall(hash, function (err, obj) {
assert.equal(obj['99'], 'banana');
assert.equal(obj.test, '25');
return done(err);
@@ -92,8 +92,8 @@ describe("The 'hmset' method", function () {
});
it('allows a key plus array and a callback', function (done) {
client.HMSET(hash, [99, 'banana', 'test', 25], helper.isString('OK'));
client.HGETALL(hash, function (err, obj) {
client.hmset(hash, [99, 'banana', 'test', 25], helper.isString('OK'));
client.hgetall(hash, function (err, obj) {
assert.equal(obj['99'], 'banana');
assert.equal(obj.test, '25');
return done(err);
@@ -101,8 +101,8 @@ describe("The 'hmset' method", function () {
});
it('handles object-style syntax without callback', function (done) {
client.HMSET(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value'});
client.HGETALL(hash, function (err, obj) {
client.hmset(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value'});
client.hgetall(hash, function (err, obj) {
assert.equal(obj['0123456789'], 'abcdefghij');
assert.equal(obj['some manner of key'], 'a type of value');
return done(err);

View File

@@ -25,23 +25,23 @@ describe("The 'hset' method", function () {
var value = new Buffer('abcdefghij');
client.hset(hash, field, value, helper.isNumber(1));
client.HGET(hash, field, helper.isString(value.toString(), done));
client.hget(hash, field, helper.isString(value.toString(), done));
});
it('handles an empty value', function (done) {
var field = new Buffer('0123456789');
var value = new Buffer(0);
client.HSET(hash, field, value, helper.isNumber(1));
client.HGET([hash, field], helper.isString('', done));
client.hset(hash, field, value, helper.isNumber(1));
client.hget([hash, field], helper.isString('', done));
});
it('handles empty key and value', function (done) {
var field = new Buffer(0);
var value = new Buffer(0);
client.HSET([hash, field, value], function (err, res) {
client.hset([hash, field, value], function (err, res) {
assert.strictEqual(res, 1);
client.HSET(hash, field, value, helper.isNumber(0, done));
client.hset(hash, field, value, helper.isNumber(0, done));
});
});
@@ -60,7 +60,7 @@ describe("The 'hset' method", function () {
);
done();
});
client.HMSET(hash, field, value);
client.hmset(hash, field, value);
});
it('does not error when a buffer and date are set as values on the same hash', function (done) {
@@ -70,7 +70,7 @@ describe("The 'hset' method", function () {
var field2 = 'date';
var value2 = new Date();
client.HMSET(hash, field1, value1, field2, value2, helper.isString('OK', done));
client.hmset(hash, field1, value1, field2, value2, helper.isString('OK', done));
});
it('does not error when a buffer and date are set as fields on the same hash', function (done) {
@@ -80,7 +80,7 @@ describe("The 'hset' method", function () {
var value2 = 'date';
var field2 = new Date();
client.HMSET(hash, field1, value1, field2, value2, helper.isString('OK', done));
client.hmset(hash, field1, value1, field2, value2, helper.isString('OK', done));
});
afterEach(function () {

View File

@@ -15,7 +15,6 @@ describe("The 'incr' method", function () {
var client;
var key = 'ABOVE_SAFE_JAVASCRIPT_INTEGER';
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // Backwards compatible
afterEach(function () {
client.end(true);
@@ -35,27 +34,27 @@ describe("The 'incr' method", function () {
it('count above the safe integers as numbers', function (done) {
client = redis.createClient.apply(null, args);
// Set a value to the maximum safe allowed javascript number (2^53) - 1
client.set(key, MAX_SAFE_INTEGER, helper.isNotError());
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 1));
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 2));
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 3));
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 4));
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 5));
client.INCR(key, function (err, res) {
helper.isNumber(MAX_SAFE_INTEGER + 6)(err, res);
client.set(key, Number.MAX_SAFE_INTEGER, helper.isNotError());
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 1));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 2));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 3));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 4));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 5));
client.incr(key, function (err, res) {
helper.isNumber(Number.MAX_SAFE_INTEGER + 6)(err, res);
assert.strictEqual(typeof res, 'number');
});
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 7));
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 8));
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 9));
client.INCR(key, helper.isNumber(MAX_SAFE_INTEGER + 10, done));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 7));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 8));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 9));
client.incr(key, helper.isNumber(Number.MAX_SAFE_INTEGER + 10, done));
});
it('count above the safe integers as strings', function (done) {
args[2].stringNumbers = true;
client = redis.createClient.apply(null, args);
// Set a value to the maximum safe allowed javascript number (2^53)
client.set(key, MAX_SAFE_INTEGER, helper.isNotError());
client.set(key, Number.MAX_SAFE_INTEGER, helper.isNotError());
client.incr(key, helper.isString('9007199254740992'));
client.incr(key, helper.isString('9007199254740993'));
client.incr(key, helper.isString('9007199254740994'));

View File

@@ -22,7 +22,7 @@ describe("The 'keys' method", function () {
it('returns matching keys', function (done) {
client.mset(['test keys 1', 'test val 1', 'test keys 2', 'test val 2'], helper.isString('OK'));
client.KEYS('test keys*', function (err, results) {
client.keys('test keys*', function (err, results) {
assert.strictEqual(2, results.length);
assert.ok(~results.indexOf('test keys 1'));
assert.ok(~results.indexOf('test keys 2'));
@@ -54,7 +54,7 @@ describe("The 'keys' method", function () {
});
it('handles an empty response', function (done) {
client.KEYS(['users:*'], function (err, results) {
client.keys(['users:*'], function (err, results) {
assert.strictEqual(results.length, 0);
assert.ok(Array.isArray(results));
return done(err);

View File

@@ -23,7 +23,7 @@ describe("The 'mget' method", function () {
it('handles fetching multiple keys in argument form', function (done) {
client.mset(['mget keys 1', 'mget val 1', 'mget keys 2', 'mget val 2', 'mget keys 3', 'mget val 3'], helper.isString('OK'));
client.MGET('mget keys 1', 'mget keys 2', 'mget keys 3', function (err, results) {
client.mget('mget keys 1', 'mget keys 2', 'mget keys 3', function (err, results) {
assert.strictEqual(3, results.length);
assert.strictEqual('mget val 1', results[0].toString());
assert.strictEqual('mget val 2', results[1].toString());
@@ -42,7 +42,7 @@ describe("The 'mget' method", function () {
});
it('handles fetching multiple keys, when some keys do not exist', function (done) {
client.MGET('mget keys 1', ['some random shit', 'mget keys 2', 'mget keys 3'], function (err, results) {
client.mget('mget keys 1', ['some random shit', 'mget keys 2', 'mget keys 3'], function (err, results) {
assert.strictEqual(4, results.length);
assert.strictEqual('mget val 1', results[0].toString());
assert.strictEqual(null, results[1]);
@@ -53,7 +53,7 @@ describe("The 'mget' method", function () {
});
it('handles fetching multiple keys, when some keys do not exist promisified', function () {
return client.MGETAsync('mget keys 1', ['some random shit', 'mget keys 2', 'mget keys 3']).then(function (results) {
return client.mgetAsync('mget keys 1', ['some random shit', 'mget keys 2', 'mget keys 3']).then(function (results) {
assert.strictEqual(4, results.length);
assert.strictEqual('mget val 1', results[0].toString());
assert.strictEqual(null, results[1]);

View File

@@ -88,7 +88,7 @@ describe("The 'monitor' method", function () {
path: '/tmp/redis.sock'
});
monitorClient.MONITOR(function (err, res) {
monitorClient.monitor(function (err, res) {
assert.strictEqual(monitorClient.monitoring, true);
assert.strictEqual(res.inspect(), new Buffer('OK').inspect());
monitorClient.mget('hello', new Buffer('world'));
@@ -105,7 +105,7 @@ describe("The 'monitor' method", function () {
it('monitors reconnects properly and works with the offline queue', function (done) {
var called = false;
client.MONITOR(helper.isString('OK'));
client.monitor(helper.isString('OK'));
client.mget('hello', 'world');
client.on('monitor', function (time, args, rawOutput) {
assert.strictEqual(client.monitoring, true);
@@ -124,7 +124,7 @@ describe("The 'monitor' method", function () {
it('monitors reconnects properly and works with the offline queue in a batch statement', function (done) {
var called = false;
var multi = client.batch();
multi.MONITOR(helper.isString('OK'));
multi.monitor(helper.isString('OK'));
multi.mget('hello', 'world');
multi.exec(function (err, res) {
assert.deepEqual(res, ['OK', [null, null]]);
@@ -144,7 +144,7 @@ describe("The 'monitor' method", function () {
});
it('monitor activates even if the command could not be processed properly after a reconnect', function (done) {
client.MONITOR(function (err, res) {
client.monitor(function (err, res) {
assert.strictEqual(err.code, 'UNCERTAIN_STATE');
});
client.on('error', function (err) {}); // Ignore error here
@@ -175,7 +175,7 @@ describe("The 'monitor' method", function () {
];
var pub = redis.createClient();
pub.on('ready', function () {
client.MONITOR(function (err, res) {
client.monitor(function (err, res) {
assert.strictEqual(res, 'OK');
pub.get('foo', helper.isNull());
});

View File

@@ -20,7 +20,7 @@ describe("The 'msetnx' method", function () {
it('if any keys exist entire operation fails', function (done) {
client.mset(['mset1', 'val1', 'mset2', 'val2', 'mset3', 'val3'], helper.isString('OK'));
client.MSETNX(['mset3', 'val3', 'mset4', 'val4'], helper.isNumber(0));
client.msetnx(['mset3', 'val3', 'mset4', 'val4'], helper.isNumber(0));
client.exists(['mset4'], helper.isNumber(0, done));
});

View File

@@ -21,7 +21,7 @@ describe("The 'randomkey' method", function () {
it('returns a random key', function (done) {
client.mset(['test keys 1', 'test val 1', 'test keys 2', 'test val 2'], helper.isString('OK'));
client.RANDOMKEY([], function (err, results) {
client.randomkey([], function (err, results) {
assert.strictEqual(true, /test keys.+/.test(results));
return done(err);
});

View File

@@ -26,7 +26,7 @@ describe("The 'rename' method", function () {
it('removes the old key', function (done) {
client.set(['foo', 'bar'], helper.isString('OK'));
client.RENAME(['foo', 'new foo'], helper.isString('OK'));
client.rename(['foo', 'new foo'], helper.isString('OK'));
client.exists(['foo'], helper.isNumber(0, done));
});

View File

@@ -20,7 +20,7 @@ describe("The 'renamenx' method", function () {
it('renames the key if target does not yet exist', function (done) {
client.set('foo', 'bar', helper.isString('OK'));
client.RENAMENX('foo', 'foo2', helper.isNumber(1));
client.renamenx('foo', 'foo2', helper.isNumber(1));
client.exists('foo', helper.isNumber(0));
client.exists(['foo2'], helper.isNumber(1, done));
});

View File

@@ -20,7 +20,7 @@ describe("The 'sadd' method", function () {
});
it('allows a single value to be added to the set', function (done) {
client.SADD('set0', 'member0', helper.isNumber(1));
client.sadd('set0', 'member0', helper.isNumber(1));
client.smembers('set0', function (err, res) {
assert.ok(~res.indexOf('member0'));
return done(err);
@@ -29,7 +29,7 @@ describe("The 'sadd' method", function () {
it('does not add the same value to the set twice', function (done) {
client.sadd('set0', 'member0', helper.isNumber(1));
client.SADD('set0', 'member0', helper.isNumber(0, done));
client.sadd('set0', 'member0', helper.isNumber(0, done));
});
it('allows multiple values to be added to the set', function (done) {

View File

@@ -47,7 +47,7 @@ describe("The 'select' method", function () {
it('changes the database and calls the callback', function (done) {
// default value of null means database 0 will be used.
assert.strictEqual(client.selectedDb, undefined, 'default db should be undefined');
var buffering = client.SELECT(1, function (err, res) {
var buffering = client.select(1, function (err, res) {
helper.isNotError()(err, res);
assert.strictEqual(client.selectedDb, 1, 'db should be 1 after select');
done();

View File

@@ -54,7 +54,7 @@ describe("The 'set' method", function () {
describe('and a callback is specified', function () {
describe('with valid parameters', function () {
it('sets the value correctly', function (done) {
client.SET(key, value, function (err, res) {
client.set(key, value, function (err, res) {
helper.isNotError()(err, res);
client.get(key, function (err, res) {
helper.isString(value)(err, res);

View File

@@ -19,7 +19,7 @@ describe("The 'setnx' method", function () {
});
it('sets key if it does not have a value', function (done) {
client.SETNX('foo', 'banana', helper.isNumber(1));
client.setnx('foo', 'banana', helper.isNumber(1));
client.get('foo', helper.isString('banana', done));
});

View File

@@ -28,7 +28,7 @@ describe("The 'sinter' method", function () {
client.sadd('sb', 'c', helper.isNumber(1));
client.sadd('sb', 'd', helper.isNumber(1));
client.SINTER('sa', 'sb', function (err, intersection) {
client.sinter('sa', 'sb', function (err, intersection) {
assert.equal(intersection.length, 2);
assert.deepEqual(intersection.sort(), [ 'b', 'c' ]);
return done(err);

View File

@@ -24,7 +24,7 @@ describe("The 'sismember' method", function () {
it('returns 1 if the value is in the set', function (done) {
client.sadd('foo', 'banana', helper.isNumber(1));
client.SISMEMBER('foo', 'banana', helper.isNumber(1, done));
client.sismember('foo', 'banana', helper.isNumber(1, done));
});
afterEach(function () {

View File

@@ -24,7 +24,7 @@ describe("The 'slowlog' method", function () {
client.slowlog('reset', helper.isString('OK'));
client.set('foo', 'bar', helper.isString('OK'));
client.get('foo', helper.isString('bar'));
client.SLOWLOG('get', function (err, res) {
client.slowlog('get', function (err, res) {
assert.equal(res.length, 3);
assert.equal(res[0][3].length, 2);
assert.deepEqual(res[1][3], ['set', 'foo', 'bar']);

View File

@@ -27,7 +27,7 @@ describe("The 'smove' method", function () {
it('does not move a value if it does not exist in the first set', function (done) {
client.sadd('foo', 'x', helper.isNumber(1));
client.SMOVE('foo', 'bar', 'y', helper.isNumber(0));
client.smove('foo', 'bar', 'y', helper.isNumber(0));
client.sismember('foo', 'y', helper.isNumber(0));
client.sismember('bar', 'y', helper.isNumber(0, done));
});

View File

@@ -57,7 +57,7 @@ describe("The 'sort' method", function () {
});
it('sorts in descending alphabetical order', function (done) {
client.SORT('y', 'desc', 'alpha', function (err, sorted) {
client.sort('y', 'desc', 'alpha', function (err, sorted) {
assert.deepEqual(sorted, ['d', 'c', 'b', 'a']);
return done(err);
});

View File

@@ -26,12 +26,12 @@ describe("The 'srem' method", function () {
});
it('handles attempting to remove a missing value', function (done) {
client.SREM('set0', 'member0', helper.isNumber(0, done));
client.srem('set0', 'member0', helper.isNumber(0, done));
});
it('allows multiple values to be removed', function (done) {
client.sadd('set0', ['member0', 'member1', 'member2'], helper.isNumber(3));
client.SREM('set0', ['member1', 'member2'], helper.isNumber(2));
client.srem('set0', ['member1', 'member2'], helper.isNumber(2));
client.smembers('set0', function (err, res) {
assert.strictEqual(res.length, 1);
assert.ok(~res.indexOf('member0'));
@@ -51,7 +51,7 @@ describe("The 'srem' method", function () {
it('handles a value missing from the set of values being removed', function (done) {
client.sadd(['set0', 'member0', 'member1', 'member2'], helper.isNumber(3));
client.SREM(['set0', 'member3', 'member4'], helper.isNumber(0));
client.srem(['set0', 'member3', 'member4'], helper.isNumber(0));
client.smembers('set0', function (err, res) {
assert.strictEqual(res.length, 3);
assert.ok(~res.indexOf('member0'));

View File

@@ -22,7 +22,7 @@ describe("The 'ttl' method", function () {
it('returns the current ttl on a key', function (done) {
client.set(['ttl key', 'ttl val'], helper.isString('OK'));
client.expire(['ttl key', '100'], helper.isNumber(1));
client.TTL(['ttl key'], function (err, ttl) {
client.ttl(['ttl key'], function (err, ttl) {
assert(ttl >= 99);
assert(ttl <= 100);
done(err);

View File

@@ -20,7 +20,7 @@ describe("The 'type' method", function () {
it('reports string type', function (done) {
client.set(['string key', 'should be a string'], helper.isString('OK'));
client.TYPE(['string key'], helper.isString('string', done));
client.type(['string key'], helper.isString('string', done));
});
it('reports list type', function (done) {
@@ -30,21 +30,21 @@ describe("The 'type' method", function () {
it('reports set type', function (done) {
client.sadd(['set key', 'should be a set'], helper.isNumber(1));
client.TYPE(['set key'], helper.isString('set', done));
client.type(['set key'], helper.isString('set', done));
});
it('reports zset type', function (done) {
client.zadd('zset key', ['10.0', 'should be a zset'], helper.isNumber(1));
client.TYPE(['zset key'], helper.isString('zset', done));
client.type(['zset key'], helper.isString('zset', done));
});
it('reports hash type', function (done) {
client.hset('hash key', 'hashtest', 'should be a hash', helper.isNumber(1));
client.TYPE(['hash key'], helper.isString('hash', done));
client.type(['hash key'], helper.isString('hash', done));
});
it('reports none for null key', function (done) {
client.TYPE('not here yet', helper.isString('none', done));
client.type('not here yet', helper.isString('none', done));
});
afterEach(function () {

View File

@@ -26,7 +26,7 @@ describe("The 'watch' method", function () {
});
it('does not execute transaction if watched key was modified prior to execution', function (done) {
client.WATCH(watched);
client.watch(watched);
client.incr(watched);
var multi = client.multi();
multi.incr(watched);

View File

@@ -319,7 +319,7 @@ describe("The 'multi' method", function () {
it('roles back a transaction when one command in a sequence of commands fails', function (done) {
var multi1, multi2;
// Provoke an error at queue time
multi1 = client.MULTI();
multi1 = client.multi();
multi1.mset('multifoo', '10', 'multibar', '20', helper.isString('OK'));
multi1.set('foo2', helper.isError());
@@ -403,7 +403,7 @@ describe("The 'multi' method", function () {
['hmset', arr3, helper.isString('OK')],
['hmset', now, {123456789: 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}],
['hmset', 'key2', {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 999}, helper.isString('OK')],
['HMSET', 'multihmset', ['multibar', 'multibaz'], undefined], // undefined is used as a explicit not set callback variable
['hmset', 'multihmset', ['multibar', 'multibaz'], undefined], // undefined is used as a explicit not set callback variable
['hmset', 'multihmset', ['multibar', 'multibaz'], helper.isString('OK')],
])
.hmget(now, 123456789, 'otherTypes')
@@ -625,7 +625,7 @@ describe("The 'multi' method", function () {
test = true;
};
multi.set('baz', 'binary');
multi.EXEC_ATOMIC();
multi.execAtomic();
assert(test);
});

View File

@@ -21,8 +21,8 @@ describe('The nodeRedis client', function () {
// Check that every entry RedisClient entry has a correspondend Multi entry
assert.strictEqual(clientPrototype.filter(function (entry) {
return multiPrototype.indexOf(entry.replace('RedisClient', 'Multi')) === -1;
}).length, 4); // multi and batch are included too
assert.strictEqual(clientPrototype.length, multiPrototype.length + 4);
}).length, 3); // multi and batch are included too
assert.strictEqual(clientPrototype.length, multiPrototype.length + 3);
// Check that all entries exist in uppercase and in lowercase variants
assert.strictEqual(data.match(/(\n| = )RedisClient\.prototype.[a-z_]+/g).length * 2, clientPrototype.length);
done();