-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Maxime Dréau <maxime@dreau.fr>
- Loading branch information
Showing
15 changed files
with
412 additions
and
1,601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
server/tests/integration/db/indexes/formations.indexes.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import dotenv from "dotenv"; | ||
import { MongoClient } from "mongodb"; | ||
|
||
export default async () => { | ||
dotenv.config({ path: "./server/.env.test" }); | ||
|
||
const workerId = `${process.env.JEST_WORKER_ID ?? ""}`; | ||
const client = new MongoClient(process.env.MNA_TDB_MONGODB_URI?.replace("{{JEST_WORKER_ID}}", workerId) ?? ""); | ||
try { | ||
if (process.env.CI) { | ||
return; | ||
} | ||
await client.connect(); | ||
const dbs = await client.db().admin().listDatabases(); | ||
await Promise.all( | ||
dbs.databases.map((db) => { | ||
if (db.name.startsWith(`TDB-test-${workerId}`)) { | ||
return client.db(db.name).dropDatabase(); | ||
} | ||
|
||
return; | ||
}) | ||
); | ||
} catch (e) { | ||
console.error(e); | ||
} finally { | ||
await client.close(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { modelDescriptors } from "@/common/model/collections"; | ||
import { createIndexes } from "@/common/model/indexes"; | ||
import { clearAllCollections, configureDbSchemaValidation } from "@/common/mongodb"; | ||
import { startAndConnectMongodb, stopMongodb } from "@tests/utils/mongoUtils"; | ||
|
||
export const useMongo = () => { | ||
beforeAll(async () => { | ||
// connect to mongodb and create indexes before running tests | ||
await startAndConnectMongodb(); | ||
await createIndexes(); | ||
}, 10_000); | ||
await configureDbSchemaValidation(modelDescriptors); | ||
}, 30_000); | ||
afterAll(async () => { | ||
await stopMongodb(); | ||
}); | ||
beforeEach(async () => { | ||
await Promise.all([clearAllCollections(), configureDbSchemaValidation(modelDescriptors)]); | ||
await clearAllCollections(); | ||
}); | ||
}; |
Oops, something went wrong.