Executor bug completely fixed

pull/2/head
Louis Chatriot 11 years ago
parent 272c40e062
commit b1b43008c9
  1. 2
      lib/executor.js
  2. 40
      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,18 +49,28 @@ 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);
done();
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';
});
});
});
throw 'Some error';
});
}
@ -68,7 +78,7 @@ function testRightOrder (d, done) {
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