You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Add tests to make sure no invalid function names get exported
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
## v.2.6.1 - 02 Jun, 2016
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed invalid function name being exported
|
||||||
|
|
||||||
## v.2.6.0 - 01 Jun, 2016
|
## v.2.6.0 - 01 Jun, 2016
|
||||||
|
|
||||||
In addition to the pre-releases the following changes exist in v.2.6.0:
|
In addition to the pre-releases the following changes exist in v.2.6.0:
|
||||||
|
@@ -21,6 +21,9 @@ var changeFunctionName = (function () {
|
|||||||
// that provided a functionality to add new commands to the client
|
// that provided a functionality to add new commands to the client
|
||||||
|
|
||||||
commands.list.forEach(function (command) {
|
commands.list.forEach(function (command) {
|
||||||
|
|
||||||
|
// Some rare Redis commands use special characters in their command name
|
||||||
|
// Convert those to a underscore to prevent using invalid function names
|
||||||
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');
|
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');
|
||||||
|
|
||||||
// Do not override existing functions
|
// Do not override existing functions
|
||||||
|
@@ -9,6 +9,7 @@ var helper = require('./helper');
|
|||||||
var utils = require('../lib/utils');
|
var utils = require('../lib/utils');
|
||||||
var fork = require('child_process').fork;
|
var fork = require('child_process').fork;
|
||||||
var redis = config.redis;
|
var redis = config.redis;
|
||||||
|
var client;
|
||||||
|
|
||||||
describe('The node_redis client', function () {
|
describe('The node_redis client', function () {
|
||||||
|
|
||||||
@@ -29,10 +30,18 @@ describe('The node_redis client', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('convert minus to underscore in Redis function names', function (done) {
|
||||||
|
var names = Object.keys(redis.RedisClient.prototype);
|
||||||
|
client = redis.createClient();
|
||||||
|
for (var i = 0; i < names.length; i++) {
|
||||||
|
assert(/^([a-zA-Z_][a-zA-Z_0-9]*)?$/.test(client[names[i]].name));
|
||||||
|
}
|
||||||
|
client.quit(done);
|
||||||
|
});
|
||||||
|
|
||||||
helper.allTests(function (parser, ip, args) {
|
helper.allTests(function (parser, ip, args) {
|
||||||
|
|
||||||
describe('using ' + parser + ' and ' + ip, function () {
|
describe('using ' + parser + ' and ' + ip, function () {
|
||||||
var client;
|
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end(true);
|
client.end(true);
|
||||||
|
Reference in New Issue
Block a user