Files
wehub-resource-sync fed8b2eed7
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:28:29 +08:00

31 lines
930 B
TypeScript

/**
* Per-test TRUNCATE — preserves `alembic_version`, wipes every other table.
*/
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
import { pg } from './db.js';
const HERE = dirname(fileURLToPath(import.meta.url));
const TRUNCATE_SQL_PATH = resolve(HERE, '..', '..', '..', 'scripts', 'e2e', 'truncate.sql');
let cached: string | null = null;
async function loadTruncateSql(): Promise<string> {
if (cached === null) {
cached = await readFile(TRUNCATE_SQL_PATH, 'utf8');
}
return cached;
}
/**
* Run `scripts/e2e/truncate.sql` against the e2e DB. Call from `beforeEach` to
* guarantee per-test isolation. Cheaper than template-cloning — that's the
* between-suites path handled by `up.sh` / `reset_db.sh`.
*/
export async function resetDb(): Promise<void> {
const sql = await loadTruncateSql();
await pg.query(sql);
}