import { describe, it, expect } from 'bun:test';
import Database from 'bun:sqlite';
import { initializeDatabase } from '../../../src/db';

describe('DB migrations smoke', () => {
  it('initializeDatabase en :memory: no lanza y crea tablas base', () => {
    const memdb = new Database(':memory:');
    expect(() => initializeDatabase(memdb)).not.toThrow();

    // Comprobar que al menos una tabla base existe (users, tasks o response_queue).
    const rows = memdb
      .query(`SELECT name FROM sqlite_master WHERE type='table' AND name IN ('users','tasks','response_queue')`)
      .all() as Array<{ name: string }>;

    expect(Array.isArray(rows)).toBe(true);
    expect(rows.length).toBeGreaterThan(0);
  });
});
