Skip to main content
Glama
get-diagnostics.test.ts2.25 kB
import { describe, it, beforeEach, mock } from 'node:test'; import assert from 'node:assert'; import { getDiagnostics } from '../src/tools/get-diagnostics.js'; import { DiagnosticsManager } from '../src/diagnostics-manager.js'; import { fileURLToPath } from 'node:url'; import { dirname, join } from 'node:path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const TEST_FILE = join(__dirname, 'fixtures', 'test-script.gd'); describe('get_diagnostics tool', () => { let mockDiagnosticsManager: DiagnosticsManager; beforeEach(() => { mockDiagnosticsManager = { getFileDiagnostics: mock.fn((path: string) => { if (path === TEST_FILE) { return Promise.resolve([ { line: 5, column: 10, severity: 'error' as const, message: 'Syntax error' }, ]); } return Promise.resolve([]); }), } as unknown as DiagnosticsManager; }); it('should return diagnostics for specific file', async () => { const result = await getDiagnostics(mockDiagnosticsManager, true, { file_path: TEST_FILE, }); assert.deepStrictEqual(result.diagnostics, { [TEST_FILE]: [ { line: 5, column: 10, severity: 'error', message: 'Syntax error' }, ], }); assert.strictEqual(result.error, undefined); }); it('should return error when LSP not connected', async () => { const result = await getDiagnostics(mockDiagnosticsManager, false, { file_path: TEST_FILE, }); assert.deepStrictEqual(result.diagnostics, {}); assert.match(result.error ?? '', /Godot LSP is not running/); }); it('should reject non-.gd files', async () => { await assert.rejects( getDiagnostics(mockDiagnosticsManager, true, { file_path: '/project/script.txt' }), /file_path must be a \.gd file/ ); }); it('should require file_path parameter', async () => { await assert.rejects( getDiagnostics(mockDiagnosticsManager, true, {}), /file_path is required/ ); }); it('should accept .gd files', async () => { const result = await getDiagnostics(mockDiagnosticsManager, true, { file_path: TEST_FILE, }); assert.strictEqual(result.error, undefined); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ryanmazzolini/minimal-godot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server