Merge pull request #27936 from overleaf/em-unit-tests-mongo

Make Mongo available to unit tests in all services

GitOrigin-RevId: b65bbb69883d5bba31d09802b89f35bdc523fe4d
This commit is contained in:
Eric Mc Sween
2025-08-25 08:05:19 +00:00
committed by Copybot
parent 7dc7b322a8
commit 8f0913fafe
57 changed files with 404 additions and 162 deletions
@@ -365,6 +365,10 @@ async function clearCachedHistoryId(projectId) {
await rclient.del(key)
}
async function cleanupTestRedis() {
await redis.cleanupTestRedis(rclient)
}
// EXPORTS
const countUnprocessedUpdatesCb = callbackify(countUnprocessedUpdates)
@@ -442,4 +446,5 @@ export const promises = {
getCachedHistoryId,
setCachedHistoryId,
clearCachedHistoryId,
cleanupTestRedis,
}
+7 -1
View File
@@ -1,10 +1,11 @@
import Metrics from '@overleaf/metrics'
import MongoUtils from '@overleaf/mongo-utils'
import Settings from '@overleaf/settings'
import mongodb from 'mongodb-legacy'
const { MongoClient, ObjectId } = mongodb
/**
* @import { ProjectHistoryFailure } from './mongo-types.ts'
* @import { ProjectHistoryFailure } from './mongo-types'
*/
export { ObjectId }
@@ -17,6 +18,10 @@ const mongoDb = mongoClient.db()
Metrics.mongodb.monitor(mongoClient)
async function cleanupTestDatabase() {
await MongoUtils.cleanupTestDatabase(mongoClient)
}
export const db = {
deletedProjects: mongoDb.collection('deletedProjects'),
projects: mongoDb.collection('projects'),
@@ -24,4 +29,5 @@ export const db = {
projectHistoryFailures: mongoDb.collection('projectHistoryFailures'),
projectHistoryLabels: mongoDb.collection('projectHistoryLabels'),
projectHistorySyncState: mongoDb.collection('projectHistorySyncState'),
cleanupTestDatabase,
}