import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; const root = new URL('../../', import.meta.url); const migration = await readFile(new URL('SHiNE-server/shine-server-db/src/main/resources/postgres/migration_v42.sql', root), 'utf8'); const boot = await readFile(new URL('SHiNE-server/shine-server-db/src/main/java/shine/db/DatabaseInitializer.java', root), 'utf8'); const recorder = await readFile(new URL('SHiNE-server/src/main/java/server/files/R2UploadAuditRecorder.java', root), 'utf8'); const publicApi = await readFile(new URL('SHiNE-server/src/main/java/server/files/R2PrepareServlet.java', root), 'utf8'); const dmApi = await readFile(new URL('SHiNE-server/src/main/java/server/files/R2DmPrepareServlet.java', root), 'utf8'); for (const table of ['public_file_uploads', 'dm_file_uploads']) { assert.ok(migration.includes(`CREATE TABLE IF NOT EXISTS ${table}`)); assert.ok(recorder.includes(`"${table}"`)); } assert.match(migration, /schema_version = 42/); assert.match(boot, /SCHEMA_VERSION_42 = 42/); assert.match(boot, /POSTGRES_MIGRATION_V42_RESOURCE/); assert.match(publicApi, /R2UploadAuditRecorder\.record\(req, false/); assert.match(dmApi, /R2UploadAuditRecorder\.record\(req, true/); console.log('R2 upload audit schema wiring OK');