Introduce e2e test

This commit is contained in:
syuilo
2021-08-12 19:05:07 +09:00
parent 77456ae0bc
commit b81ff340b1
18 changed files with 805 additions and 32 deletions

View File

@@ -211,3 +211,13 @@ export function initDb(justBorrow = false, sync = false, forceRecreate = false)
entities: entities
});
}
export async function resetDb() {
const conn = await getConnection();
const tables = await conn.query(`SELECT relname AS "table"
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind = 'r'
AND nspname !~ '^pg_toast';`);
await Promise.all(tables.map(t => t.table).map(x => conn.query(`DELETE FROM "${x}" CASCADE`)));
}