Skip to content

Commit 68936c5

Browse files
author
Benjamin Coe
committed
based on code-review added back check for error
1 parent bb1ab14 commit 68936c5

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

test/commands/multi.spec.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ describe("The 'multi' method", function () {
6060

6161
it('roles back a transaction when one command in a sequence of commands fails', function (done) {
6262
var multi1, multi2;
63+
var expected = helper.serverVersionAtLeast(client, [2, 6, 5]) ? helper.isError() : function () {};
6364

6465
// Provoke an error at queue time
6566
multi1 = client.MULTI();
6667
multi1.mset("multifoo", "10", "multibar", "20", helper.isString("OK"));
67-
multi1.set("foo2");
68+
69+
multi1.set("foo2", expected);
6870
multi1.incr("multifoo");
6971
multi1.incr("multibar");
7072
multi1.exec(function () {
@@ -90,31 +92,33 @@ describe("The 'multi' method", function () {
9092
});
9193

9294
it('roles back a transaction when one command in an array of commands fails', function (done) {
93-
// test nested multi-bulk replies
94-
client.multi([
95-
["mget", "multifoo", "multibar", function (err, res) {
96-
assert.strictEqual(2, res.length);
97-
assert.strictEqual(0, +res[0]);
98-
assert.strictEqual(0, +res[1]);
99-
}],
100-
["set", "foo2"],
101-
["incr", "multifoo"],
102-
["incr", "multibar"]
103-
]).exec(function (err, replies) {
104-
if (helper.serverVersionAtLeast(client, [2, 6, 5])) {
105-
assert.notEqual(err, null);
106-
assert.equal(replies, undefined);
107-
} else {
108-
assert.strictEqual(2, replies[0].length);
109-
assert.strictEqual(null, replies[0][0]);
110-
assert.strictEqual(null, replies[0][1]);
111-
112-
assert.strictEqual("1", replies[1].toString());
113-
assert.strictEqual("1", replies[2].toString());
114-
}
115-
116-
return done();
117-
});
95+
var expected = helper.serverVersionAtLeast(client, [2, 6, 5]) ? helper.isError() : function () {};
96+
97+
// test nested multi-bulk replies
98+
client.multi([
99+
["mget", "multifoo", "multibar", function (err, res) {
100+
assert.strictEqual(2, res.length);
101+
assert.strictEqual(0, +res[0]);
102+
assert.strictEqual(0, +res[1]);
103+
}],
104+
["set", "foo2", expected],
105+
["incr", "multifoo"],
106+
["incr", "multibar"]
107+
]).exec(function (err, replies) {
108+
if (helper.serverVersionAtLeast(client, [2, 6, 5])) {
109+
assert.notEqual(err, null);
110+
assert.equal(replies, undefined);
111+
} else {
112+
assert.strictEqual(2, replies[0].length);
113+
assert.strictEqual(null, replies[0][0]);
114+
assert.strictEqual(null, replies[0][1]);
115+
116+
assert.strictEqual("1", replies[1].toString());
117+
assert.strictEqual("1", replies[2].toString());
118+
}
119+
120+
return done();
121+
});
118122
});
119123

120124
it('handles multiple operations being applied to a set', function (done) {

0 commit comments

Comments
 (0)