1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-02 08:48:11 +09:00

Update utils.ts

This commit is contained in:
syuilo 2022-05-21 22:07:01 +09:00
parent 2205c61edf
commit 425084b596

View File

@ -159,7 +159,7 @@ export function launchServer(callbackSpawnedProcess: (p: childProcess.ChildProce
export async function initTestDb(justBorrow = false, initEntities?: any[]) { export async function initTestDb(justBorrow = false, initEntities?: any[]) {
if (process.env.NODE_ENV !== 'test') throw 'NODE_ENV is not a test'; if (process.env.NODE_ENV !== 'test') throw 'NODE_ENV is not a test';
return new DataSource({ const db = new DataSource({
type: 'postgres', type: 'postgres',
host: config.db.host, host: config.db.host,
port: config.db.port, port: config.db.port,
@ -170,6 +170,10 @@ export async function initTestDb(justBorrow = false, initEntities?: any[]) {
dropSchema: true && !justBorrow, dropSchema: true && !justBorrow,
entities: initEntities || entities, entities: initEntities || entities,
}); });
await db.initialize();
return db;
} }
export function startServer(timeout = 30 * 1000): Promise<childProcess.ChildProcess> { export function startServer(timeout = 30 * 1000): Promise<childProcess.ChildProcess> {