MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / prepareDatabase

Function prepareDatabase

packages/testtools/src/client.ts:313–328  ·  view source on GitHub ↗
(provider: string, dbName: string)

Source from the content-addressed store, hash-verified

311}
312
313async function prepareDatabase(provider: string, dbName: string) {
314 if (provider === 'postgresql') {
315 invariant(dbName, 'dbName is required');
316 const pgClient = new PGClient(TEST_PG_CONFIG);
317 await pgClient.connect();
318 await pgClient.query(`DROP DATABASE IF EXISTS "${dbName}"`);
319 await pgClient.query(`CREATE DATABASE "${dbName}"`);
320 await pgClient.end();
321 } else if (provider === 'mysql') {
322 invariant(dbName, 'dbName is required');
323 const mysqlPool = createMysqlPool(TEST_MYSQL_CONFIG);
324 await mysqlPool.promise().query(`DROP DATABASE IF EXISTS \`${dbName}\``);
325 await mysqlPool.promise().query(`CREATE DATABASE \`${dbName}\``);
326 await mysqlPool.promise().end();
327 }
328}
329
330export async function createPolicyTestClient<Schema extends SchemaDef>(
331 schema: Schema,

Callers 1

createTestClientFunction · 0.85

Calls 1

invariantFunction · 0.90

Tested by

no test coverage detected