Clean up Mongo databases created by the test suite.

This commit is contained in:
Will Daly
2014-02-04 15:52:01 -05:00
parent 54f508a01f
commit 8ee601a5e3
3 changed files with 54 additions and 8 deletions

View File

@@ -0,0 +1,24 @@
/*
Drop all Mongo test databases.
Usage example:
mongo delete-mongo-test-dbs.js
will drop every database that starts with "test_" or "acceptance_",
but ignore other databases.
*/
String.prototype.startsWith = function(substring) {
return (this.indexOf(substring) == 0);
}
var dbNameList = db.getMongo().getDBNames();
for (var i in dbNameList) {
if (dbNameList[i].startsWith('test_') || dbNameList[i].startsWith('acceptance_')) {
dbToDrop = db.getMongo().getDB(dbNameList[i]);
print("Dropping test db " + dbNameList[i]);
dbToDrop.dropDatabase();
}
}