MCPcopy
hub / github.com/promptfoo/promptfoo / closeTestDatabaseClient

Function closeTestDatabaseClient

src/database/testing.ts:61–79  ·  view source on GitHub ↗
(client: TestDatabaseClient)

Source from the content-addressed store, hash-verified

59}
60
61export async function closeTestDatabaseClient(client: TestDatabaseClient): Promise<void> {
62 await enqueueTestDatabaseOperation(async () => {
63 const clients = (globalThis as TestDatabaseGlobal)[TEST_DATABASE_CLIENTS_KEY];
64 if (!clients?.delete(client)) {
65 client.close();
66 return;
67 }
68
69 try {
70 // libsql requires a process-wide shared in-memory cache for its internal
71 // connections. Reset it only after the final module graph has stopped using it.
72 if (clients.size === 0) {
73 await resetTestDatabaseClient(client);
74 }
75 } finally {
76 client.close();
77 }
78 });
79}
80
81export async function closeTestDatabaseClients(): Promise<void> {
82 await enqueueTestDatabaseOperation(async () => {

Callers 2

isolation.test.tsFile · 0.90
closeDbFunction · 0.90

Calls 4

resetTestDatabaseClientFunction · 0.85
deleteMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…