test: move resetDb to own testing lib function
This commit is contained in:
@@ -3,8 +3,6 @@ import { drizzle } from "drizzle-orm/libsql";
|
||||
|
||||
import type { Env } from "~/types/env";
|
||||
|
||||
import { tables } from "./schema";
|
||||
|
||||
type Db = ReturnType<typeof createDb>;
|
||||
let db: Db | null = null;
|
||||
|
||||
@@ -17,14 +15,6 @@ export function getDb(env: Env): Db {
|
||||
return db;
|
||||
}
|
||||
|
||||
export async function resetDb() {
|
||||
if (!db) return;
|
||||
|
||||
for (const table of tables) {
|
||||
await db.delete(table);
|
||||
}
|
||||
}
|
||||
|
||||
function createDb(env: Env) {
|
||||
const client = createClient({
|
||||
url: env.TURSO_URL,
|
||||
|
||||
Reference in New Issue
Block a user