Skip to content

Commit

Permalink
Merge a54eb99 into 27bb93a
Browse files Browse the repository at this point in the history
  • Loading branch information
TK-one committed Aug 6, 2018
2 parents 27bb93a + a54eb99 commit 261822e
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 92 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -1102,4 +1102,4 @@ require('./lib/individualCommands');
require('./lib/extendedApi');

//enables adding new commands (for modules and new commands)
exports.addCommand = exports.add_command = require('./lib/commands');
exports.addCommand = exports.add_command = require('./lib/commands');
68 changes: 34 additions & 34 deletions test/batch.spec.js
Expand Up @@ -187,12 +187,12 @@ describe("The 'batch' method", function () {
['del', 'some set'],
['smembers', 'some set', undefined] // The explicit undefined is handled as a callback that is undefined
])
.scard('some set')
.exec(function (err, replies) {
assert.strictEqual(4, replies[0].length);
assert.strictEqual(0, replies[2].length);
return done();
});
.scard('some set')
.exec(function (err, replies) {
assert.strictEqual(4, replies[0].length);
assert.strictEqual(0, replies[2].length);
return done();
});
});

it('allows multiple operations to be performed using constructor with all kinds of syntax', function (done) {
Expand All @@ -213,29 +213,29 @@ describe("The 'batch' method", function () {
['HMSET', 'batchhmset', ['batchbar', 'batchbaz']],
['hmset', 'batchhmset', ['batchbar', 'batchbaz'], helper.isString('OK')],
])
.hmget(now, 123456789, 'otherTypes')
.hmget('key2', arr2, function noop () {})
.hmget(['batchhmset2', 'some manner of key', 'batchbar3'])
.mget('batchfoo2', ['batchfoo3', 'batchfoo'], function (err, res) {
assert.strictEqual(res[0], 'batchbar2');
assert.strictEqual(res[1], 'batchbar3');
assert.strictEqual(res[2], null);
})
.exec(function (err, replies) {
assert.equal(arr.length, 3);
assert.equal(arr2.length, 2);
assert.equal(arr3.length, 3);
assert.equal(arr4.length, 3);
assert.strictEqual(null, err);
assert.equal(replies[10][1], '555');
assert.equal(replies[11][0], 'a type of value');
assert.strictEqual(replies[12][0], null);
assert.equal(replies[12][1], 'test');
assert.equal(replies[13][0], 'batchbar2');
assert.equal(replies[13].length, 3);
assert.equal(replies.length, 14);
return done();
});
.hmget(now, 123456789, 'otherTypes')
.hmget('key2', arr2, function noop () {})
.hmget(['batchhmset2', 'some manner of key', 'batchbar3'])
.mget('batchfoo2', ['batchfoo3', 'batchfoo'], function (err, res) {
assert.strictEqual(res[0], 'batchbar2');
assert.strictEqual(res[1], 'batchbar3');
assert.strictEqual(res[2], null);
})
.exec(function (err, replies) {
assert.equal(arr.length, 3);
assert.equal(arr2.length, 2);
assert.equal(arr3.length, 3);
assert.equal(arr4.length, 3);
assert.strictEqual(null, err);
assert.equal(replies[10][1], '555');
assert.equal(replies[11][0], 'a type of value');
assert.strictEqual(replies[12][0], null);
assert.equal(replies[12][1], 'test');
assert.equal(replies[13][0], 'batchbar2');
assert.equal(replies[13].length, 3);
assert.equal(replies.length, 14);
return done();
});
});

it('converts a non string key to a string', function (done) {
Expand Down Expand Up @@ -316,11 +316,11 @@ describe("The 'batch' method", function () {
['mget', ['batchfoo', 'some', 'random value', 'keys']],
['incr', 'batchfoo']
])
.exec(function (err, replies) {
assert.strictEqual(replies.length, 2);
assert.strictEqual(replies[0].length, 4);
return done();
});
.exec(function (err, replies) {
assert.strictEqual(replies.length, 2);
assert.strictEqual(replies[0].length, 4);
return done();
});
});

