All tests pass

pull/2/head
Louis Chatriot 9 years ago
parent 7c25401f16
commit d446bdbf36
  1. 21
      test/db.test.js

@ -424,7 +424,7 @@ describe('Database', function () {
}); // ==== End of 'Insert' ==== // }); // ==== End of 'Insert' ==== //
describe.only('#getCandidates', function () { describe('#getCandidates', function () {
it('Can use an index to get docs with a basic match', function (done) { it('Can use an index to get docs with a basic match', function (done) {
d.ensureIndex({ fieldName: 'tf' }, function (err) { d.ensureIndex({ fieldName: 'tf' }, function (err) {
@ -539,12 +539,23 @@ describe('Database', function () {
assert.isNull(err); assert.isNull(err);
assert.isNull(doc); assert.isNull(doc);
d.findOne({}, function (err, doc) { d.on('compaction.done', function () {
assert.isNull(err); // After compaction, no more mention of the document, correctly removed
assert.isNull(doc); var datafileContents = fs.readFileSync(testDb, 'utf8');
datafileContents.split('\n').length.should.equal(2);
assert.isNull(datafileContents.match(/world/));
done(); // New datastore on same datafile is empty
var d2 = new Datastore({ filename: testDb, autoload: true });
d2.findOne({}, function (err, doc) {
assert.isNull(err);
assert.isNull(doc);
done();
});
}); });
d.persistence.compactDatafile();
}); });
}, 101); }, 101);
}); });

Loading…
Cancel
Save