import { afterAll } from 'bun:test';
import { useLocalKysely } from './local';

export async function useTestKysely(
  cleanupStrategy: 'afterAll' | 'using' | 'manual'
) {
  const kysely = await useLocalKysely();

  if (cleanupStrategy === 'afterAll')
    afterAll(async () => {
      await kysely.destroy();
    });
  return {
    kysely,
    [Symbol.dispose]: async () => {
      await kysely.destroy();
    },
  };
}
