Files
MineGeo/scripts/test-map-sharing-sql.mjs

23 lines
1.1 KiB
JavaScript

import { readFile, readdir } from "node:fs/promises";
import { PGlite } from "../.data/sql-verification/node_modules/@electric-sql/pglite/dist/index.js";
const db = new PGlite();
try {
await db.exec(`create role anon; create role authenticated; create role service_role;
create schema auth; create table auth.users(id uuid primary key);
create function auth.uid() returns uuid language sql as $$ select null::uuid $$;
create schema storage; create table storage.buckets(id text primary key,name text,public boolean,file_size_limit bigint);`);
for (const file of (await readdir("supabase/migrations"))
.filter((f) => f.endsWith(".sql"))
.sort())
await db.exec(await readFile(`supabase/migrations/${file}`, "utf8"));
await db.exec(await readFile("tests/sql/map-sharing.sql", "utf8"));
console.log(
"Map sharing SQL passed: private solo/rooms, owner attribution, publication blocked, original owner can submit.",
);
} catch (error) {
console.error(error.message, error.where ?? "");
process.exitCode = 1;
} finally {
await db.close();
}