This commit is contained in:
Nikita Sivukhin
2025-09-17 10:38:05 +04:00
parent 1185298670
commit 66de28d84b
30 changed files with 4175 additions and 190 deletions

View File

@@ -1,6 +1,26 @@
import { unlinkSync } from "node:fs";
import { expect, test } from 'vitest'
import { connect } from './promise.js'
import { sql } from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/better-sqlite3';
test('drizzle-orm', async () => {
const path = `test-${(Math.random() * 10000) | 0}.db`;
try {
const conn = await connect(path);
const db = drizzle(conn);
await db.run('CREATE TABLE t(x, y)');
let tasks = [];
for (let i = 0; i < 1234; i++) {
tasks.push(db.run(sql`INSERT INTO t VALUES (${i}, randomblob(${i} * 5))`))
}
await Promise.all(tasks);
expect(await db.all("SELECT COUNT(*) as cnt FROM t")).toEqual([{ cnt: 1234 }])
} finally {
unlinkSync(path);
unlinkSync(`${path}-wal`);
}
})
test('in-memory db', async () => {
const db = await connect(":memory:");