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

Improve coverage; make tests ready for Redis 3.2

Add command sanity check
This commit is contained in:
Ruben Bridgewater
2016-04-21 02:56:06 +02:00
parent eae16938cd
commit ce1678c778
9 changed files with 79 additions and 24 deletions

View File

@@ -1,6 +1,8 @@
'use strict';
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var config = require('./lib/config');
var helper = require('./helper');
var utils = require('../lib/utils');
@@ -9,6 +11,23 @@ var redis = config.redis;
describe('The node_redis client', function () {
it('individual commands sanity check', function (done) {
// All commands should work the same in multi context or without
// Therefor individual commands always have to be handled in both cases
fs.readFile(path.resolve(__dirname, '../lib/individualCommands.js'), 'utf8', function (err, data) {
var client_prototype = data.match(/(\n| = )RedisClient\.prototype.[a-zA-Z_]+/g);
var multi_prototype = data.match(/(\n| = )Multi\.prototype\.[a-zA-Z_]+/g);
// Check that every entry RedisClient entry has a correspondend Multi entry
assert.strictEqual(client_prototype.filter(function (entry) {
return multi_prototype.indexOf(entry.replace('RedisClient', 'Multi')) === -1;
}).length, 4); // multi and batch are included too
assert.strictEqual(client_prototype.length, multi_prototype.length + 4);
// Check that all entries exist in uppercase and in lowercase variants
assert.strictEqual(data.match(/(\n| = )RedisClient\.prototype.[a-z_]+/g).length * 2, client_prototype.length);
done();
});
});
helper.allTests(function (parser, ip, args) {
describe('using ' + parser + ' and ' + ip, function () {