Skip to content

Commit 1ae280d

Browse files
author
Ruben Bridgewater
committed
Fix some tests and deactivate broken ones
1 parent ba779ac commit 1ae280d

File tree

6 files changed

+15
-94
lines changed

6 files changed

+15
-94
lines changed

test/commands/hmget.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ describe("The 'hmget' method", function () {
1818
client.once("error", done);
1919
client.once("connect", function () {
2020
client.flushdb();
21-
client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value"}, helper.isString('OK'));
22-
return done();
21+
client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value"}, helper.isString('OK', done));
2322
});
2423
});
2524

test/commands/mset.spec.js

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ describe("The 'mset' method", function () {
6060
describe("and a callback is specified", function () {
6161
describe("with valid parameters", function () {
6262
it("sets the value correctly", function (done) {
63-
client.mset(key, value, key2, value2);
64-
client.get(key, helper.isString(value));
65-
client.get(key2, helper.isString(value2, done));
63+
client.mset(key, value, key2, value2, function(err) {
64+
if (err) {
65+
return done(err);
66+
}
67+
client.get(key, helper.isString(value));
68+
client.get(key2, helper.isString(value2, done));
69+
});
6670
});
6771
});
6872

@@ -75,14 +79,6 @@ describe("The 'mset' method", function () {
7579
});
7680
});
7781

78-
describe("with undefined 'key' and defined 'value' parameters", function () {
79-
it("reports an error", function () {
80-
client.mset(undefined, value, undefined, value2, function (err, res) {
81-
helper.isError()(err, null);
82-
done();
83-
});
84-
});
85-
});
8682
});
8783

8884
describe("and no callback is specified", function () {
@@ -108,19 +104,6 @@ describe("The 'mset' method", function () {
108104
client.mset();
109105
});
110106
});
111-
112-
describe("with undefined 'key' and defined 'value' parameters", function () {
113-
it("throws an error", function () {
114-
var mochaListener = helper.removeMochaListener();
115-
116-
process.once('uncaughtException', function (err) {
117-
process.on('uncaughtException', mochaListener);
118-
helper.isError()(err, null);
119-
});
120-
121-
client.mset(undefined, value, undefined, value2);
122-
});
123-
});
124107
});
125108
});
126109
});

test/commands/set.spec.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ describe("The 'set' method", function () {
7676
});
7777
});
7878
});
79-
80-
describe("with undefined 'key' and defined 'value' parameters", function () {
81-
it("reports an error", function () {
82-
client.set(undefined, value, function (err, res) {
83-
helper.isError()(err, null);
84-
done();
85-
});
86-
});
87-
});
8879
});
8980

9081
describe("and no callback is specified", function () {
@@ -132,19 +123,6 @@ describe("The 'set' method", function () {
132123
}, 100);
133124
});
134125
});
135-
136-
describe("with undefined 'key' and defined 'value' parameters", function () {
137-
it("throws an error", function () {
138-
var mochaListener = helper.removeMochaListener();
139-
140-
process.once('uncaughtException', function (err) {
141-
process.on('uncaughtException', mochaListener);
142-
helper.isError()(err, null);
143-
});
144-
145-
client.set(undefined, value);
146-
});
147-
});
148126
});
149127
});
150128
});

test/commands/setnx.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ describe("The 'setnx' method", function () {
2828
client.set('foo', 'bar', helper.isString('OK'));
2929
client.setnx('foo', 'banana', helper.isNumber(0));
3030
client.get('foo', helper.isString('bar', done));
31-
return done();
3231
});
3332

3433
afterEach(function () {

test/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
},
5959
isError: function (done) {
6060
return function (err, results) {
61-
assert.notEqual(err, null, "err is null, but an error is expected here.");
61+
assert(err instanceof Error, "err is not instance of 'Error', but an error is expected here.");
6262
if (done) return done();
6363
};
6464
},

test/node_redis.spec.js

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -188,54 +188,16 @@ describe("The node_redis client", function () {
188188
// Does not pass.
189189
// "Connection in subscriber mode, only subscriber commands may be used"
190190
it("reconnects, unsubscribes, and can retrieve the pre-existing data", function (done) {
191-
client.on("reconnecting", function on_recon(params) {
192-
client.on("ready", function on_connect() {
193-
client.unsubscribe(helper.isNotError());
194-
195-
client.on('unsubscribe', function (channel, count) {
196-
// we should now be out of subscriber mode.
197-
client.set('foo', 'bar', helper.isNumber(1));
198-
return done();
199-
});
200-
});
201-
});
191+
client.on("ready", function on_connect() {
192+
client.unsubscribe(helper.isNotError());
202193

203-
client.set("recon 1", "one");
204-
client.subscribe("recon channel", function (err, res) {
205-
// Do not do this in normal programs. This is to simulate the server closing on us.
206-
// For orderly shutdown in normal programs, do client.quit()
207-
client.stream.destroy();
208-
});
209-
});
210-
211-
it("remains subscribed", function () {
212-
var client2 = redis.createClient.apply(redis.createClient, args);
213-
214-
client.on("reconnecting", function on_recon(params) {
215-
client.on("ready", function on_connect() {
216-
async.parallel([function (cb) {
217-
client.on("message", function (channel, message) {
218-
try {
219-
helper.isString("recon channel")(null, channel);
220-
helper.isString("a test message")(null, message);
221-
} catch (err) {
222-
cb(err);
223-
}
224-
});
225-
226-
client2.subscribe("recon channel", function (err, res) {
227-
if (err) {
228-
cb(err);
229-
return;
230-
}
231-
client2.publish("recon channel", "a test message");
232-
});
233-
}], function (err, results) {
234-
done(err);
235-
});
194+
client.on('unsubscribe', function (channel, count) {
195+
// we should now be out of subscriber mode.
196+
client.set('foo', 'bar', helper.isString('OK', done));
236197
});
237198
});
238199

200+
client.set("recon 1", "one");
239201
client.subscribe("recon channel", function (err, res) {
240202
// Do not do this in normal programs. This is to simulate the server closing on us.
241203
// For orderly shutdown in normal programs, do client.quit()

0 commit comments

Comments
 (0)