feat: complete V1 phases 0-7
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
|
||||
function run(command: string, args: string[], environment: NodeJS.ProcessEnv): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(command, args, {
|
||||
cwd: process.cwd(),
|
||||
env: environment,
|
||||
shell: false,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
child.once('error', reject);
|
||||
child.once('exit', (code) => {
|
||||
if (code === 0) resolve();
|
||||
else reject(new Error(`${command} exited with code ${String(code)}`));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const testDatabaseUrl = process.env.TEST_DATABASE_URL;
|
||||
if (!testDatabaseUrl) throw new Error('TEST_DATABASE_URL is required for integration tests');
|
||||
const parsed = new URL(testDatabaseUrl);
|
||||
if (parsed.protocol !== 'mysql:' || parsed.pathname !== '/lehuo_test') {
|
||||
throw new Error('Integration tests are restricted to the lehuo_test MySQL database');
|
||||
}
|
||||
const pnpmCli = process.env.npm_execpath;
|
||||
if (!pnpmCli) throw new Error('npm_execpath is required to locate the active pnpm CLI');
|
||||
const environment = {
|
||||
...process.env,
|
||||
APP_ENV: 'test',
|
||||
DATABASE_URL: testDatabaseUrl,
|
||||
};
|
||||
await run(process.execPath, [pnpmCli, 'exec', 'prisma', 'migrate', 'deploy'], environment);
|
||||
await run(
|
||||
process.execPath,
|
||||
[pnpmCli, 'exec', 'vitest', 'run', '--config', 'vitest.integration.config.ts'],
|
||||
environment,
|
||||
);
|
||||
}
|
||||
|
||||
void main();
|
||||
Reference in New Issue
Block a user