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