Skip to content

Commit fbca5cd

Browse files
authored
Upgrade node and dependencies (#1578)
* upgrade workflow actions * fix setup-node version * change redis-64 version to 3.0.503 * fix "no password is set" for redis6, fix tests to work with redis6, add redis6 to workflows * do not use assert.match (was added only at v13.6.0 & v12.16.0) * fix errors.subscribeUnsubscribeOnly regex * fix invaliodPassword typo * send --save "" to redis-server in tests * upgrade dependencies, set node minimum version to 10, use current LTS versions in tests and benchmark workflows * change windows tests too * revert mocha back to ^4.1.0 * fix for f552850 - revert mocha back to ^4.1.0 * fix some tests and upgrade mocha * fix two more tests * try to fix tests in windows * upgrade denque and redis-commands ref #1575 * replace `new Buffer` (deprecated) with `Buffer.from` * Buffer.from(0) should be Buffer.alloc(0)
1 parent 2188744 commit fbca5cd

22 files changed

+129
-98
lines changed

.github/workflows/benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
node-version: [8.x, 10.x, 12.x]
13-
redis-version: [5]
12+
node-version: [10.x, 12.x, 14.x, 15.x]
13+
redis-version: [5.x, 6.x]
1414

1515
steps:
1616
- uses: actions/[email protected]

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
node-version: [6.x, 8.x, 10.x, 12.x]
13-
redis-version: [4.x, 5.x]
12+
node-version: [10.x, 12.x, 14.x, 15.x]
13+
redis-version: [4.x, 5.x, 6.x]
1414

1515
steps:
1616
- uses: actions/[email protected]

.github/workflows/tests_windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
node-version: [6.x, 8.x, 10.x, 12.x]
12+
node-version: [10.x, 12.x, 14.x, 15.x]
1313
steps:
1414
- uses: actions/[email protected]
1515
with:

lib/individualCommands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var utils = require('./utils');
44
var debug = require('./debug');
55
var Multi = require('./multi');
66
var Command = require('./command');
7-
var no_password_is_set = /no password is set/;
7+
var no_password_is_set = /no password is set|called without any password configured/;
88
var loading = /LOADING/;
99
var RedisClient = require('../').RedisClient;
1010

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@
3030
"coveralls": "nyc report --reporter=text-lcov | coveralls",
3131
"coverage": "nyc report --reporter=html",
3232
"benchmark": "node benchmarks/multi_bench.js",
33-
"test": "nyc --cache mocha ./test/*.js ./test/commands/*.js --timeout=8000 && npm run coverage",
33+
"test": "nyc --cache mocha ./test/*.spec.js ./test/commands/*.spec.js --timeout=8000 && npm run coverage",
3434
"lint": "eslint .",
3535
"lint:fix": "eslint . --fix",
3636
"lint:report": "eslint --output-file=eslint-report.json --format=json .",
3737
"compare": "node benchmarks/diff_multi_bench_output.js beforeBench.txt afterBench.txt"
3838
},
3939
"dependencies": {
40-
"denque": "^1.4.1",
41-
"redis-commands": "^1.5.0",
40+
"denque": "^1.5.0",
41+
"redis-commands": "^1.7.0",
4242
"redis-errors": "^1.2.0",
4343
"redis-parser": "^3.0.0"
4444
},
4545
"engines": {
46-
"node": ">=6"
46+
"node": ">=10"
4747
},
4848
"devDependencies": {
49-
"prettier": "^1.19.1",
5049
"bluebird": "^3.7.2",
51-
"coveralls": "^2.11.2",
52-
"eslint": "^6.8.0",
50+
"coveralls": "^3.1.0",
51+
"cross-spawn": "^7.0.3",
52+
"eslint": "^7.21.0",
5353
"intercept-stdout": "~0.1.2",
5454
"metrics": "^0.1.21",
55-
"mocha": "^4.1.0",
56-
"nyc": "^14.1.1",
55+
"mocha": "^8.3.0",
56+
"nyc": "^15.1.0",
57+
"prettier": "^2.2.1",
5758
"tcp-port-used": "^1.0.1",
58-
"uuid": "^3.4.0",
59-
"cross-spawn": "^6.0.5"
59+
"uuid": "^8.3.2"
6060
},
6161
"repository": {
6262
"type": "git",

test/auth.spec.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var assert = require('assert');
44
var config = require('./lib/config');
55
var helper = require('./helper');
6+
var errors = require('./errors');
67
var redis = config.redis;
78

89
if (process.platform === 'win32') {
@@ -70,11 +71,13 @@ describe('client authentication', function () {
7071
it('emits error when auth is bad without callback', function (done) {
7172
if (helper.redisProcess().spawnFailed()) this.skip();
7273

73-
client = redis.createClient.apply(null, args);
74+
client = redis.createClient.apply(null, config.configureClient(ip, {
75+
no_ready_check: true
76+
}));
7477

7578
client.once('error', function (err) {
7679
assert.strictEqual(err.command, 'AUTH');
77-
assert.ok(/ERR invalid password/.test(err.message));
80+
assert.ok(errors.invalidPassword.test(err.message));
7881
return done();
7982
});
8083

@@ -84,11 +87,13 @@ describe('client authentication', function () {
8487
it('returns an error when auth is bad (empty string) with a callback', function (done) {
8588
if (helper.redisProcess().spawnFailed()) this.skip();
8689

87-
client = redis.createClient.apply(null, args);
90+
client = redis.createClient.apply(null, config.configureClient(ip, {
91+
no_ready_check: true
92+
}));
8893

8994
client.auth('', function (err, res) {
9095
assert.strictEqual(err.command, 'AUTH');
91-
assert.ok(/ERR invalid password/.test(err.message));
96+
assert.ok(errors.invalidPassword.test(err.message));
9297
done();
9398
});
9499
});
@@ -190,10 +195,12 @@ describe('client authentication', function () {
190195
it('should return an error if the password is not correct and a callback has been provided', function (done) {
191196
if (helper.redisProcess().spawnFailed()) this.skip();
192197

193-
client = redis.createClient.apply(null, args);
198+
client = redis.createClient.apply(null, config.configureClient(ip, {
199+
no_ready_check: true
200+
}));
194201
var async = true;
195202
client.auth('undefined', function (err, res) {
196-
assert.strictEqual(err.message, 'ERR invalid password');
203+
assert.ok(errors.invalidPassword.test(err.message));
197204
assert.strictEqual(err.command, 'AUTH');
198205
assert.strictEqual(res, undefined);
199206
async = false;
@@ -205,9 +212,11 @@ describe('client authentication', function () {
205212
it('should emit an error if the password is not correct and no callback has been provided', function (done) {
206213
if (helper.redisProcess().spawnFailed()) this.skip();
207214

208-
client = redis.createClient.apply(null, args);
215+
client = redis.createClient.apply(null, config.configureClient(ip, {
216+
no_ready_check: true
217+
}));
209218
client.on('error', function (err) {
210-
assert.strictEqual(err.message, 'ERR invalid password');
219+
assert.ok(errors.invalidPassword.test(err.message));
211220
assert.strictEqual(err.command, 'AUTH');
212221
done();
213222
});
@@ -235,7 +244,7 @@ describe('client authentication', function () {
235244
client = redis.createClient.apply(null, args);
236245
client.on('ready', function () {
237246
client.set('foo', 'bar', function (err, res) {
238-
assert.equal(err.message, 'NOAUTH Authentication required.');
247+
assert.ok(/^NOAUTH Authentication required\.(\r\n)?$/.test(err.message));
239248
assert.equal(err.code, 'NOAUTH');
240249
assert.equal(err.command, 'SET');
241250
done();
@@ -248,7 +257,7 @@ describe('client authentication', function () {
248257
client = redis.createClient.apply(null, args);
249258
client.on('error', function (err) {
250259
assert.equal(err.code, 'NOAUTH');
251-
assert.equal(err.message, 'Ready check failed: NOAUTH Authentication required.');
260+
assert.ok(/^Ready check failed: NOAUTH Authentication required\.(\r\n)?$/.test(err.message));
252261
assert.equal(err.command, 'INFO');
253262
done();
254263
});
@@ -258,9 +267,10 @@ describe('client authentication', function () {
258267
if (helper.redisProcess().spawnFailed()) this.skip();
259268
client = redis.createClient({
260269
password: 'wrong_password',
270+
no_ready_check: true
261271
});
262272
client.once('error', function (err) {
263-
assert.strictEqual(err.message, 'ERR invalid password');
273+
assert.ok(errors.invalidPassword.test(err.message));
264274
done();
265275
});
266276
});
@@ -277,7 +287,7 @@ describe('client authentication', function () {
277287
client.once('ready', function () {
278288
assert.strictEqual(client.pub_sub_mode, 1);
279289
client.get('foo', function (err, res) {
280-
assert(/ERR only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/.test(err.message));
290+
assert.ok(errors.subscribeUnsubscribeOnly.test(err.message));
281291
done();
282292
});
283293
});

test/commands/client.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ describe("The 'client' method", function () {
5757
it('off', function (done) {
5858
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
5959
assert.strictEqual(client.reply, 'ON');
60-
client.client(new Buffer('REPLY'), 'OFF', helper.isUndefined());
60+
client.client(Buffer.from('REPLY'), 'OFF', helper.isUndefined());
6161
assert.strictEqual(client.reply, 'OFF');
6262
client.set('foo', 'bar', helper.isUndefined(done));
6363
});
6464

6565
it('skip', function (done) {
6666
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
6767
assert.strictEqual(client.reply, 'ON');
68-
client.client('REPLY', new Buffer('SKIP'), helper.isUndefined());
68+
client.client('REPLY', Buffer.from('SKIP'), helper.isUndefined());
6969
assert.strictEqual(client.reply, 'SKIP_ONE_MORE');
7070
client.set('foo', 'bar', helper.isUndefined());
7171
client.get('foo', helper.isString('bar', done));
@@ -91,7 +91,7 @@ describe("The 'client' method", function () {
9191
var batch = client.batch();
9292
assert.strictEqual(client.reply, 'ON');
9393
batch.set('hello', 'world');
94-
batch.client(new Buffer('REPLY'), new Buffer('OFF'), helper.isUndefined());
94+
batch.client(Buffer.from('REPLY'), Buffer.from('OFF'), helper.isUndefined());
9595
batch.set('foo', 'bar', helper.isUndefined());
9696
batch.exec(function (err, res) {
9797
assert.strictEqual(client.reply, 'OFF');

test/commands/hgetall.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ describe("The 'hgetall' method", function () {
5050
});
5151

5252
describe('binary client', function () {
53-
var client;
5453
var args = config.configureClient(ip, {
5554
return_buffers: true
5655
});
@@ -63,14 +62,14 @@ describe("The 'hgetall' method", function () {
6362
});
6463

6564
it('returns binary results', function (done) {
66-
client.hmset(['bhosts', 'mjr', '1', 'another', '23', 'home', '1234', new Buffer([0xAA, 0xBB, 0x00, 0xF0]), new Buffer([0xCC, 0xDD, 0x00, 0xF0])], helper.isString('OK'));
65+
client.hmset(['bhosts', 'mjr', '1', 'another', '23', 'home', '1234', Buffer.from([0xAA, 0xBB, 0x00, 0xF0]), Buffer.from([0xCC, 0xDD, 0x00, 0xF0])], helper.isString('OK'));
6766
client.HGETALL('bhosts', function (err, obj) {
6867
assert.strictEqual(4, Object.keys(obj).length);
6968
assert.strictEqual('1', obj.mjr.toString());
7069
assert.strictEqual('23', obj.another.toString());
7170
assert.strictEqual('1234', obj.home.toString());
72-
assert.strictEqual((new Buffer([0xAA, 0xBB, 0x00, 0xF0])).toString('binary'), Object.keys(obj)[3]);
73-
assert.strictEqual((new Buffer([0xCC, 0xDD, 0x00, 0xF0])).toString('binary'), obj[(new Buffer([0xAA, 0xBB, 0x00, 0xF0])).toString('binary')].toString('binary'));
71+
assert.strictEqual((Buffer.from([0xAA, 0xBB, 0x00, 0xF0])).toString('binary'), Object.keys(obj)[3]);
72+
assert.strictEqual((Buffer.from([0xCC, 0xDD, 0x00, 0xF0])).toString('binary'), obj[(Buffer.from([0xAA, 0xBB, 0x00, 0xF0])).toString('binary')].toString('binary'));
7473
return done(err);
7574
});
7675
});

test/commands/hlen.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ describe("The 'hlen' method", function () {
2020

2121
it('reports the count of keys', function (done) {
2222
var hash = 'test hash';
23-
var field1 = new Buffer('0123456789');
24-
var value1 = new Buffer('abcdefghij');
25-
var field2 = new Buffer(0);
26-
var value2 = new Buffer(0);
23+
var field1 = Buffer.from('0123456789');
24+
var value1 = Buffer.from('abcdefghij');
25+
var field2 = Buffer.alloc(0);
26+
var value2 = Buffer.alloc(0);
2727

2828
client.HSET(hash, field1, value1, helper.isNumber(1));
2929
client.HSET(hash, field2, value2, helper.isNumber(1));

test/commands/hset.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ describe("The 'hset' method", function () {
2121
});
2222

2323
it('allows a value to be set in a hash', function (done) {
24-
var field = new Buffer('0123456789');
25-
var value = new Buffer('abcdefghij');
24+
var field = Buffer.from('0123456789');
25+
var value = Buffer.from('abcdefghij');
2626

2727
client.hset(hash, field, value, helper.isNumber(1));
2828
client.HGET(hash, field, helper.isString(value.toString(), done));
2929
});
3030

3131
it('handles an empty value', function (done) {
32-
var field = new Buffer('0123456789');
33-
var value = new Buffer(0);
32+
var field = Buffer.from('0123456789');
33+
var value = Buffer.alloc(0);
3434

3535
client.HSET(hash, field, value, helper.isNumber(1));
3636
client.HGET([hash, field], helper.isString('', done));
3737
});
3838

3939
it('handles empty key and value', function (done) {
40-
var field = new Buffer(0);
41-
var value = new Buffer(0);
40+
var field = Buffer.alloc(0);
41+
var value = Buffer.alloc(0);
4242
client.HSET([hash, field, value], function (err, res) {
4343
assert.strictEqual(res, 1);
4444
client.HSET(hash, field, value, helper.isNumber(0, done));
@@ -60,7 +60,7 @@ describe("The 'hset' method", function () {
6060
it('does not error when a buffer and date are set as values on the same hash', function (done) {
6161
var hash = 'test hash';
6262
var field1 = 'buffer';
63-
var value1 = new Buffer('abcdefghij');
63+
var value1 = Buffer.from('abcdefghij');
6464
var field2 = 'date';
6565
var value2 = new Date();
6666

@@ -70,7 +70,7 @@ describe("The 'hset' method", function () {
7070
it('does not error when a buffer and date are set as fields on the same hash', function (done) {
7171
var hash = 'test hash';
7272
var value1 = 'buffer';
73-
var field1 = new Buffer('abcdefghij');
73+
var field1 = Buffer.from('abcdefghij');
7474
var value2 = 'date';
7575
var field2 = new Date();
7676

0 commit comments

Comments
 (0)