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

Improve tests a bit

Reduce timeouts if possible
Extend timeouts if needed (windows tests need their time)
Don't expose the redis socket to others than the owner
Don't create the stunnel log
This commit is contained in:
Ruben Bridgewater
2016-03-31 19:21:14 +02:00
parent 79c1767f86
commit 14170f9d02
21 changed files with 136 additions and 86 deletions

View File

@ -43,7 +43,7 @@ describe("The 'set' method", function () {
beforeEach(function (done) {
client = redis.createClient.apply(null, args);
client.once('ready', function () {
done();
client.flushdb(done);
});
});
@ -62,6 +62,35 @@ describe("The 'set' method", function () {
});
});
});
it('set expire date in seconds', function (done) {
client.set('foo', 'bar', 'ex', 10, helper.isString('OK'));
client.pttl('foo', function (err, res) {
assert(res >= 10000 - 50); // Max 50 ms should have passed
assert(res <= 10000); // Max possible should be 10.000
done(err);
});
});
it('set expire date in milliseconds', function (done) {
client.set('foo', 'bar', 'px', 100, helper.isString('OK'));
client.pttl('foo', function (err, res) {
assert(res >= 50); // Max 50 ms should have passed
assert(res <= 100); // Max possible should be 100
done(err);
});
});
it('only set the key if (not) already set', function (done) {
client.set('foo', 'bar', 'NX', helper.isString('OK'));
client.set('foo', 'bar', 'nx', helper.isNull());
client.set('foo', 'bar', 'EX', '10', 'XX', helper.isString('OK'));
client.ttl('foo', function (err, res) {
assert(res >= 9); // Min 9s should be left
assert(res <= 10); // Max 10s should be left
done(err);
});
});
});
describe('reports an error with invalid parameters', function () {