it('allows multiple operations to be performed on a hash', function (done) {
Expand Down
4 changes: 2 additions & 2 deletions test/commands/select.spec.js
Expand Up @@ -72,7 +72,7 @@ describe("The 'select' method", function () {
assert.strictEqual(client.selected_db, undefined, 'default db should be undefined');
client.select(9999, function (err) {
assert.equal(err.code, 'ERR');
assert((err.message == 'ERR DB index is out of range' || err.message == 'ERR invalid DB index'));
assert((err.message === 'ERR DB index is out of range' || err.message === 'ERR invalid DB index'));
done();
});
});
Expand All @@ -97,7 +97,7 @@ describe("The 'select' method", function () {

client.on('error', function (err) {
assert.strictEqual(err.command, 'SELECT');
assert((err.message == 'ERR DB index is out of range' || err.message == 'ERR invalid DB index'));
assert((err.message === 'ERR DB index is out of range' || err.message === 'ERR invalid DB index'));
done();
});

Expand Down
2 changes: 1 addition & 1 deletion test/connection.spec.js
Expand Up @@ -376,7 +376,7 @@ describe('connection tests', function () {
var add = process.platform !== 'win32' ? 15 : 200;
var now = Date.now();
assert(now - time < connect_timeout + add, 'The real timeout time should be below ' + (connect_timeout + add) + 'ms but is: ' + (now - time));
// Timers sometimes trigger early (e.g. 1ms to early)
// Timers sometimes trigger early (e.g. 1ms to early)
assert(now - time >= connect_timeout - 5, 'The real timeout time should be above ' + connect_timeout + 'ms, but it is: ' + (now - time));
done();
});
Expand Down
25 changes: 13 additions & 12 deletions test/lib/redis-process.js
Expand Up @@ -27,20 +27,21 @@ function waitForRedis (available, cb, port) {
bluebird.join(
tcpPortUsed.check(port, '127.0.0.1'),
tcpPortUsed.check(port, '::1'),
function (ipV4, ipV6) {
if (ipV6 === available && ipV4 === available) {
if (fs.existsSync(socket) === available) {
clearInterval(id);
return cb();
function (ipV4, ipV6) {
if (ipV6 === available && ipV4 === available) {
if (fs.existsSync(socket) === available) {
clearInterval(id);
return cb();
}
// The same message applies for can't stop but we ignore that case
throw new Error('Port ' + port + ' is already in use. Tests can\'t start.\n');
}
// The same message applies for can't stop but we ignore that case
throw new Error('Port ' + port + ' is already in use. Tests can\'t start.\n');
}
if (Date.now() - time > 6000) {
throw new Error('Redis could not start on port ' + (port || config.PORT) + '\n');
if (Date.now() - time > 6000) {
throw new Error('Redis could not start on port ' + (port || config.PORT) + '\n');
}
running = false;
}
running = false;
}).catch(function (err) {
).catch(function (err) {
console.error('\x1b[31m' + err.stack + '\x1b[0m\n');
process.exit(1);
});
Expand Down
70 changes: 35 additions & 35 deletions test/multi.spec.js
Expand Up @@ -379,12 +379,12 @@ describe("The 'multi' method", function () {
['del', 'some set'],
['smembers', 'some set']
])
.scard('some set')
.exec(function (err, replies) {
assert.strictEqual(4, replies[0].length);
assert.strictEqual(0, replies[2].length);
return done();
});
.scard('some set')
.exec(function (err, replies) {
assert.strictEqual(4, replies[0].length);
assert.strictEqual(0, replies[2].length);
return done();
});
});

it('allows multiple operations to be performed using constructor with all kinds of syntax', function (done) {
Expand All @@ -406,30 +406,30 @@ describe("The 'multi' method", function () {
['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')
.hmget('key2', arr2, function noop () {})
.hmget(['multihmset2', 'some manner of key', 'multibar3'])
.mget('multifoo2', ['multifoo3', 'multifoo'], function (err, res) {
assert(res[0], 'multifoo3');
assert(res[1], 'multifoo');
called = true;
})
.exec(function (err, replies) {
assert(called);
assert.equal(arr.length, 3);
assert.equal(arr2.length, 2);
assert.equal(arr3.length, 3);
assert.equal(arr4.length, 3);
assert.strictEqual(null, err);
assert.equal(replies[10][1], '555');
assert.equal(replies[11][0], 'a type of value');
assert.strictEqual(replies[12][0], null);
assert.equal(replies[12][1], 'test');
assert.equal(replies[13][0], 'multibar2');
assert.equal(replies[13].length, 3);
assert.equal(replies.length, 14);
return done();
});
.hmget(now, 123456789, 'otherTypes')
.hmget('key2', arr2, function noop () {})
.hmget(['multihmset2', 'some manner of key', 'multibar3'])
.mget('multifoo2', ['multifoo3', 'multifoo'], function (err, res) {
assert(res[0], 'multifoo3');
assert(res[1], 'multifoo');
called = true;
})
.exec(function (err, replies) {
assert(called);
assert.equal(arr.length, 3);
assert.equal(arr2.length, 2);
assert.equal(arr3.length, 3);
assert.equal(arr4.length, 3);
assert.strictEqual(null, err);
assert.equal(replies[10][1], '555');
assert.equal(replies[11][0], 'a type of value');
assert.strictEqual(replies[12][0], null);
assert.equal(replies[12][1], 'test');
assert.equal(replies[13][0], 'multibar2');
assert.equal(replies[13].length, 3);
assert.equal(replies.length, 14);
return done();
});
});

it('converts a non string key to a string', function (done) {
Expand Down Expand Up @@ -505,11 +505,11 @@ describe("The 'multi' method", function () {
['mget', ['multifoo', 'some', 'random value', 'keys']],
['incr', 'multifoo']
])
.exec(function (err, replies) {
assert.strictEqual(replies.length, 2);
assert.strictEqual(replies[0].length, 4);
return done();
});
.exec(function (err, replies) {
assert.strictEqual(replies.length, 2);
assert.strictEqual(replies[0].length, 4);
return done();
});
});

it('allows multiple operations to be performed on a hash', function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/node_redis.spec.js
Expand Up @@ -122,7 +122,7 @@ describe('The node_redis client', function () {
it('check if all new options replaced the old ones', function (done) {
client.selected_db = 1;
var client2 = client.duplicate({
db: 2,
db: 2,
no_ready_check: true
});
assert(client.connected);
Expand Down
12 changes: 6 additions & 6 deletions test/tls.spec.js
Expand Up @@ -110,17 +110,17 @@ describe('TLS connection tests', function () {
});

describe('using rediss as url protocol', function (done) {
var tls_connect = tls.connect
var tls_connect = tls.connect;
beforeEach(function () {
tls.connect = function (options) {
options = utils.clone(options)
options = utils.clone(options);
options.ca = tls_options.ca;
return tls_connect.call(tls, options);
}
})
};
});
afterEach(function () {
tls.connect = tls_connect;
})
});
it('connect with tls when rediss is used as the protocol', function (done) {
if (skip) this.skip();
client = redis.createClient('rediss://localhost:' + tls_port);
Expand All @@ -129,7 +129,7 @@ describe('TLS connection tests', function () {
client.set('foo', 'bar');
client.get('foo', helper.isString('bar', done));
});
})
});

it('fails to connect because the cert is not correct', function (done) {
if (skip) this.skip();
Expand Down

0 comments on commit 261822e

Please sign in to comment.