Isolate local API tests to a dedicated familysync_test DB (quick 260613-ndv) #18

Merged
luckberg merged 5 commits from quick/260613-ndv-test-db-isolation into main 2026-06-13 20:32:45 -04:00
Showing only changes of commit 4517432dca - Show all commits
+3 -9
View File
@@ -64,14 +64,10 @@ export default async function setup(): Promise<void> {
// Try @'%' first (Docker/network access); fall back to @'localhost' if the user was
// created with a localhost host qualifier.
try {
await rootConn.query(
`GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${appUser}'@'%'`,
);
await rootConn.query(`GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${appUser}'@'%'`);
} catch {
// If @'%' fails (user only exists as @'localhost'), try that form.
await rootConn.query(
`GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${appUser}'@'localhost'`,
);
await rootConn.query(`GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${appUser}'@'localhost'`);
}
await rootConn.query('FLUSH PRIVILEGES');
@@ -101,9 +97,7 @@ export default async function setup(): Promise<void> {
// construct({ client, mode }, undefined) and the session client becomes
// the plain config object (no .query()). The two-arg form is safe.
const db = drizzle(appPool, { mode: 'default' });
const migrationsFolder = fileURLToPath(
new URL('../src/db/migrations', import.meta.url),
);
const migrationsFolder = fileURLToPath(new URL('../src/db/migrations', import.meta.url));
await migrate(db, { migrationsFolder });
// Clean slate each run: truncate every table (except drizzle's migration