Files
Homarr/e2e/shared/e2e-db.ts
Meier Lukas 4ead238462 test(e2e): add for onboarding and lldap authorization (#1834)
* test(e2e): add for onboarding and lldap authorization

* ci: add playwright chrome installation to e2e test

* fix(e2e): timeout between lldap login redirect to short

* test(e2e): add oidc azure test

* fix(e2e): lldap test fails

* wip: add temporary error log for failed ldap server connection

* fix(e2e): github actions don't support host.docker.internal

* chore: address pull request feedback

* refactor(e2e): move onboarding steps to onboarding actions and assertions

* fix(e2e): increase timeout for navigating back from azure login

* fix: wait for url network changed error

* fix: revert to wait for url

* fix(e2e): remove oidc test

* refactor(e2e): remove env validation

* ci: remove azure oidc env variables
2025-01-03 16:49:30 +01:00

33 lines
1003 B
TypeScript

import { mkdir } from "fs/promises";
import path from "path";
import { createId } from "@paralleldrive/cuid2";
import Database from "better-sqlite3";
import { BetterSQLite3Database, drizzle } from "drizzle-orm/better-sqlite3";
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
import * as sqliteSchema from "../../packages/db/schema/sqlite";
export const createSqliteDbFileAsync = async () => {
const localMountPath = path.join(__dirname, "tmp", createId());
await mkdir(path.join(localMountPath, "db"), { recursive: true });
const localDbUrl = path.join(localMountPath, "db", "db.sqlite");
const connection = new Database(localDbUrl);
const db = drizzle(connection, {
schema: sqliteSchema,
casing: "snake_case",
});
await migrate(db, {
migrationsFolder: path.join(__dirname, "..", "..", "packages", "db", "migrations", "sqlite"),
});
return {
db,
localMountPath,
};
};
export type SqliteDatabase = BetterSQLite3Database<typeof sqliteSchema>;