36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import {beforeAll, afterAll} from 'bun:test';
|
|
import Bun from 'bun';
|
|
import {sql} from "bun";
|
|
|
|
beforeAll(async () => {
|
|
console.log(process.env.DATABASE_URL);
|
|
const scriptFile = await Bun.file('./scripts/dbCreate.sql').text();
|
|
|
|
// Drop the database in preparation for rebuild
|
|
await sql`DROP SCHEMA public CASCADE`;
|
|
await sql`CREATE SCHEMA public`;
|
|
|
|
// Run DB build script
|
|
await sql.unsafe(scriptFile);
|
|
|
|
// Populate initial data
|
|
await sql`SET search_path TO showfinder,public`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('ADMIN', false)`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('USERS_CREATE', false)`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('USERS_OTHER_UPDATE', false)`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('USERS_OTHER_DELETE', true)`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('USERS_SELF_READ', true)`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('USERS_SELF_UPDATE', true)`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('USERS_OTHER_READ', true)`;
|
|
await sql`INSERT INTO claims(name, is_default) VALUES ('USERS_SELF_DELETE', false)`;
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|