Skip to main content
Glama
healthcheck.test.ts1.73 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import express from 'express'; import request from 'supertest'; import { initApp, shutdownApp } from './app'; import { loadTestConfig } from './config/loader'; import * as otel from './otel/otel'; const app = express(); describe('Health check', () => { let setGaugeSpy: jest.SpyInstance; const originalProcessEnv = process.env; beforeEach(() => { process.env = { ...originalProcessEnv }; setGaugeSpy = jest.spyOn(otel, 'setGauge'); }); afterEach(async () => { process.env = originalProcessEnv; setGaugeSpy.mockRestore(); await shutdownApp(); }); test('Get /healthcheck', async () => { const config = await loadTestConfig(); await initApp(app, config); const res = await request(app).get('/healthcheck'); expect(res.status).toBe(200); }); test('Get /healthcheck when OTel is enabled', async () => { process.env.OTLP_METRICS_ENDPOINT = 'http://localhost:4318/v1/metrics'; const config = await loadTestConfig(); await initApp(app, config); const res = await request(app).get('/healthcheck'); expect(res.status).toBe(200); expect(setGaugeSpy).toHaveBeenCalledTimes(3); }); test('Get /healthcheck when OTel is enabled and read and write instance are the same', async () => { process.env.OTLP_METRICS_ENDPOINT = 'http://localhost:4318/v1/metrics'; const config = await loadTestConfig(); config.readonlyDatabase = undefined; await initApp(app, config); const res = await request(app).get('/healthcheck'); expect(res.status).toBe(200); expect(setGaugeSpy).toHaveBeenCalledTimes(2); }); });

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/medplum/medplum'

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