openvibers/openvibe.tools Commits
Tests: the per-app prune check reads rows with db.many (db.query returns a result, not an array); spawned apps get one PGlite directory each (observe.test.js ran img, text and yt on one DATA_DIR and PGlite, single-process, aborted)
Changes
@@@ -446,7 +446,7 @@ async function serve(app) {}const img = createGuardStore({ db, app: 'img', log: quiet });assert.strictEqual(await img.pruneAbuse(now0), 1, "img prunes its own row");-- const left = await db.query('SELECT app FROM guard_abuse ORDER BY app');++ const left = await db.many('SELECT app FROM guard_abuse ORDER BY app');assert.deepStrictEqual(left.map(r => r.app), ['docs'], "docs' row is untouched");}@@@ -26,10 +26,12 @@ async function startApp(app, env = {}, port, { readyPath = '/api/health' } = {})let out = '';// Without a DATABASE_URL the app serves from an embedded PGlite database. Point it at a directory// under the test's own DATA_DIR, so it survives the kill a restart test does (production uses a real-- // PostgreSQL, which outlives the process the same way).++ // PostgreSQL, which outlives the process the same way). One directory per app: PGlite is a++ // single-process database, and tests that start several apps on one DATA_DIR (observe.test.js runs++ // img, text and yt at once) aborted when two processes opened the same files.const url = env.DATABASE_URL !== undefined ? env.DATABASE_URL : process.env.DATABASE_URL;const pglite = (!String(url || '').trim() && env.DATA_DIR && env.TOOLS_PGLITE_DIR === undefined)-- ? { TOOLS_PGLITE_DIR: path.join(env.DATA_DIR, 'pglite') }++ ? { TOOLS_PGLITE_DIR: path.join(env.DATA_DIR, 'pglite', app) }: {};const child = spawn(process.execPath, ['server/index.js'], {cwd: dir,
@@ -446,7 +446,7 @@ async function serve(app) {
@@ -446,7 +446,7 @@ async function serve(app) {
}
}
const img = createGuardStore({ db, app: 'img', log: quiet });
const img = createGuardStore({ db, app: 'img', log: quiet });
assert.strictEqual(await img.pruneAbuse(now0), 1, "img prunes its own row");
assert.strictEqual(await img.pruneAbuse(now0), 1, "img prunes its own row");
- const left = await db.query('SELECT app FROM guard_abuse ORDER BY app');
+ const left = await db.many('SELECT app FROM guard_abuse ORDER BY app');
assert.deepStrictEqual(left.map(r => r.app), ['docs'], "docs' row is untouched");
assert.deepStrictEqual(left.map(r => r.app), ['docs'], "docs' row is untouched");
}
}
@@ -26,10 +26,12 @@ async function startApp(app, env = {}, port, { readyPath = '/api/health' } = {})
@@ -26,10 +26,12 @@ async function startApp(app, env = {}, port, { readyPath = '/api/health' } = {})
let out = '';
let out = '';
// Without a DATABASE_URL the app serves from an embedded PGlite database. Point it at a directory
// Without a DATABASE_URL the app serves from an embedded PGlite database. Point it at a directory
// under the test's own DATA_DIR, so it survives the kill a restart test does (production uses a real
// under the test's own DATA_DIR, so it survives the kill a restart test does (production uses a real
- // PostgreSQL, which outlives the process the same way).
+ // PostgreSQL, which outlives the process the same way). One directory per app: PGlite is a
+ // single-process database, and tests that start several apps on one DATA_DIR (observe.test.js runs
+ // img, text and yt at once) aborted when two processes opened the same files.
const url = env.DATABASE_URL !== undefined ? env.DATABASE_URL : process.env.DATABASE_URL;
const url = env.DATABASE_URL !== undefined ? env.DATABASE_URL : process.env.DATABASE_URL;
const pglite = (!String(url || '').trim() && env.DATA_DIR && env.TOOLS_PGLITE_DIR === undefined)
const pglite = (!String(url || '').trim() && env.DATA_DIR && env.TOOLS_PGLITE_DIR === undefined)
- ? { TOOLS_PGLITE_DIR: path.join(env.DATA_DIR, 'pglite') }
+ ? { TOOLS_PGLITE_DIR: path.join(env.DATA_DIR, 'pglite', app) }
: {};
: {};
const child = spawn(process.execPath, ['server/index.js'], {
const child = spawn(process.execPath, ['server/index.js'], {
cwd: dir,
cwd: dir,