|
|
|
@ -251,8 +251,7 @@ describe('Database', function () { |
|
|
|
|
it('If a bulk insert violates a constraint, all changes are rolled back', function (done) { |
|
|
|
|
var docs = [{ a: 5, b: 'hello' }, { a: 42, b: 'world' }, { a: 5, b: 'bloup' }, { a: 7 }]; |
|
|
|
|
|
|
|
|
|
d.ensureIndex({ fieldName: 'a', unique: true }); |
|
|
|
|
|
|
|
|
|
d.ensureIndex({ fieldName: 'a', unique: true }, function () { // Important to specify callback here to make sure filesystem synced
|
|
|
|
|
d.insert(docs, function (err) { |
|
|
|
|
err.errorType.should.equal('uniqueViolated'); |
|
|
|
|
|
|
|
|
@ -266,6 +265,10 @@ describe('Database', function () { |
|
|
|
|
done(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('Can insert a doc with id 0', function (done) { |
|
|
|
|