Executor bug completely fixed

pull/2/head
Louis Chatriot 11 years ago
parent 272c40e062
commit b1b43008c9
  1. 2
      lib/executor.js
  2. 34
      test/executor.test.js

@ -22,7 +22,7 @@ function Executor () {
// Always tell the queue task is complete. Execute callback if any was given.
if (typeof lastArg === 'function') {
callback = function () {
cb();
process.nextTick(cb);
lastArg.apply(null, arguments);
};

@ -49,26 +49,36 @@ function testRightOrder (d, done) {
// Do nothing with the error which is only there to test we stay on track
});
d.find({}, function (err) {
process.nextTick(function () {
d.insert({ bar: 1 }, function (err) {
for (var i = 0; i < currentUncaughtExceptionHandlers.length; i += 1) {
process.on('uncaughtException', currentUncaughtExceptionHandlers[i]);
}
d.find({}, function (err, docs) {
docs.length.should.equal(0);
d.insert({ a: 1 }, function () {
d.update({ a: 1 }, { a: 2 }, {}, function () {
d.find({}, function (err, docs) {
docs[0].a.should.equal(2);
process.nextTick(function () {
d.update({ a: 2 }, { a: 3 }, {}, function () {
d.find({}, function (err, docs) {
docs[0].a.should.equal(3);
done();
});
});
});
throw 'Some error';
});
});
});
});
}
describe('Executor', function () {
describe.only('With persistent database', function () {
describe('With persistent database', function () {
var d;
beforeEach(function (done) {
@ -100,6 +110,10 @@ describe('Executor', function () {
testThrowInCallback(d, done);
});
it('Operations are executed in the right order', function(done) {
testRightOrder(d, done);
});
}); // ==== End of 'With persistent database' ====
@ -113,7 +127,7 @@ describe('Executor', function () {
d.loadDatabase(function (err) {
assert.isNull(err);
d.getAllData().length.should.equal(0);
return cb();
return done();
});
});
@ -121,6 +135,10 @@ describe('Executor', function () {
testThrowInCallback(d, done);
});
it('Operations are executed in the right order', function(done) {
testRightOrder(d, done);
});
}); // ==== End of 'With non persistent database' ====
});

Loading…
Cancel
Save