mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge pull request #2202 from justinsb/cleanup_collections
Drop collections after test (WIP)
This commit is contained in:
@@ -24,6 +24,10 @@ if (Meteor.isServer) {
|
||||
Meteor.publish('c-' + name, function () {
|
||||
return c.find();
|
||||
});
|
||||
},
|
||||
dropInsecureCollection: function(name) {
|
||||
var c = COLLECTIONS[name];
|
||||
c._dropCollection();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2338,14 +2342,21 @@ _.each( ['STRING', 'MONGO'], function (idGeneration) {
|
||||
testAsyncMulti('mongo-livedata - consistent _id generation ' + name + ', ' + repetitions + ' repetitions on ' + collectionCount + ' collections, idGeneration=' + idGeneration, [ function (test, expect) {
|
||||
var collectionOptions = { idGeneration: idGeneration };
|
||||
|
||||
var cleanups = this.cleanups = [];
|
||||
this.collections = _.times(collectionCount, function () {
|
||||
var collectionName = "consistentid_" + Random.id();
|
||||
if (Meteor.isClient) {
|
||||
Meteor.call('createInsecureCollection', collectionName, collectionOptions);
|
||||
Meteor.subscribe('c-' + collectionName, expect());
|
||||
cleanups.push(function (expect) { Meteor.call('dropInsecureCollection', collectionName, expect(function () {})); });
|
||||
}
|
||||
|
||||
return (COLLECTIONS[collectionName] = new Meteor.Collection(collectionName, collectionOptions));
|
||||
var collection = new Meteor.Collection(collectionName, collectionOptions);
|
||||
if (Meteor.isServer) {
|
||||
cleanups.push(function () { collection._dropCollection(); });
|
||||
}
|
||||
COLLECTIONS[collectionName] = collection;
|
||||
return collection;
|
||||
});
|
||||
}, function (test, expect) {
|
||||
// now run the actual test
|
||||
@@ -2354,6 +2365,11 @@ _.each( ['STRING', 'MONGO'], function (idGeneration) {
|
||||
fn(test, expect, this.collections[j], i);
|
||||
}
|
||||
}
|
||||
}, function (test, expect) {
|
||||
// Run any registered cleanup functions (e.g. to drop collections)
|
||||
_.each(this.cleanups, function(cleanup) {
|
||||
cleanup(expect);
|
||||
});
|
||||
}]);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user