Even faster tests (#4868)

* Various improvements in test name / de-duplications

* Reverts to class by class deletion, introduced fast mode that just delete data for mongo

- Speeds up are incredible Executed 1695 of 1713 specs INCOMPLETE (18 PENDING) in 4 mins 19 secs.

* Adds documentation about the deleteEverything
This commit is contained in:
Florent Vilmart
2018-07-03 11:13:08 -04:00
committed by GitHub
parent ae1a8226d5
commit 960431b92d
18 changed files with 648 additions and 651 deletions

View File

@@ -31,6 +31,22 @@ const MongoClient = mongodb.MongoClient;
const ReadPreference = mongodb.ReadPreference;
const MongoSchemaCollectionName = '_SCHEMA';
const storageAdapterAllCollections = mongoAdapter => {
return mongoAdapter.connect()
.then(() => mongoAdapter.database.collections())
.then(collections => {
return collections.filter(collection => {
if (collection.namespace.match(/\.system\./)) {
return false;
}
// TODO: If you have one app with a collection prefix that happens to be a prefix of another
// apps prefix, this will go very very badly. We should fix that somehow.
return (collection.collectionName.indexOf(mongoAdapter._collectionPrefix) == 0);
});
});
}
const convertParseSchemaToMongoSchema = ({...schema}) => {
delete schema.fields._rperm;
delete schema.fields._wperm;
@@ -297,9 +313,9 @@ export class MongoStorageAdapter implements StorageAdapter {
.catch(err => this.handleError(err));
}
dropDatabase() {
if (!this.database) { return Promise.resolve(); }
return this.database.dropDatabase();
deleteAllClasses(fast: boolean) {
return storageAdapterAllCollections(this)
.then(collections => Promise.all(collections.map(collection => fast ? collection.remove({}) : collection.drop())));
}
// Remove the column and all the data. For Relations, the _Join collection is handled