You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Add example test with grunt and mocha.
Add test for reconnect. Run each test for both parsers and both IP versions. Don't save a reference to this nodified assertion function. Add DEBUG env var which enables extra debug logging in node_redis. Remove Grunt, run Redis on 6378 for non-interference. Remove the tests already ported to Mocha. Port reconnect after pubsub test; add subscribed after reconnect test. Reconnet after pubsub test confused me. I don't think it tested anything, and it didn't pass for me after I ported it. I've disabled it and added a note. In its place, I've added a test to make sure we are still subscribed and can receive pubsub messages after a reconnect. Move test suite config-like stuff into a library. Move test suite createClient args generation into the config library. WIP. Some select tests, most disabled and still WIP.
This commit is contained in:
committed by
Benjamin Coe
parent
6cae0b880f
commit
2b44245056
30
test/lib/config.js
Normal file
30
test/lib/config.js
Normal file
@@ -0,0 +1,30 @@
|
||||
module.exports = (function () {
|
||||
var redis = require('../../index');
|
||||
redis.debug_mode = process.env.DEBUG ? JSON.parse(process.env.DEBUG) : false;
|
||||
|
||||
var config = {
|
||||
redis: redis,
|
||||
PORT: 6378,
|
||||
HOST: {
|
||||
IPv4: "127.0.0.1",
|
||||
IPv6: "::1"
|
||||
}
|
||||
};
|
||||
|
||||
config.configureClient = function (parser, ip, isSocket) {
|
||||
var args = [];
|
||||
|
||||
if (!isSocket) {
|
||||
args.push(config.PORT);
|
||||
args.push(config.HOST[ip]);
|
||||
args.push({ family: ip, parser: parser });
|
||||
} else {
|
||||
args.push(ip);
|
||||
args.push({ parser: parser });
|
||||
}
|
||||
|
||||
return args;
|
||||
};
|
||||
|
||||
return config;
|
||||
})();
|
60
test/lib/nodeify-assertions.js
Normal file
60
test/lib/nodeify-assertions.js
Normal file
@@ -0,0 +1,60 @@
|
||||
var assert = require('assert');
|
||||
|
||||
module.exports = {
|
||||
isNumber: function (expected) {
|
||||
return function (err, results) {
|
||||
assert.strictEqual(null, err, "expected " + expected + ", got error: " + err);
|
||||
assert.strictEqual(expected, results, expected + " !== " + results);
|
||||
assert.strictEqual(typeof results, "number", "expected a number, got " + typeof results);
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
isString: function (str) {
|
||||
return function (err, results) {
|
||||
assert.strictEqual(null, err, "expected string '" + str + "', got error: " + err);
|
||||
assert.equal(str, results, str + " does not match " + results);
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
isNull: function () {
|
||||
return function (err, results) {
|
||||
assert.strictEqual(null, err, "expected null, got error: " + err);
|
||||
assert.strictEqual(null, results, results + " is not null");
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
isError: function () {
|
||||
return function (err, results) {
|
||||
assert.notEqual(err, null, "err is null, but an error is expected here.");
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
isNotError: function () {
|
||||
return function (err, results) {
|
||||
assert.strictEqual(err, null, "expected success, got an error: " + err);
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
isType: {
|
||||
number: function () {
|
||||
return function (err, results) {
|
||||
assert.strictEqual(null, err, "expected any number, got error: " + err);
|
||||
assert.strictEqual(typeof results, "number", results + " is not a number");
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
positiveNumber: function () {
|
||||
return function (err, results) {
|
||||
assert.strictEqual(null, err, "expected positive number, got error: " + err);
|
||||
assert.strictEqual(true, (results > 0), results + " is not a positive number");
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
23
test/lib/redis-process.js
Normal file
23
test/lib/redis-process.js
Normal file
@@ -0,0 +1,23 @@
|
||||
var cp = require('child_process');
|
||||
|
||||
module.exports = {
|
||||
start: function (done, isSocket) {
|
||||
var confFile = isSocket ? "test/conf/redis-socket.conf" : "test/conf/redis.conf";
|
||||
var redis = cp.spawn("redis-server", [confFile]);
|
||||
|
||||
redis.once('err', done);
|
||||
setTimeout(function (data) {
|
||||
redis.removeListener('err', done);
|
||||
done();
|
||||
}, 1000);
|
||||
|
||||
return {
|
||||
stop: function (done) {
|
||||
redis.once("exit", function () {
|
||||
done();
|
||||
});
|
||||
redis.kill("SIGINT");
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user