MCPcopy
hub / github.com/promptfoo/promptfoo / resetTestDatabaseClient

Function resetTestDatabaseClient

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

Source from the content-addressed store, hash-verified

35}
36
37export async function resetTestDatabaseClient(client: TestDatabaseClient): Promise<void> {
38 const schemaObjects = await client.execute(`
39 SELECT type, name
40 FROM sqlite_master
41 WHERE name NOT LIKE 'sqlite_%'
42 AND type IN ('table', 'view', 'trigger')
43 ORDER BY CASE type WHEN 'trigger' THEN 0 WHEN 'view' THEN 1 ELSE 2 END
44 `);
45
46 await client.execute('PRAGMA foreign_keys = OFF');
47 try {
48 for (const row of schemaObjects.rows) {
49 const type = String(row.type).toUpperCase();
50 if (type !== 'TABLE' && type !== 'VIEW' && type !== 'TRIGGER') {
51 continue;
52 }
53 const name = String(row.name).replace(/"/g, '""');
54 await client.execute(`DROP ${type} IF EXISTS "${name}"`);
55 }
56 } finally {
57 await client.execute('PRAGMA foreign_keys = ON');
58 }
59}
60
61export async function closeTestDatabaseClient(client: TestDatabaseClient): Promise<void> {
62 await enqueueTestDatabaseOperation(async () => {

Callers 3

isolation.test.tsFile · 0.90
closeTestDatabaseClientFunction · 0.85
closeTestDatabaseClientsFunction · 0.85

Calls 1

executeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…