You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Stricten tests by always ending redis with .end(true) if possible
This commit is contained in:
@@ -246,7 +246,7 @@ something like this `Error: Ready check failed: ERR operation not permitted`.
|
|||||||
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
|
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
|
||||||
If you want to exit cleanly, call `client.quit()` to send the `QUIT` command after you have handled all replies.
|
If you want to exit cleanly, call `client.quit()` to send the `QUIT` command after you have handled all replies.
|
||||||
|
|
||||||
If flush is set to true, all commands will be rejected instead of ignored after using `.end`.
|
If flush is set to true, all still running commands will be rejected instead of ignored after using `.end`.
|
||||||
|
|
||||||
This example closes the connection to the Redis server before the replies have been read. You probably don't
|
This example closes the connection to the Redis server before the replies have been read. You probably don't
|
||||||
want to do this:
|
want to do this:
|
||||||
@@ -263,8 +263,7 @@ client.get("foo_rand000000000000", function (err, reply) {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
`client.end()` is useful for timeout cases where something is stuck or taking too long and you want
|
`client.end()` without the flush parameter should not be used in production!
|
||||||
to start over.
|
|
||||||
|
|
||||||
## client.unref()
|
## client.unref()
|
||||||
|
|
||||||
|
@@ -24,7 +24,9 @@ describe("client authentication", function () {
|
|||||||
client = null;
|
client = null;
|
||||||
});
|
});
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
// Explicitly ignore still running commands
|
||||||
|
// The ready command could still be running
|
||||||
|
client.end(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows auth to be provided with 'auth' method", function (done) {
|
it("allows auth to be provided with 'auth' method", function (done) {
|
||||||
|
@@ -61,8 +61,8 @@ describe("The 'blpop' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
bclient.end();
|
bclient.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -28,8 +28,8 @@ describe("The 'client' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
client2.end();
|
client2.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('list', function () {
|
describe('list', function () {
|
||||||
|
@@ -53,7 +53,7 @@ describe("The 'dbsize' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns a zero db size", function (done) {
|
it("returns a zero db size", function (done) {
|
||||||
|
@@ -50,7 +50,7 @@ describe("The 'del' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -22,7 +22,7 @@ describe("The 'eval' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts a float to an integer when evaluated', function (done) {
|
it('converts a float to an integer when evaluated', function (done) {
|
||||||
|
@@ -33,7 +33,7 @@ describe("The 'exits' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -35,7 +35,7 @@ describe("The 'expire' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -50,7 +50,7 @@ describe("The 'flushdb' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when there is data in Redis", function () {
|
describe("when there is data in Redis", function () {
|
||||||
|
@@ -28,7 +28,7 @@ describe("The 'geoadd' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -56,7 +56,7 @@ describe("The 'get' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when the key exists in Redis", function () {
|
describe("when the key exists in Redis", function () {
|
||||||
|
@@ -52,7 +52,7 @@ describe("The 'getset' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when the key exists in Redis", function () {
|
describe("when the key exists in Redis", function () {
|
||||||
|
@@ -77,7 +77,7 @@ describe("The 'hgetall' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -33,7 +33,7 @@ describe("The 'hincrby' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -31,7 +31,7 @@ describe("The 'hlen' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -64,7 +64,7 @@ describe("The 'hmget' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -110,7 +110,7 @@ describe("The 'hmset' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -56,7 +56,7 @@ describe("The 'hset' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -29,7 +29,7 @@ describe("The 'incr' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports an error", function (done) {
|
it("reports an error", function (done) {
|
||||||
@@ -64,7 +64,7 @@ describe("The 'incr' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("changes the last digit from 2 to 3", function (done) {
|
it("changes the last digit from 2 to 3", function (done) {
|
||||||
|
@@ -63,7 +63,7 @@ describe("The 'keys' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -63,7 +63,7 @@ describe("The 'mget' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -52,7 +52,7 @@ describe("The 'mset' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("and a callback is specified", function () {
|
describe("and a callback is specified", function () {
|
||||||
|
@@ -31,7 +31,7 @@ describe("The 'msetnx' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -28,7 +28,7 @@ describe("The 'randomkey' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -31,7 +31,7 @@ describe("The 'rename' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -34,7 +34,7 @@ describe("The 'renamenx' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -29,7 +29,7 @@ describe("The 'rpush' command", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -55,7 +55,7 @@ describe("The 'sadd' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -24,7 +24,7 @@ describe("The 'scard' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -23,7 +23,7 @@ describe("The 'script' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("loads script with client.script('load')", function (done) {
|
it("loads script with client.script('load')", function (done) {
|
||||||
|
@@ -40,7 +40,7 @@ describe("The 'sdiff' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -40,7 +40,7 @@ describe("The 'sdiffstore' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -41,7 +41,7 @@ describe("The 'select' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("changes the database and calls the callback", function (done) {
|
it("changes the database and calls the callback", function (done) {
|
||||||
|
@@ -50,7 +50,7 @@ describe("The 'set' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("and a callback is specified", function () {
|
describe("and a callback is specified", function () {
|
||||||
|
@@ -34,7 +34,7 @@ describe("The 'setex' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -30,7 +30,7 @@ describe("The 'setnx' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -56,7 +56,7 @@ describe("The 'sinter' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -41,7 +41,7 @@ describe("The 'sinterstore' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -28,7 +28,7 @@ describe("The 'sismember' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -34,7 +34,7 @@ describe("The 'slowlog' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -31,7 +31,7 @@ describe("The 'smembers' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -33,7 +33,7 @@ describe("The 'smove' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -122,7 +122,7 @@ describe("The 'sort' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -31,7 +31,7 @@ describe("The 'spop' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -62,7 +62,7 @@ describe("The 'srem' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -39,7 +39,7 @@ describe("The 'sunion' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -42,7 +42,7 @@ describe("The 'sunionstore' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -37,7 +37,7 @@ describe.skip("The 'sync' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -31,7 +31,7 @@ describe("The 'ttl' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -48,7 +48,7 @@ describe("The 'type' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -22,7 +22,7 @@ describe("The 'watch' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not execute transaction if watched key was modified prior to execution', function (done) {
|
it('does not execute transaction if watched key was modified prior to execution', function (done) {
|
||||||
|
@@ -40,7 +40,7 @@ describe("The 'zadd' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -42,7 +42,7 @@ describe("The 'zscan' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -28,7 +28,7 @@ describe("The 'zscore' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -16,7 +16,7 @@ describe("connection tests", function () {
|
|||||||
client = null;
|
client = null;
|
||||||
});
|
});
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("on lost connection", function () {
|
describe("on lost connection", function () {
|
||||||
@@ -174,7 +174,7 @@ describe("connection tests", function () {
|
|||||||
client.on('connect', function () {
|
client.on('connect', function () {
|
||||||
assert.strictEqual(client.stream._idleTimeout, -1);
|
assert.strictEqual(client.stream._idleTimeout, -1);
|
||||||
assert.strictEqual(client.stream._events.timeout, undefined);
|
assert.strictEqual(client.stream._events.timeout, undefined);
|
||||||
done();
|
client.on('ready', done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -32,7 +32,8 @@ describe("The node_redis client", function () {
|
|||||||
var client;
|
var client;
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
client.end();
|
// Explicitly ignore still running commands
|
||||||
|
client.end(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when connected", function () {
|
describe("when connected", function () {
|
||||||
@@ -97,11 +98,14 @@ describe("The node_redis client", function () {
|
|||||||
describe(".end", function () {
|
describe(".end", function () {
|
||||||
|
|
||||||
it('used without flush', function(done) {
|
it('used without flush', function(done) {
|
||||||
|
var finished = false;
|
||||||
var end = helper.callFuncAfter(function() {
|
var end = helper.callFuncAfter(function() {
|
||||||
|
if (!finished) {
|
||||||
done(new Error('failed'));
|
done(new Error('failed'));
|
||||||
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
var cb = function(err, res) {
|
var cb = function(err, res) {
|
||||||
assert.equal(err.message, "SET can't be processed. The connection has already been closed.");
|
assert(/The connection has already been closed/.test(err.message));
|
||||||
end();
|
end();
|
||||||
};
|
};
|
||||||
for (var i = 0; i < 20; i++) {
|
for (var i = 0; i < 20; i++) {
|
||||||
@@ -110,7 +114,10 @@ describe("The node_redis client", function () {
|
|||||||
}
|
}
|
||||||
client.set('foo', 'bar', cb);
|
client.set('foo', 'bar', cb);
|
||||||
}
|
}
|
||||||
setTimeout(done, 250);
|
setTimeout(function () {
|
||||||
|
finished = true;
|
||||||
|
done();
|
||||||
|
}, 250);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('used with flush set to true', function(done) {
|
it('used with flush set to true', function(done) {
|
||||||
@@ -255,14 +262,7 @@ describe("The node_redis client", function () {
|
|||||||
|
|
||||||
describe('domain', function () {
|
describe('domain', function () {
|
||||||
it('allows client to be executed from within domain', function (done) {
|
it('allows client to be executed from within domain', function (done) {
|
||||||
var domain;
|
var domain = require('domain').create();
|
||||||
|
|
||||||
try {
|
|
||||||
domain = require('domain').create();
|
|
||||||
} catch (err) {
|
|
||||||
console.log("Skipping test because this version of node doesn't have domains.");
|
|
||||||
return done();
|
|
||||||
}
|
|
||||||
|
|
||||||
domain.run(function () {
|
domain.run(function () {
|
||||||
client.set('domain', 'value', function (err, res) {
|
client.set('domain', 'value', function (err, res) {
|
||||||
@@ -505,19 +505,24 @@ describe("The node_redis client", function () {
|
|||||||
max_attempts: 0,
|
max_attempts: 0,
|
||||||
parser: parser
|
parser: parser
|
||||||
});
|
});
|
||||||
|
var finished = false;
|
||||||
client.on('error', function(e) {
|
client.on('error', function(e) {
|
||||||
// ignore, b/c expecting a "can't connect" error
|
// ignore, b/c expecting a "can't connect" error
|
||||||
});
|
});
|
||||||
|
|
||||||
return setTimeout(function() {
|
return setTimeout(function() {
|
||||||
client.set('foo', 'bar', function(err, result) {
|
client.set('foo', 'bar', function(err, result) {
|
||||||
|
if (!finished) {
|
||||||
// This should never be called
|
// This should never be called
|
||||||
return done(err);
|
return done(err);
|
||||||
|
} else {
|
||||||
|
assert.strictEqual(err.message, "The command can't be processed. The connection has already been closed.");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return setTimeout(function() {
|
return setTimeout(function() {
|
||||||
assert.strictEqual(client.offline_queue.length, 1);
|
assert.strictEqual(client.offline_queue.length, 1);
|
||||||
|
finished = true;
|
||||||
return done();
|
return done();
|
||||||
}, 25);
|
}, 25);
|
||||||
}, 50);
|
}, 50);
|
||||||
|
Reference in New Issue
Block a user