Skip to content

Commit 901babb

Browse files
committed
Update turso-driver.test.ts
1 parent 8310995 commit 901babb

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

packages/plugins/driver-turso/src/turso-driver.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,41 @@ describe('TursoDriver Remote Mode (via @libsql/client)', () => {
910910
it('should handle empty batch gracefully', async () => {
911911
await expect(driver.syncSchemasBatch([])).resolves.not.toThrow();
912912
});
913+
914+
// ── initObjects (remote-mode override — must NOT touch better-sqlite3) ──
915+
//
916+
// Regression: in serverless environments (e.g. Vercel) the native
917+
// `better-sqlite3` binding is unavailable. The base `SqlDriver.initObjects`
918+
// uses Knex (better-sqlite3) for `hasTable`/`createTable`, which crashes
919+
// with "Could not locate the bindings file". TursoDriver must route
920+
// `initObjects` through RemoteTransport instead.
921+
it('should provision tables via RemoteTransport (no better-sqlite3) in remote mode', async () => {
922+
await driver.initObjects([
923+
{
924+
name: 'remote_init_a',
925+
fields: {
926+
title: { type: 'string' },
927+
qty: { type: 'integer' },
928+
},
929+
},
930+
{
931+
name: 'remote_init_b',
932+
fields: {
933+
name: { type: 'string' },
934+
},
935+
},
936+
]);
937+
938+
// If routed via RemoteTransport, both tables exist on the libsql client.
939+
const a = await driver.create('remote_init_a', { title: 'X', qty: 1 });
940+
expect(a.title).toBe('X');
941+
const b = await driver.create('remote_init_b', { name: 'Y' });
942+
expect(b.name).toBe('Y');
943+
});
944+
945+
it('should handle empty initObjects list gracefully in remote mode', async () => {
946+
await expect(driver.initObjects([])).resolves.not.toThrow();
947+
});
913948
});
914949

915950
// ── Lazy Connect (self-healing for serverless cold starts) ───────────────────

0 commit comments

Comments
 (0)