From d6ce52143224799546401aecb8a210ca203292b8 Mon Sep 17 00:00:00 2001 From: Leonardo Venturini Date: Wed, 23 Oct 2024 07:54:47 -0400 Subject: [PATCH] cleanup collections before starting tests --- packages/mongo/package.js | 2 +- packages/tinytest/tinytest_server.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/mongo/package.js b/packages/mongo/package.js index bdedaa4c0c..59e3ac2efe 100644 --- a/packages/mongo/package.js +++ b/packages/mongo/package.js @@ -109,7 +109,7 @@ Package.onTest(function (api) { api.use('ecmascript'); api.use('npm-mongo', 'server'); api.use(['tinytest', 'test-helpers', 'ejson', 'random', - 'ddp', 'base64']); + 'ddp', 'base64', 'typescript']); // XXX test order dependency: the allow_tests "partial allow" test // fails if it is run before mongo_livedata_tests. api.addFiles("mongo_livedata_tests.js", ["client", "server"]); diff --git a/packages/tinytest/tinytest_server.js b/packages/tinytest/tinytest_server.js index fa51723879..22a781a4c5 100644 --- a/packages/tinytest/tinytest_server.js +++ b/packages/tinytest/tinytest_server.js @@ -12,7 +12,7 @@ export { Tinytest }; const handlesForRun = new Map; const reportsForRun = new Map; -Meteor.publish(ServerTestResultsSubscription, function (runId) { +Meteor.publish(ServerTestResultsSubscription, async function (runId) { check(runId, String); if (! handlesForRun.has(runId)) { @@ -36,9 +36,16 @@ Meteor.publish(ServerTestResultsSubscription, function (runId) { }); Meteor.methods({ - 'tinytest/run'(runId, pathPrefix) { + async 'tinytest/run'(runId, pathPrefix) { check(runId, String); check(pathPrefix, Match.Optional([String])); + + const collections = await MongoInternals.defaultRemoteCollectionDriver().mongo.db.collections(); + + for (const collection of collections) { + await collection.drop(); + } + this.unblock(); reportsForRun.set(runId, Object.create(null)); @@ -84,4 +91,4 @@ Meteor.methods({ handlesForRun.delete(runId); reportsForRun.delete(runId); } -}); +}); \ No newline at end of file