mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
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:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user