You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Improve code coverage by adding tests and removing unnecessary code
This commit is contained in:
@@ -37,6 +37,14 @@ describe("The 'hmget' method", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('allows keys to be specified by passing an array as first argument', function (done) {
|
||||
client.HMGET([hash, "0123456789", "some manner of key"], function (err, reply) {
|
||||
assert.strictEqual("abcdefghij", reply[0].toString());
|
||||
assert.strictEqual("a type of value", reply[1].toString());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('allows a single key to be specified in an array', function (done) {
|
||||
client.HMGET(hash, ["0123456789"], function (err, reply) {
|
||||
assert.strictEqual("abcdefghij", reply[0].toString());
|
||||
|
@@ -20,7 +20,7 @@ describe("The 'hmset' method", function () {
|
||||
});
|
||||
|
||||
it('handles redis-style syntax', function (done) {
|
||||
client.HMSET(hash, "0123456789", "abcdefghij", "some manner of key", "a type of value", helper.isString('OK'));
|
||||
client.HMSET(hash, "0123456789", "abcdefghij", "some manner of key", "a type of value", "otherTypes", 555, helper.isString('OK'));
|
||||
client.HGETALL(hash, function (err, obj) {
|
||||
assert.equal(obj['0123456789'], 'abcdefghij');
|
||||
assert.equal(obj['some manner of key'], 'a type of value');
|
||||
@@ -29,7 +29,7 @@ describe("The 'hmset' method", function () {
|
||||
});
|
||||
|
||||
it('handles object-style syntax', function (done) {
|
||||
client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value"}, helper.isString('OK'));
|
||||
client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}, helper.isString('OK'));
|
||||
client.HGETALL(hash, function (err, obj) {
|
||||
assert.equal(obj['0123456789'], 'abcdefghij');
|
||||
assert.equal(obj['some manner of key'], 'a type of value');
|
||||
@@ -37,6 +37,15 @@ describe("The 'hmset' method", function () {
|
||||
})
|
||||
});
|
||||
|
||||
it('handles object-style syntax and the key being a number', function (done) {
|
||||
client.HMSET(231232, {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}, helper.isString('OK'));
|
||||
client.HGETALL(231232, function (err, obj) {
|
||||
assert.equal(obj['0123456789'], 'abcdefghij');
|
||||
assert.equal(obj['some manner of key'], 'a type of value');
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('allows a numeric key', function (done) {
|
||||
client.HMSET(hash, 99, 'banana', helper.isString('OK'));
|
||||
client.HGETALL(hash, function (err, obj) {
|
||||
|
@@ -7,12 +7,6 @@ var uuid = require('uuid');
|
||||
|
||||
describe("The 'mset' method", function () {
|
||||
|
||||
function removeMochaListener () {
|
||||
var mochaListener = process.listeners('uncaughtException').pop();
|
||||
process.removeListener('uncaughtException', mochaListener);
|
||||
return mochaListener;
|
||||
}
|
||||
|
||||
helper.allTests(function(parser, ip, args) {
|
||||
|
||||
describe("using " + parser + " and " + ip, function () {
|
||||
@@ -102,7 +96,7 @@ describe("The 'mset' method", function () {
|
||||
describe("with undefined 'key' and missing 'value' parameter", function () {
|
||||
// this behavior is different from the 'set' behavior.
|
||||
it("throws an error", function (done) {
|
||||
var mochaListener = removeMochaListener();
|
||||
var mochaListener = helper.removeMochaListener();
|
||||
|
||||
process.once('uncaughtException', function (err) {
|
||||
process.on('uncaughtException', mochaListener);
|
||||
@@ -116,7 +110,7 @@ describe("The 'mset' method", function () {
|
||||
|
||||
describe("with undefined 'key' and defined 'value' parameters", function () {
|
||||
it("throws an error", function () {
|
||||
var mochaListener = removeMochaListener();
|
||||
var mochaListener = helper.removeMochaListener();
|
||||
|
||||
process.once('uncaughtException', function (err) {
|
||||
process.on('uncaughtException', mochaListener);
|
||||
|
@@ -6,12 +6,6 @@ var redis = config.redis;
|
||||
|
||||
describe("The 'select' method", function () {
|
||||
|
||||
function removeMochaListener () {
|
||||
var mochaListener = process.listeners('uncaughtException').pop();
|
||||
process.removeListener('uncaughtException', mochaListener);
|
||||
return mochaListener;
|
||||
}
|
||||
|
||||
helper.allTests(function(parser, ip, args) {
|
||||
|
||||
describe("using " + parser + " and " + ip, function () {
|
||||
@@ -96,7 +90,7 @@ describe("The 'select' method", function () {
|
||||
|
||||
describe("with an invalid db index", function () {
|
||||
it("throws an error when callback not provided", function (done) {
|
||||
var mochaListener = removeMochaListener();
|
||||
var mochaListener = helper.removeMochaListener();
|
||||
assert.strictEqual(client.selected_db, null, "default db should be null");
|
||||
|
||||
process.once('uncaughtException', function (err) {
|
||||
|
@@ -7,12 +7,6 @@ var uuid = require('uuid');
|
||||
|
||||
describe("The 'set' method", function () {
|
||||
|
||||
function removeMochaListener () {
|
||||
var mochaListener = process.listeners('uncaughtException').pop();
|
||||
process.removeListener('uncaughtException', mochaListener);
|
||||
return mochaListener;
|
||||
}
|
||||
|
||||
helper.allTests(function(parser, ip, args) {
|
||||
|
||||
describe("using " + parser + " and " + ip, function () {
|
||||
@@ -123,7 +117,7 @@ describe("The 'set' method", function () {
|
||||
|
||||
it("does not throw an error", function (done) {
|
||||
this.timeout(200);
|
||||
var mochaListener = removeMochaListener();
|
||||
var mochaListener = helper.removeMochaListener();
|
||||
|
||||
process.once('uncaughtException', function (err) {
|
||||
process.on('uncaughtException', mochaListener);
|
||||
@@ -140,7 +134,7 @@ describe("The 'set' method", function () {
|
||||
|
||||
describe("with undefined 'key' and defined 'value' parameters", function () {
|
||||
it("throws an error", function () {
|
||||
var mochaListener = removeMochaListener();
|
||||
var mochaListener = helper.removeMochaListener();
|
||||
|
||||
process.once('uncaughtException', function (err) {
|
||||
process.on('uncaughtException', mochaListener);
|
||||
|
Reference in New Issue
Block a user