mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Rely solely on indices (with some icky error parsing) to generate "user/email already exists" errors. Not yet making the ensureIndex API public. Not indexing the tiny loginServiceConfiguration collection. Indexing tinytest_results.
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
Meteor.startup(function () {
|
|
Meteor._ServerTestResults.remove();
|
|
// Index is definitely not unique and doesn't need to be sparse.
|
|
Meteor._ServerTestResults._ensureIndex('run_id');
|
|
});
|
|
|
|
Meteor.publish('tinytest/results', function (run_id) {
|
|
return Meteor._ServerTestResults.find({run_id: run_id},
|
|
{key: {collection: 'tinytest_results',
|
|
run_id: run_id}});
|
|
});
|
|
|
|
Meteor.methods({
|
|
'tinytest/run': function (run_id) {
|
|
this.unblock();
|
|
|
|
// XXX using private API === lame
|
|
var Future = __meteor_bootstrap__.require('fibers/future');
|
|
var future = new Future;
|
|
|
|
var onReport = function (report) {
|
|
if (! Fiber.current) {
|
|
Meteor._debug("Trying to report a test not in a fiber! "+
|
|
"You probably forgot to wrap a callback in bindEnvironment.");
|
|
console.trace();
|
|
}
|
|
Meteor._ServerTestResults.insert({run_id: run_id, report: report});
|
|
Meteor.refresh({collection: 'tinytest_results', run_id: run_id});
|
|
};
|
|
|
|
var onComplete = function() {
|
|
future.ret();
|
|
};
|
|
|
|
Meteor._runTests(onReport, onComplete);
|
|
|
|
future.wait();
|
|
}
|
|
});
|