mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-23 03:04:19 +01:00
wip
This commit is contained in:
@@ -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:");
|
||||
|
||||
Reference in New Issue
Block a user