test: cover share validation and migrations

This commit is contained in:
2026-08-16 01:00:24 +07:00 Unverified
parent 9617d67c7c
commit bcda6664e3
2 changed files with 111 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import { describe, expect, test } from "bun:test";
describe("share migration", () => {
test("backfills Discord IDs before creating the unique index", async () => {
const migration = await Bun.file(
new URL("../../drizzle/0018_authenticated_share.sql", import.meta.url)
).text();
const backfill = migration.indexOf('SET "discord_id"');
const uniqueIndex = migration.indexOf(
'CREATE UNIQUE INDEX "user_discord_id_unique"'
);
expect(backfill).toBeGreaterThan(-1);
expect(uniqueIndex).toBeGreaterThan(backfill);
expect(migration).toContain('CREATE TABLE "share"."text"');
expect(migration).toContain('CREATE TABLE "share"."comment"');
expect(migration).toContain("ON DELETE cascade");
});
});