Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Adding tests to cover three of the four remaining code paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ellis committed Jun 18, 2013
1 parent 8196048 commit 76aeb60
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,33 @@ exports.onlyConfirmOnce = function(test) {
myWriter.setnx('hai', 'there', function(err, result) {
test.equal(result[0].primary, 1);
test.equal(result[1].secondary, 'OK');
myServers.shutdown(test.done.bind(test));
});
};

exports.onlyConfirmOnce2 = function(test) {
test.expect(2);
var myServers = new RedisBroadcast({
primary: [6379, 'localhost'],
secondary: [6379, 'localhost']
}, { onlyConfirmOnce: true });
var myWriter = myServers.writeTo('primary').thenTo('secondary');
myWriter.setnx('hai', 'there', function(err, result) {
test.equal(result.length, 1);
test.equal(result[0].primary, 0);
myServers.shutdown(test.done.bind(test));
});
};

exports.onlyConfirmOnceFailPath = function(test) {
test.expect(1);
var myServers = new RedisBroadcast({
primary: [6379, 'localhost'],
secondary: [6379, 'localhost']
}, { onlyConfirmOnce: true });
var myWriter = myServers.writeTo('primary').thenTo('secondary');
myWriter.setnx(undefined, undefined, function(err) {
test.ok(err);
myServers.shutdown({ killChildProc: true }, test.done.bind(test));
});
};
Expand Down

0 comments on commit 76aeb60

Please sign in to comment.