Skip to content

Commit

Permalink
Stricten tests by always ending redis with .end(true) if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Bridgewater committed Nov 22, 2015
1 parent 0913a4d commit 8bf794f
Show file tree
Hide file tree
Showing 57 changed files with 83 additions and 77 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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
want to do this:
Expand All @@ -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
to start over.
`client.end()` without the flush parameter should not be used in production!

## client.unref()

Expand Down
4 changes: 3 additions & 1 deletion test/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ describe("client authentication", function () {
client = null;
});
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) {
Expand Down
4 changes: 2 additions & 2 deletions test/commands/blpop.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ describe("The 'blpop' method", function () {
});

afterEach(function () {
client.end();
bclient.end();
client.end(true);
bclient.end(true);
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/commands/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe("The 'client' method", function () {
});

afterEach(function () {
client.end();
client2.end();
client.end(true);
client2.end(true);
});

describe('list', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dbsize.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("The 'dbsize' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

it("returns a zero db size", function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/del.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("The 'del' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/eval.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("The 'eval' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

it('converts a float to an integer when evaluated', function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/exits.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("The 'exits' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/expire.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("The 'expire' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/flushdb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("The 'flushdb' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

describe("when there is data in Redis", function () {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/geoadd.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("The 'geoadd' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("The 'get' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

describe("when the key exists in Redis", function () {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/getset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("The 'getset' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

describe("when the key exists in Redis", function () {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/hgetall.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("The 'hgetall' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/hincrby.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("The 'hincrby' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/hlen.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("The 'hlen' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/hmget.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("The 'hmget' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/hmset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe("The 'hmset' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/hset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("The 'hset' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/commands/incr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("The 'incr' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

it("reports an error", function (done) {
Expand Down Expand Up @@ -64,7 +64,7 @@ describe("The 'incr' method", function () {
});

after(function () {
client.end();
client.end(true);
});

it("changes the last digit from 2 to 3", function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/keys.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("The 'keys' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/mget.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("The 'mget' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/mset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("The 'mset' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

describe("and a callback is specified", function () {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/msetnx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("The 'msetnx' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/randomkey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("The 'randomkey' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/rename.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("The 'rename' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/renamenx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("The 'renamenx' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/rpush.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("The 'rpush' command", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/sadd.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("The 'sadd' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/scard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("The 'scard' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/script.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("The 'script' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

it("loads script with client.script('load')", function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/sdiff.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("The 'sdiff' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/sdiffstore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("The 'sdiffstore' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("The 'select' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

it("changes the database and calls the callback", function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/set.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("The 'set' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});

describe("and a callback is specified", function () {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/setex.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("The 'setex' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/setnx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("The 'setnx' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/sinter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("The 'sinter' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/sinterstore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("The 'sinterstore' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/sismember.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("The 'sismember' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/slowlog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("The 'slowlog' method", function () {
});

afterEach(function () {
client.end();
client.end(true);
});
});
});
Expand Down
Loading

0 comments on commit 8bf794f

Please sign in to comment.