-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.ts
More file actions
33 lines (28 loc) · 826 Bytes
/
global.ts
File metadata and controls
33 lines (28 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { loadEnvConfig } from '@koala-ts/framework';
import { client, connectToDb } from '../../src/infrastructure/database';
async function setup() {
loadEnvConfig('test');
await setupAtlasSearchIndex();
}
async function teardown() {
await client.db(process.env.MONGODB_DB).dropDatabase();
await client.close();
}
async function setupAtlasSearchIndex() {
await connectToDb();
const collection = client.db(process.env.MONGODB_DB).collection('movies');
await collection.insertOne({ tmp: 1 });
await collection.createSearchIndex({
name: 'default',
definition: {
'mappings': {
'dynamic': true
}
}
});
await collection.deleteOne({ tmp: 1 });
}
export default async function () {
await setup();
return teardown;
}