You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
tests: fix buffer test (failed due to new parser) & remove unused node feature checks (< 4)
This commit is contained in:
12
index.js
12
index.js
@@ -20,11 +20,6 @@ var SUBSCRIBE_COMMANDS = {
|
||||
punsubscribe: true
|
||||
};
|
||||
|
||||
// Newer Node.js versions > 0.10 return the EventEmitter right away and using .EventEmitter was deprecated
|
||||
if (typeof EventEmitter !== 'function') {
|
||||
EventEmitter = EventEmitter.EventEmitter;
|
||||
}
|
||||
|
||||
function noop () {}
|
||||
|
||||
function handle_detect_buffers_reply (reply, command, buffer_args) {
|
||||
@@ -153,7 +148,6 @@ function RedisClient (options, stream) {
|
||||
this.server_info = {};
|
||||
this.auth_pass = options.auth_pass || options.password;
|
||||
this.selected_db = options.db; // Save the selected db here, used when reconnecting
|
||||
this.old_state = null;
|
||||
this.fire_strings = true; // Determine if strings or buffers should be written to the stream
|
||||
this.pipeline = false;
|
||||
this.sub_commands_left = 0;
|
||||
@@ -175,12 +169,6 @@ function RedisClient (options, stream) {
|
||||
'If you want to keep on listening to this event please listen to the stream drain event directly.'
|
||||
);
|
||||
} else if ((event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer') && !this.buffers && !this.message_buffers) {
|
||||
if (this.reply_parser.name !== 'javascript') {
|
||||
return this.warn(
|
||||
'You attached the "' + event + '" listener without the returnBuffers option set to true.\n' +
|
||||
'Please use the JavaScript parser or set the returnBuffers option to true to return buffers.'
|
||||
);
|
||||
}
|
||||
this.reply_parser.optionReturnBuffers = true;
|
||||
this.message_buffers = true;
|
||||
this.handle_reply = handle_detect_buffers_reply;
|
||||
|
@@ -4,18 +4,6 @@ var commands = require('redis-commands');
|
||||
var Multi = require('./multi');
|
||||
var RedisClient = require('../').RedisClient;
|
||||
var Command = require('./command');
|
||||
// Feature detect if a function may change it's name
|
||||
var changeFunctionName = (function () {
|
||||
var fn = function abc () {};
|
||||
try {
|
||||
Object.defineProperty(fn, 'name', {
|
||||
value: 'foobar'
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}());
|
||||
|
||||
var addCommand = function (command) {
|
||||
// Some rare Redis commands use special characters in their command name
|
||||
@@ -61,12 +49,10 @@ var addCommand = function (command) {
|
||||
if (commandName !== command) {
|
||||
RedisClient.prototype[commandName.toUpperCase()] = RedisClient.prototype[commandName] = RedisClient.prototype[command];
|
||||
}
|
||||
if (changeFunctionName) {
|
||||
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
||||
value: commandName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Do not override existing functions
|
||||
if (!Multi.prototype[command]) {
|
||||
@@ -108,12 +94,10 @@ var addCommand = function (command) {
|
||||
if (commandName !== command) {
|
||||
Multi.prototype[commandName.toUpperCase()] = Multi.prototype[commandName] = Multi.prototype[command];
|
||||
}
|
||||
if (changeFunctionName) {
|
||||
Object.defineProperty(Multi.prototype[command], 'name', {
|
||||
value: commandName
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
commands.list.forEach(addCommand);
|
||||
|
@@ -524,6 +524,8 @@ describe('publish/subscribe', function () {
|
||||
assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect());
|
||||
sub.quit(end);
|
||||
});
|
||||
// Either message_buffers or buffers has to be true, but not both at the same time
|
||||
assert.notStrictEqual(sub.message_buffers, sub.buffers);
|
||||
});
|
||||
var batch = sub.batch();
|
||||
batch.psubscribe('*');
|
||||
|
Reference in New Issue
Block a user