mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
24 lines
641 B
TypeScript
24 lines
641 B
TypeScript
import 'hydrooj/src/loader';
|
|
|
|
jest.mock('hydrooj/src/service/db');
|
|
|
|
export async function connect() {
|
|
const db = require('hydrooj/src/service/db');
|
|
await db.start({});
|
|
const scripts = require('hydrooj/src/upgrade').default;
|
|
let dbVer = 0;
|
|
const expected = scripts.length;
|
|
while (dbVer < expected) {
|
|
const func = scripts[dbVer];
|
|
dbVer++;
|
|
if (func.toString().includes('_FRESH_INSTALL_IGNORE')) continue;
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await func();
|
|
}
|
|
}
|
|
|
|
export async function dispose() {
|
|
const db = require('hydrooj/src/service/db');
|
|
await db.stop();
|
|
}
|