You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
tweaks based on running test-suite on Windows on an older Redis
This commit is contained in:
@@ -10,10 +10,10 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||||
"coverage": "nyc report --reporter=html",
|
"test": "nyc ./node_modules/.bin/_mocha ./test/*.js ./test/commands/*.js ./test/parser/*.js --timeout=8000",
|
||||||
"test": "./node_modules/.bin/jshint * && nyc ./node_modules/.bin/_mocha ./test/*.js ./test/commands/*.js ./test/parser/*.js --timeout=8000",
|
"pretest": "optional-dev-dependency hiredis",
|
||||||
"jshint": "./node_modules/.bin/jshint *"
|
"posttest": "jshint *"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coveralls": "^2.11.2",
|
"coveralls": "^2.11.2",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"metrics": ">=0.1.5",
|
"metrics": ">=0.1.5",
|
||||||
"mocha": "^2.2.5",
|
"mocha": "^2.2.5",
|
||||||
"nyc": "^3.2.2",
|
"nyc": "^3.2.2",
|
||||||
|
"optional-dev-dependency": "^1.0.1",
|
||||||
"tcp-port-used": "^0.1.2",
|
"tcp-port-used": "^0.1.2",
|
||||||
"uuid": "^2.0.1"
|
"uuid": "^2.0.1"
|
||||||
},
|
},
|
||||||
|
@@ -24,7 +24,7 @@ describe("client authentication", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("allows auth to be provided with 'auth' method", function (done) {
|
it("allows auth to be provided with 'auth' method", function (done) {
|
||||||
abortOnSpawnFailure(done);
|
if (helper.redisProcess().spawnFailed()) this.skip();
|
||||||
|
|
||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
client.auth(auth, function (err, res) {
|
client.auth(auth, function (err, res) {
|
||||||
@@ -35,7 +35,7 @@ describe("client authentication", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("raises error when auth is bad", function (done) {
|
it("raises error when auth is bad", function (done) {
|
||||||
abortOnSpawnFailure(done);
|
if (helper.redisProcess().spawnFailed()) this.skip();
|
||||||
|
|
||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ describe("client authentication", function () {
|
|||||||
|
|
||||||
if (ip === 'IPv4') {
|
if (ip === 'IPv4') {
|
||||||
it('allows auth to be provided as part of redis url', function (done) {
|
it('allows auth to be provided as part of redis url', function (done) {
|
||||||
abortOnSpawnFailure(done);
|
if (helper.redisProcess().spawnFailed()) this.skip();
|
||||||
|
|
||||||
client = redis.createClient('redis://foo:' + auth + '@' + config.HOST[ip] + ':' + config.PORT);
|
client = redis.createClient('redis://foo:' + auth + '@' + config.HOST[ip] + ':' + config.PORT);
|
||||||
client.on("ready", function () {
|
client.on("ready", function () {
|
||||||
@@ -59,7 +59,7 @@ describe("client authentication", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('allows auth to be provided as config option for client', function (done) {
|
it('allows auth to be provided as config option for client', function (done) {
|
||||||
abortOnSpawnFailure(done);
|
if (helper.redisProcess().spawnFailed()) this.skip();
|
||||||
|
|
||||||
var args = config.configureClient(parser, ip, {
|
var args = config.configureClient(parser, ip, {
|
||||||
auth_pass: auth
|
auth_pass: auth
|
||||||
@@ -71,7 +71,7 @@ describe("client authentication", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reconnects with appropriate authentication', function (done) {
|
it('reconnects with appropriate authentication', function (done) {
|
||||||
abortOnSpawnFailure(done);
|
if (helper.redisProcess().spawnFailed()) this.skip();
|
||||||
|
|
||||||
var readyCount = 0;
|
var readyCount = 0;
|
||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
@@ -93,13 +93,4 @@ describe("client authentication", function () {
|
|||||||
helper.startRedis('./conf/redis.conf', done);
|
helper.startRedis('./conf/redis.conf', done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// if we fail to spawn Redis (spawning Redis directly is
|
|
||||||
// not possible in some CI environments) skip the auth tests.
|
|
||||||
function abortOnSpawnFailure (done) {
|
|
||||||
if (helper.redisProcess().spawnFailed()) {
|
|
||||||
console.warn('skipped authentication test')
|
|
||||||
return done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
@@ -17,12 +17,7 @@ describe("The 'client' method", function () {
|
|||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
client.once("error", done);
|
client.once("error", done);
|
||||||
client.once("connect", function () {
|
client.once("connect", function () {
|
||||||
client.flushdb(function (err) {
|
client.flushdb(done)
|
||||||
if (!helper.serverVersionAtLeast(client, [2, 4, 0])) {
|
|
||||||
err = Error('script not supported in redis <= 2.4.0');
|
|
||||||
}
|
|
||||||
return done(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -17,12 +17,7 @@ describe("The 'eval' method", function () {
|
|||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
client.once("error", done);
|
client.once("error", done);
|
||||||
client.once("connect", function () {
|
client.once("connect", function () {
|
||||||
client.flushdb(function (err) {
|
client.flushdb(done)
|
||||||
if (!helper.serverVersionAtLeast(client, [2, 5, 0])) {
|
|
||||||
err = Error('exec not supported in redis <= 2.5.0');
|
|
||||||
}
|
|
||||||
return done(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,30 +26,37 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('converts a float to an integer when evaluated', function (done) {
|
it('converts a float to an integer when evaluated', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval("return 100.5", 0, helper.isNumber(100, done));
|
client.eval("return 100.5", 0, helper.isNumber(100, done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns a string', function (done) {
|
it('returns a string', function (done) {
|
||||||
client.EVAL("return 'hello world'", 0, helper.isString('hello world', done));
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
|
client.eval("return 'hello world'", 0, helper.isString('hello world', done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts boolean true to integer 1', function (done) {
|
it('converts boolean true to integer 1', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval("return true", 0, helper.isNumber(1, done));
|
client.eval("return true", 0, helper.isNumber(1, done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts boolean false to null', function (done) {
|
it('converts boolean false to null', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval("return false", 0, helper.isNull(done));
|
client.eval("return false", 0, helper.isNull(done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts lua status code to string representation', function (done) {
|
it('converts lua status code to string representation', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval("return {ok='fine'}", 0, helper.isString('fine', done));
|
client.eval("return {ok='fine'}", 0, helper.isString('fine', done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts lua error to an error response', function (done) {
|
it('converts lua error to an error response', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval("return {err='this is an error'}", 0, helper.isError(done));
|
client.eval("return {err='this is an error'}", 0, helper.isError(done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('represents a lua table appropritely', function (done) {
|
it('represents a lua table appropritely', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval("return {1,2,3,'ciao',{1,2}}", 0, function (err, res) {
|
client.eval("return {1,2,3,'ciao',{1,2}}", 0, function (err, res) {
|
||||||
assert.strictEqual(5, res.length);
|
assert.strictEqual(5, res.length);
|
||||||
assert.strictEqual(1, res[0]);
|
assert.strictEqual(1, res[0]);
|
||||||
@@ -69,25 +71,27 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('populates keys and argv correctly', function (done) {
|
it('populates keys and argv correctly', function (done) {
|
||||||
client.eval("return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 2, "a", "b", "c", "d", function (err, res) {
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
assert.strictEqual(4, res.length);
|
client.eval("return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 2, "a", "b", "c", "d", function (err, res) {
|
||||||
assert.strictEqual("a", res[0]);
|
assert.strictEqual(4, res.length);
|
||||||
assert.strictEqual("b", res[1]);
|
assert.strictEqual("a", res[0]);
|
||||||
assert.strictEqual("c", res[2]);
|
assert.strictEqual("b", res[1]);
|
||||||
assert.strictEqual("d", res[3]);
|
assert.strictEqual("c", res[2]);
|
||||||
return done();
|
assert.strictEqual("d", res[3]);
|
||||||
});
|
return done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows arguments to be provided in array rather than as multiple parameters', function (done) {
|
it('allows arguments to be provided in array rather than as multiple parameters', function (done) {
|
||||||
client.eval(["return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 2, "a", "b", "c", "d"], function (err, res) {
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
assert.strictEqual(4, res.length);
|
client.eval(["return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 2, "a", "b", "c", "d"], function (err, res) {
|
||||||
assert.strictEqual("a", res[0]);
|
assert.strictEqual(4, res.length);
|
||||||
assert.strictEqual("b", res[1]);
|
assert.strictEqual("a", res[0]);
|
||||||
assert.strictEqual("c", res[2]);
|
assert.strictEqual("b", res[1]);
|
||||||
assert.strictEqual("d", res[3]);
|
assert.strictEqual("c", res[2]);
|
||||||
return done();
|
assert.strictEqual("d", res[3]);
|
||||||
});
|
return done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('evalsha', function () {
|
describe('evalsha', function () {
|
||||||
@@ -101,19 +105,23 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a script to be executed that accesses the redis API', function (done) {
|
it('allows a script to be executed that accesses the redis API', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval(source, 0, helper.isString('eval get sha test', done));
|
client.eval(source, 0, helper.isString('eval get sha test', done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can execute a script if the SHA exists', function (done) {
|
it('can execute a script if the SHA exists', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.evalsha(sha, 0, helper.isString('eval get sha test', done));
|
client.evalsha(sha, 0, helper.isString('eval get sha test', done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error if SHA does not exist', function (done) {
|
it('throws an error if SHA does not exist', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.evalsha('ffffffffffffffffffffffffffffffffffffffff', 0, helper.isError(done));
|
client.evalsha('ffffffffffffffffffffffffffffffffffffffff', 0, helper.isError(done));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows a key to be incremented, and performs appropriate conversion from LUA type', function (done) {
|
it('allows a key to be incremented, and performs appropriate conversion from LUA type', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.set("incr key", 0, function (err, reply) {
|
client.set("incr key", 0, function (err, reply) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
client.eval("local foo = redis.call('incr','incr key')\n" + "return {type(foo),foo}", 0, function (err, res) {
|
client.eval("local foo = redis.call('incr','incr key')\n" + "return {type(foo),foo}", 0, function (err, res) {
|
||||||
@@ -126,6 +134,7 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a bulk operation to be performed, and performs appropriate conversion from LUA type', function (done) {
|
it('allows a bulk operation to be performed, and performs appropriate conversion from LUA type', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.set("bulk reply key", "bulk reply value", function (err, res) {
|
client.set("bulk reply key", "bulk reply value", function (err, res) {
|
||||||
client.eval("local foo = redis.call('get','bulk reply key'); return {type(foo),foo}", 0, function (err, res) {
|
client.eval("local foo = redis.call('get','bulk reply key'); return {type(foo),foo}", 0, function (err, res) {
|
||||||
assert.strictEqual(2, res.length);
|
assert.strictEqual(2, res.length);
|
||||||
@@ -137,6 +146,7 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a multi mulk operation to be performed, with the appropriate type conversion', function (done) {
|
it('allows a multi mulk operation to be performed, with the appropriate type conversion', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.multi()
|
client.multi()
|
||||||
.del("mylist")
|
.del("mylist")
|
||||||
.rpush("mylist", "a")
|
.rpush("mylist", "a")
|
||||||
@@ -157,6 +167,7 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns an appropriate representation of Lua status reply', function (done) {
|
it('returns an appropriate representation of Lua status reply', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.eval("local foo = redis.call('set','mykey','myval'); return {type(foo),foo['ok']}", 0, function (err, res) {
|
client.eval("local foo = redis.call('set','mykey','myval'); return {type(foo),foo['ok']}", 0, function (err, res) {
|
||||||
assert.strictEqual(2, res.length);
|
assert.strictEqual(2, res.length);
|
||||||
assert.strictEqual("table", res[0]);
|
assert.strictEqual("table", res[0]);
|
||||||
@@ -166,6 +177,7 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns an appropriate representation of a Lua error reply', function (done) {
|
it('returns an appropriate representation of a Lua error reply', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.set("error reply key", "error reply value", function (err, res) {
|
client.set("error reply key", "error reply value", function (err, res) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
client.eval("local foo = redis.pcall('incr','error reply key'); return {type(foo),foo['err']}", 0, function (err, res) {
|
client.eval("local foo = redis.pcall('incr','error reply key'); return {type(foo),foo['err']}", 0, function (err, res) {
|
||||||
@@ -178,6 +190,7 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns an appropriate representation of a Lua nil reply', function (done) {
|
it('returns an appropriate representation of a Lua nil reply', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 5, 0]);
|
||||||
client.del("nil reply key", function (err, res) {
|
client.del("nil reply key", function (err, res) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
client.eval("local foo = redis.call('get','nil reply key'); return {type(foo),foo == false}", 0, function (err, res) {
|
client.eval("local foo = redis.call('get','nil reply key'); return {type(foo),foo == false}", 0, function (err, res) {
|
||||||
|
@@ -24,7 +24,7 @@ describe("The 'expire' method", function () {
|
|||||||
client.EXPIRE(["expiry key", "1"], helper.isNumber(1));
|
client.EXPIRE(["expiry key", "1"], helper.isNumber(1));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
client.exists(["expiry key"], helper.isNumber(0, done));
|
client.exists(["expiry key"], helper.isNumber(0, done));
|
||||||
}, 1100);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@@ -64,9 +64,9 @@ describe("The 'multi' method", function () {
|
|||||||
// Provoke an error at queue time
|
// Provoke an error at queue time
|
||||||
multi1 = client.MULTI();
|
multi1 = client.MULTI();
|
||||||
multi1.mset("multifoo", "10", "multibar", "20", helper.isString("OK"));
|
multi1.mset("multifoo", "10", "multibar", "20", helper.isString("OK"));
|
||||||
multi1.set("foo2", helper.isError());
|
multi1.set("foo2");
|
||||||
multi1.incr("multifoo", helper.isNumber(11));
|
multi1.incr("multifoo");
|
||||||
multi1.incr("multibar", helper.isNumber(21));
|
multi1.incr("multibar");
|
||||||
multi1.exec(function () {
|
multi1.exec(function () {
|
||||||
// Redis 2.6.5+ will abort transactions with errors
|
// Redis 2.6.5+ will abort transactions with errors
|
||||||
// see: http://redis.io/topics/transactions
|
// see: http://redis.io/topics/transactions
|
||||||
@@ -89,6 +89,7 @@ describe("The 'multi' method", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
// I'm unclear as to the difference between this test in the test above,
|
// I'm unclear as to the difference between this test in the test above,
|
||||||
// perhaps @mranney can clarify?
|
// perhaps @mranney can clarify?
|
||||||
it('roles back a transaction when an error was provoked at queue time', function (done) {
|
it('roles back a transaction when an error was provoked at queue time', function (done) {
|
||||||
@@ -137,8 +138,8 @@ describe("The 'multi' method", function () {
|
|||||||
assert.equal(replies, undefined);
|
assert.equal(replies, undefined);
|
||||||
} else {
|
} else {
|
||||||
assert.strictEqual(2, replies[0].length);
|
assert.strictEqual(2, replies[0].length);
|
||||||
assert.strictEqual("0", replies[0][0].toString());
|
assert.strictEqual(null, replies[0][0]);
|
||||||
assert.strictEqual("0", replies[0][1].toString());
|
assert.strictEqual(null, replies[0][1]);
|
||||||
|
|
||||||
assert.strictEqual("1", replies[1].toString());
|
assert.strictEqual("1", replies[1].toString());
|
||||||
assert.strictEqual("1", replies[2].toString());
|
assert.strictEqual("1", replies[2].toString());
|
||||||
@@ -226,7 +227,7 @@ describe("The 'multi' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports multiple exceptions when they occur', function (done) {
|
it('reports multiple exceptions when they occur', function (done) {
|
||||||
if (!helper.serverVersionAtLeast(client, [2, 6, 5])) return done();
|
helper.serverVersionAtLeast.bind(this)(client, [2, 6, 5])
|
||||||
|
|
||||||
client.multi().set("foo").exec(function (err, reply) {
|
client.multi().set("foo").exec(function (err, reply) {
|
||||||
assert(Array.isArray(err), "err should be an array");
|
assert(Array.isArray(err), "err should be an array");
|
||||||
|
@@ -19,12 +19,7 @@ describe("The 'script' method", function () {
|
|||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
client.once("error", done);
|
client.once("error", done);
|
||||||
client.once("connect", function () {
|
client.once("connect", function () {
|
||||||
client.flushdb(function (err) {
|
client.flushdb(done);
|
||||||
if (!helper.serverVersionAtLeast(client, [2, 6, 0])) {
|
|
||||||
err = Error('script not supported in redis <= 2.6.0');
|
|
||||||
}
|
|
||||||
return done(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -33,17 +28,20 @@ describe("The 'script' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("loads script with client.script('load')", function (done) {
|
it("loads script with client.script('load')", function (done) {
|
||||||
client.SCRIPT("load", command, function(err, result) {
|
helper.serverVersionAtLeast.bind(this)(client, [2, 6, 0]);
|
||||||
|
client.script("load", command, function(err, result) {
|
||||||
assert.strictEqual(result, commandSha);
|
assert.strictEqual(result, commandSha);
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows a loaded script to be evaluated', function (done) {
|
it('allows a loaded script to be evaluated', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 6, 0]);
|
||||||
client.evalsha(commandSha, 0, helper.isString('99', done));
|
client.evalsha(commandSha, 0, helper.isString('99', done));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows a script to be loaded as part of a chained transaction', function (done) {
|
it('allows a script to be loaded as part of a chained transaction', function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 6, 0]);
|
||||||
client.multi().script("load", command).exec(function(err, result) {
|
client.multi().script("load", command).exec(function(err, result) {
|
||||||
assert.strictEqual(result[0], commandSha);
|
assert.strictEqual(result[0], commandSha);
|
||||||
return done();
|
return done();
|
||||||
@@ -51,6 +49,7 @@ describe("The 'script' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("allows a script to be loaded using a transaction's array syntax", function (done) {
|
it("allows a script to be loaded using a transaction's array syntax", function (done) {
|
||||||
|
helper.serverVersionAtLeast.bind(this)(client, [2, 6, 0]);
|
||||||
client.multi([['script', 'load', command]]).exec(function(err, result) {
|
client.multi([['script', 'load', command]]).exec(function(err, result) {
|
||||||
assert.strictEqual(result[0], commandSha);
|
assert.strictEqual(result[0], commandSha);
|
||||||
return done();
|
return done();
|
||||||
|
@@ -18,12 +18,7 @@ describe("The 'watch' method", function () {
|
|||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
client.once("error", done);
|
client.once("error", done);
|
||||||
client.once("connect", function () {
|
client.once("connect", function () {
|
||||||
client.flushdb(function (err) {
|
client.flushdb(done);
|
||||||
if (!helper.serverVersionAtLeast(client, [2, 2, 0])) {
|
|
||||||
err = Error('some watch commands not supported in redis <= 2.2.0');
|
|
||||||
}
|
|
||||||
return done(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -98,17 +98,26 @@ module.exports = {
|
|||||||
// Return true if the server version >= desired_version
|
// Return true if the server version >= desired_version
|
||||||
var version = connection.server_info.versions;
|
var version = connection.server_info.versions;
|
||||||
for (var i = 0; i < 3; i++) {
|
for (var i = 0; i < 3; i++) {
|
||||||
if (version[i] > desired_version[i]) return true;
|
if (version[i] < desired_version[i]) {
|
||||||
if (version[i] < desired_version[i]) return false;
|
if (this.skip) this.skip();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
allTests: function (cb) {
|
allTests: function (cb) {
|
||||||
[undefined].forEach(function (options) { // add buffer option at some point
|
[undefined].forEach(function (options) { // add buffer option at some point
|
||||||
describe(options && options.return_buffers ? "returning buffers" : "returning strings", function () {
|
describe(options && options.return_buffers ? "returning buffers" : "returning strings", function () {
|
||||||
['hiredis', 'javascript'].forEach(function (parser) {
|
var parsers = ['javascript'];
|
||||||
cb(parser, "/tmp/redis.sock", config.configureClient(parser, "/tmp/redis.sock", options));
|
var protocols = ['IPv4'];
|
||||||
['IPv4', 'IPv6'].forEach(function (ip) {
|
if (process.platform !== 'win32') {
|
||||||
|
parsers.push('hiredis');
|
||||||
|
protocols.push('IPv6')
|
||||||
|
}
|
||||||
|
|
||||||
|
parsers.forEach(function (parser) {
|
||||||
|
if (process.platform !== 'win32') cb(parser, "/tmp/redis.sock", config.configureClient(parser, "/tmp/redis.sock", options));
|
||||||
|
protocols.forEach(function (ip) {
|
||||||
cb(parser, ip, config.configureClient(parser, ip, options));
|
cb(parser, ip, config.configureClient(parser, ip, options));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -219,7 +219,7 @@ describe("The node_redis client", function () {
|
|||||||
|
|
||||||
describe('monitor', function () {
|
describe('monitor', function () {
|
||||||
it('monitors commands on all other redis clients', function (done) {
|
it('monitors commands on all other redis clients', function (done) {
|
||||||
if (!helper.serverVersionAtLeast(client, [2, 6, 0])) return done();
|
helper.serverVersionAtLeast.bind(this)(client, [2, 6, 0]);
|
||||||
|
|
||||||
var monitorClient = redis.createClient.apply(redis.createClient, args);
|
var monitorClient = redis.createClient.apply(redis.createClient, args);
|
||||||
var responses = [];
|
var responses = [];
|
||||||
|
@@ -69,7 +69,7 @@ describe("publish/subscribe", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('receives messages if subscribe is called after unsubscribe', function (done) {
|
it('receives messages if subscribe is called after unsubscribe', function (done) {
|
||||||
if (!helper.serverVersionAtLeast(pub, [2, 6, 11])) return done();
|
helper.serverVersionAtLeast.bind(this)(sub, [2, 6, 11]);
|
||||||
|
|
||||||
sub.once("subscribe", function (chnl, count) {
|
sub.once("subscribe", function (chnl, count) {
|
||||||
pub.publish(channel, message, helper.isNumber(1));
|
pub.publish(channel, message, helper.isNumber(1));
|
||||||
@@ -87,7 +87,7 @@ describe("publish/subscribe", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles SUB_UNSUB_MSG_SUB', function (done) {
|
it('handles SUB_UNSUB_MSG_SUB', function (done) {
|
||||||
if (!helper.serverVersionAtLeast(pub, [2, 6, 11])) return done();
|
helper.serverVersionAtLeast.bind(this)(sub, [2, 6, 11]);
|
||||||
|
|
||||||
sub.subscribe('chan8');
|
sub.subscribe('chan8');
|
||||||
sub.subscribe('chan9');
|
sub.subscribe('chan9');
|
||||||
@@ -99,7 +99,7 @@ describe("publish/subscribe", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles SUB_UNSUB_MSG_SUB', function (done) {
|
it('handles SUB_UNSUB_MSG_SUB', function (done) {
|
||||||
if (!helper.serverVersionAtLeast(pub, [2, 6, 11])) return done();
|
helper.serverVersionAtLeast.bind(this)(sub, [2, 6, 11]);
|
||||||
|
|
||||||
sub.psubscribe('abc*');
|
sub.psubscribe('abc*');
|
||||||
sub.subscribe('xyz');
|
sub.subscribe('xyz');
|
||||||
@@ -198,8 +198,7 @@ describe("publish/subscribe", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('executes callback when unsubscribe is called and there are no subscriptions', function (done) {
|
it('executes callback when unsubscribe is called and there are no subscriptions', function (done) {
|
||||||
// test hangs on older versions of redis, so skip
|
helper.serverVersionAtLeast.bind(this)(sub, [2, 6, 11]);
|
||||||
if (!helper.serverVersionAtLeast(pub, [2, 6, 11])) return done();
|
|
||||||
|
|
||||||
pub.unsubscribe(function (err, results) {
|
pub.unsubscribe(function (err, results) {
|
||||||
assert.strictEqual(null, results);
|
assert.strictEqual(null, results);
|
||||||
@@ -228,8 +227,7 @@ describe("publish/subscribe", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('executes callback when punsubscribe is called and there are no subscriptions', function (done) {
|
it('executes callback when punsubscribe is called and there are no subscriptions', function (done) {
|
||||||
// test hangs on older versions of redis, so skip
|
helper.serverVersionAtLeast.bind(this)(sub, [2, 6, 11]);
|
||||||
if (!helper.serverVersionAtLeast(pub, [2, 6, 11])) return done();
|
|
||||||
|
|
||||||
pub.punsubscribe(function (err, results) {
|
pub.punsubscribe(function (err, results) {
|
||||||
assert.strictEqual(null, results);
|
assert.strictEqual(null, results);
|
||||||
|
Reference in New Issue
Block a user