Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Also delete system.indexes - Fix #13

  • Loading branch information...
commit 5bd075e21410154cad956121403a1dda99109a1e 1 parent 115843f
@emerleite authored
Showing with 12 additions and 25 deletions.
  1. +3 −11 lib/database-cleaner.js
  2. +9 −14 test/mongodb.test.js
View
14 lib/database-cleaner.js
@@ -7,19 +7,11 @@ module.exports = DatabaseCleaner = function(type) {
if (count < 1) { return callback.apply(); }
collections.forEach(function (collection) {
- if (collection.collectionName != 'system.indexes') {
- collection.remove({}, function () {
- count--;
- if (count <= 0 && callback) {
- callback.apply();
- }
- });
- } else {
- count--;
- if (count <= 0 && callback) {
+ collection.drop(function () {
+ if (--count <= 0 && callback) {
callback.apply();
}
- }
+ });
});
});
};
View
23 test/mongodb.test.js
@@ -30,18 +30,13 @@ describe('mongodb', function() {
db.collections( function (skip, collections) {
var total_collections = collections.length;
collections.forEach(function (collection) {
- if (collection.collectionName != 'system.indexes') {
- collection.count({}, function (err, count) {
- count.should.equal(0);
- total_collections--;
- if (total_collections <= 0) {
- tearDown(db);
- done();
- }
- });
- } else {
- total_collections--;
- }
+ collection.count({}, function (err, count) {
+ count.should.equal(0);
+ if (--total_collections <= 0) {
+ tearDown(db);
+ done();
+ }
+ });
});
});
});
@@ -56,12 +51,12 @@ describe('mongodb', function() {
});
});
- it('should not delete system.indexes collection', function(done) {
+ it('should also delete system.indexes collection', function(done) {
setUp(function(db) {
databaseCleaner.clean(db, function () {
db.collection('system.indexes', function (skip, collection) {
collection.count({}, function (err, count) {
- (count > 0).should.be.true;
+ (count > 0).should.be.false;
done();
tearDown(db);
});
Please sign in to comment.
Something went wrong with that request. Please try again.