Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into reset-all-buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalouin committed Sep 20, 2018
2 parents 8585ef1 + 71997f6 commit c50b25e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ class LimitdRedis extends EventEmitter {
resetAll(cb) {
this.db.resetAll(cb);
}

close(callback) {
this.db.close((err) => {
this.db.removeAllListeners();
callback(err);
});
}
}

module.exports = LimitdRedis;
Expand Down
11 changes: 11 additions & 0 deletions test/client.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,15 @@ describe('LimitdRedis', () => {
client.resetAll(done);
});
});

describe('#close', () => {
it('should call db.close', (done) => {
client.db.close = (cb) => cb();
client.close((err) => {
assert.equal(client.db.listenerCount('error'), 0);
assert.equal(client.db.listenerCount('ready'), 0);
done(err);
});
});
});
});

0 comments on commit c50b25e

Please sign in to comment.