import { mkdtempSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { createRegistry } from '../../src/config/registry.js' import { createServer } from '../../src/server.js' import { connectClient, fakeManager } from './helpers.js' describe('createServer', () => { let dir: string beforeEach(() => { dir = mkdtempSync(join(tmpdir(), 'dbmole-server-')) }) afterEach(() => { rmSync(dir, { recursive: true, force: true }) }) it('registers all nine tools', async () => { const registry = createRegistry({ storePath: join(dir, 'connections.json'), env: {} }) const server = createServer(registry, fakeManager()) const client = await connectClient(server) const { tools } = await client.listTools() expect(tools.map((tool) => tool.name).sort()).toEqual([ 'add_connection', 'describe_table', 'execute_sql', 'list_connections', 'list_databases', 'list_tables', 'remove_connection', 'test_connection', 'update_connection' ]) }) })