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

Use .end(true) to stricten test cases and improve coverage

This commit is contained in:
Ruben Bridgewater
2015-11-23 23:11:31 +01:00
parent f877c3950c
commit d55017a01e
8 changed files with 37 additions and 12 deletions

View File

@@ -60,7 +60,7 @@ describe("The 'batch' method", function () {
}); });
afterEach(function () { afterEach(function () {
client.end(); client.end(true);
}); });
it("returns an empty array", function (done) { it("returns an empty array", function (done) {

View File

@@ -28,7 +28,7 @@ describe("detect_buffers", function () {
}); });
afterEach(function () { afterEach(function () {
client.end(); client.end(true);
}); });
describe('get', function () { describe('get', function () {

View File

@@ -11,7 +11,7 @@ var client;
describe("The 'multi' method", function () { describe("The 'multi' method", function () {
afterEach(function () { afterEach(function () {
client.end(); client.end(true);
}); });
describe('regression test', function () { describe('regression test', function () {

View File

@@ -96,6 +96,30 @@ describe("The node_redis client", function () {
done(); done();
}); });
}); });
it('safe strings that are bigger than 30000 characters with multi', function(done) {
var str = 'foo ಠ_ಠ bar ';
while (str.length < 111111) {
str += str;
}
var called = false;
var temp = client.writeBuffers.bind(client);
assert(String(client.writeBuffers) !== String(client.writeDefault));
client.writeBuffers = function (data) {
called = true;
// To increase write performance for strings the value is converted to a buffer
assert(String(client.writeBuffers) === String(client.writeDefault));
temp(data);
};
client.multi().set('foo', str).get('foo', function (err, res) {
assert.strictEqual(res, str);
}).exec(function (err, res) {
assert(called);
assert.strictEqual(res[1], str);
done();
});
assert(String(client.writeBuffers) !== String(client.writeDefault));
});
}); });
describe("send_command", function () { describe("send_command", function () {
@@ -135,7 +159,7 @@ describe("The node_redis client", function () {
describe(".end", function () { describe(".end", function () {
it('used without flush', function(done) { it('used without flush / flush set to false', function(done) {
var finished = false; var finished = false;
var end = helper.callFuncAfter(function() { var end = helper.callFuncAfter(function() {
if (!finished) { if (!finished) {
@@ -513,7 +537,7 @@ describe("The node_redis client", function () {
client.retry_backoff = 1; client.retry_backoff = 1;
client.stream.end(); client.stream.end();
} else { } else {
client.end(); client.end(true);
var lasted = new Date().getTime() - time; var lasted = new Date().getTime() - time;
assert.ok(lasted < 100); assert.ok(lasted < 100);
return done(); return done();

View File

@@ -367,8 +367,8 @@ describe("publish/subscribe", function () {
}); });
afterEach(function () { afterEach(function () {
sub.end(); sub.end(true);
pub.end(); pub.end(true);
}); });
}); });
}); });

View File

@@ -22,7 +22,8 @@ describe("rename commands", function () {
rename_commands: { rename_commands: {
set: '807081f5afa96845a02816a28b7258c3', set: '807081f5afa96845a02816a28b7258c3',
GETRANGE: '9e3102b15cf231c4e9e940f284744fe0' GETRANGE: '9e3102b15cf231c4e9e940f284744fe0'
} },
parser: parser
}); });
client.on('ready', function () { client.on('ready', function () {
@@ -31,7 +32,7 @@ describe("rename commands", function () {
}); });
afterEach(function () { afterEach(function () {
client.end(); client.end(true);
}); });
it("allows to use renamed functions", function (done) { it("allows to use renamed functions", function (done) {

View File

@@ -277,8 +277,8 @@ describe("return_buffers", function () {
}); });
afterEach(function () { afterEach(function () {
sub.end(); sub.end(true);
pub.end(); pub.end(true);
}); });
}); });
}); });

View File

@@ -126,7 +126,7 @@ describe("TLS connection tests", function () {
}); });
client.on("reconnecting", function (params) { client.on("reconnecting", function (params) {
client.end(); client.end(true);
setTimeout(done, 100); setTimeout(done, 100);
}); });
}); });