All tests pass

pull/2/head
Louis Chatriot 9 years ago
parent 7c25401f16
commit d446bdbf36
  1. 15
      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,13 +539,24 @@ 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 () {
// After compaction, no more mention of the document, correctly removed
var datafileContents = fs.readFileSync(testDb, 'utf8');
datafileContents.split('\n').length.should.equal(2);
assert.isNull(datafileContents.match(/world/));
// 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(err);
assert.isNull(doc); assert.isNull(doc);
done(); done();
}); });
}); });
d.persistence.compactDatafile();
});
}, 101); }, 101);
}); });
}, 100); }, 100);

Loading…
Cancel
Save