|
| 1 | +import { migrate } from "drizzle-orm/libsql/migrator"; |
| 2 | +import { afterAll, afterEach, beforeAll } from "vitest"; |
| 3 | +// import { reset } from "drizzle-seed"; |
| 4 | + |
| 5 | +import { db } from "@/lib/db"; |
| 6 | +import { NewClient, clients } from "@/lib/db/schema"; |
| 7 | +import { sql } from "drizzle-orm"; |
| 8 | + |
| 9 | +beforeAll(async () => { |
| 10 | + // await reset(db, schema); |
| 11 | + // create tables |
| 12 | + // await db.run( |
| 13 | + // sql.raw(` |
| 14 | + // CREATE TABLE IF NOT EXISTS clients ( |
| 15 | + // client_id TEXT PRIMARY KEY, |
| 16 | + // toggl_tag TEXT NOT NULL, |
| 17 | + // total_hours_paid REAL NOT NULL DEFAULT 0, |
| 18 | + // last_paid_date TEXT NOT NULL |
| 19 | + // ) |
| 20 | + // `), |
| 21 | + // ); |
| 22 | + await migrate(db, { |
| 23 | + migrationsFolder: "./src/drizzle", |
| 24 | + }); |
| 25 | + await db.insert(clients).values({ |
| 26 | + clientId: "123e4567-e89b-12d3-a456-426614174000", |
| 27 | + // clientId: "123e4567-e89b-12d3-a456-426614174000", |
| 28 | + // TODO - create shortui() - e.g. https://github.com/simplyhexagonal/short-unique-id |
| 29 | + togglTag: "daniel", |
| 30 | + totalHoursPaid: 40, |
| 31 | + lastPaidDate: new Date("2024-01-31").toISOString(), |
| 32 | + } as NewClient); |
| 33 | + console.log("before all tests"); |
| 34 | + |
| 35 | + // const rows = await db.select().from(clients); |
| 36 | + // console.dir(rows, { depth: null }); |
| 37 | +}); |
| 38 | + |
| 39 | +// afterAll(async () => { |
| 40 | +// await client.end(); |
| 41 | +// }); |
0 commit comments