21 lines
1.1 KiB
JavaScript
21 lines
1.1 KiB
JavaScript
// No response bodies or credentials are logged by rollout acceptance.
|
|
async function accept(base) {
|
|
const r = await fetch(`${base}/api/products?limit=1`, {signal: AbortSignal.timeout(5000), redirect: 'error'});
|
|
if (r.status !== 200) throw new Error('catalog status');
|
|
const b = await r.json();
|
|
if (!Array.isArray(b.data) || !Number.isInteger(b.meta?.total) || b.meta.total < 0) throw new Error('catalog shape');
|
|
}
|
|
async function main() {
|
|
const {PrismaClient} = require('@prisma/client');
|
|
const db = new PrismaClient();
|
|
try {
|
|
for (let n=0; n<30; n++) {
|
|
try { await accept('http://127.0.0.1:3000'); console.log('Backend schema/catalog acceptance passed'); return; }
|
|
catch { if(n===29) throw new Error('catalog acceptance'); await new Promise(r=>setTimeout(r,2000)); }
|
|
}
|
|
} finally { await db.$disconnect(); }
|
|
}
|
|
module.exports = {accept};
|
|
// node -e is used inside the built backend; imports in tests do not execute main.
|
|
if (!module.parent) main().catch(()=>{console.error('Backend acceptance failed (schema, migration receipt or catalog)');process.exitCode=1;});
|