20 lines
1.8 KiB
TypeScript
20 lines
1.8 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import { test } from "node:test"
|
|
import { assertDatabaseControlArchiveBoundary, DatabaseControlArchiveBoundaryError, DATABASE_CONTROL_DUMP_EXCLUDE_SCHEMA_ARG } from "./database-control-archive-boundary.js"
|
|
|
|
test("exact shared exclusion argv preserves public TOC", () => {
|
|
assert.equal(DATABASE_CONTROL_DUMP_EXCLUDE_SCHEMA_ARG, "--exclude-schema=mmapp_control")
|
|
assertDatabaseControlArchiveBoundary(Buffer.from("; Archive mmapp_control filename\n1; 2615 2200 SCHEMA - public owner\n2; 1259 1 TABLE public servers owner\n3; 1259 2 TABLE DATA public servers owner\n"))
|
|
assertDatabaseControlArchiveBoundary("1; 1259 1 TABLE public other_mmapp_control_archive owner\n")
|
|
})
|
|
test("all reserved namespace/object descriptors refuse including quoted tokens and case", () => {
|
|
for (const description of ["SCHEMA - mmapp_control owner", "TABLE mmapp_control database_schema_state owner", "TABLE DATA mmapp_control database_schema_intents owner", "SEQUENCE mmapp_control sequence owner", "COMMENT - SCHEMA mmapp_control owner", "ACL - SCHEMA mmapp_control owner", 'TABLE "mmapp_control" state owner', "FUNCTION MMAPP_CONTROL f() owner", "FUTURE UNKNOWN mmapp_control object owner", "TABLE public mmapp_control owner"]) {
|
|
assert.throws(() => assertDatabaseControlArchiveBoundary("1; 1259 1 " + description + "\n"), DatabaseControlArchiveBoundaryError)
|
|
}
|
|
})
|
|
test("unsupported TOC encoding, control bytes, malformed entries and bounds refuse", () => {
|
|
for (const value of [Buffer.from([0xff]), "1; 0 1 TABLE public a\0 owner", "not a TOC entry", "1; 0 1 TABLE public a\x1b owner", "x".repeat(16 * 1024 * 1024 + 1), "\n".repeat(200000)]) {
|
|
assert.throws(() => assertDatabaseControlArchiveBoundary(value), DatabaseControlArchiveBoundaryError)
|
|
}
|
|
})
|