Skip to main content
Glama
dbinvalidindexes.test.ts1.65 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { Parameters } from '@medplum/fhirtypes'; import express from 'express'; import request from 'supertest'; import { initApp, shutdownApp } from '../../app'; import { loadTestConfig } from '../../config/loader'; import { DatabaseMode, getDatabasePool } from '../../database'; import { initTestAuth } from '../../test.setup'; describe('$db-invalid-indexes', () => { const app = express(); beforeAll(async () => { const config = await loadTestConfig(); await initApp(app, config); }); afterAll(async () => { await shutdownApp(); }); afterEach(async () => { const client = getDatabasePool(DatabaseMode.WRITER); await client.query(`REINDEX INDEX CONCURRENTLY "CarePlan_replaces_idx"`); }); test('Success', async () => { const client = getDatabasePool(DatabaseMode.WRITER); await client.query( `UPDATE pg_index SET indislive = false FROM pg_class WHERE pg_class.oid = pg_index.indexrelid AND pg_class.relname = $1`, ['CarePlan_replaces_idx'] ); const accessToken = await initTestAuth({ project: { superAdmin: true } }); const res = await request(app) .post('/fhir/R4/$db-invalid-indexes') .set('Authorization', 'Bearer ' + accessToken) .send({}); expect(res.status).toBe(200); const params = res.body as Parameters; const invalidIndex = params.parameter?.find( (p) => p.name === 'invalidIndex' && p.valueString?.startsWith('"CarePlan_replaces_idx"') ); expect(invalidIndex).toBeDefined(); }); });

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