Check-in gate + fixes, RPC test suite, docs
- Convivo: not-checked-in gate for non-staff (see-a-staff screen with QR code + logout); lifts automatically once staff checks them in - Convivo: fix check-in 'pick a session first' race (synchronous default session fallback) - Add RPC test suite (npm run test:rpc): points idempotency, role guards, service-session guard, speaker auto-promote, leaderboard staff exclusion - Fix db:types script (create packages/shared/src); gitignore generated types - Docs: README/roadmap drift fixes, tests.md, backend README link Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
fcbc19b8fc
commit
b08a439949
11 files changed
+559
-38
No files matched your search
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env node
|
||||
// Convivo — RPC test runner.
|
||||
//
|
||||
// Runs supabase/tests/rpc_tests.sql against the local Supabase Postgres
|
||||
// container and exits non-zero if any test failed.
|
||||
//
|
||||
// npm run test:rpc
|
||||
//
|
||||
// Requires the Supabase core to be running (`npm run db:start`).
|
||||
|
||||
const { execFileSync } = require('node:child_process');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const SQL_FILE = path.join(__dirname, 'rpc_tests.sql');
|
||||
const DB_CONTAINER = process.env.SUPABASE_DB_CONTAINER || 'supabase_db_Convivo';
|
||||
|
||||
const sql = fs.readFileSync(SQL_FILE, 'utf8');
|
||||
|
||||
let output;
|
||||
try {
|
||||
output = execFileSync('docker', ['exec', '-i', DB_CONTAINER, 'psql', '-U', 'postgres'], {
|
||||
input: sql,
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
});
|
||||
} catch (e) {
|
||||
// psql exits non-zero on a hard error (e.g. container not running).
|
||||
process.stderr.write(e.stdout || '');
|
||||
process.stderr.write(e.stderr || '');
|
||||
process.stderr.write('\nFailed to run RPC tests (is the Supabase core running? `npm run db:start`).\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.stdout.write(output);
|
||||
|
||||
// Parse the summary row: " 14 | 14 | 0" (three pipe-separated
|
||||
// numbers, no trailing pipe). Match the last such row in the output.
|
||||
const summaryRows = [...output.matchAll(/(\d+)\s*\|\s*(\d+)\s*\|\s*(\d+)\s*$/gm)];
|
||||
const summaryMatch = summaryRows.length ? summaryRows[summaryRows.length - 1] : null;
|
||||
if (!summaryMatch) {
|
||||
process.stderr.write('\nCould not parse the test summary from psql output.\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [, total, passed, failed] = summaryMatch.map((n) => parseInt(n, 10));
|
||||
process.stdout.write(`\nRPC tests: ${passed}/${total} passed, ${failed} failed.\n`);
|
||||
process.exit(failed > 0 ? 1 : 0);
|
||||
Reference in new issue
Block a user