import { describe, it, expect } from 'vitest'; import { db } from '../src/db/client'; import { user } from '../src/db/schema'; import { runMigrations } from '../src/db/migrate'; import { ensureDbDir } from '../src/db/ensure-dir'; describe('database', () => { it('can query the migrated user table (empty)', async () => { const rows = await db.select().from(user); expect(rows).toEqual([]); }); }); describe('runMigrations', () => { it('is idempotent — running again on an already-migrated DB does not throw', async () => { // setup.ts already migrated the test DB once; re-running must be a no-op. await expect(runMigrations()).resolves.toBeUndefined(); await expect(runMigrations()).resolves.toBeUndefined(); }); }); describe('ensureDbDir', () => { it('is a no-op for a non-file: URL', () => { expect(() => ensureDbDir('libsql://remote.example')).not.toThrow(); }); it('does not create a directory for a bare filename in the current dir', () => { expect(() => ensureDbDir('file:app.db')).not.toThrow(); }); });