Files
MikrotikManager/backend/src/services/router-configuration-guard.sql.test.ts
T

28 lines
1.8 KiB
TypeScript

/** Invoked ONLY by the dedicated root-owned embedded-PG profile. No fallback
* to application DATABASE_URL, .env or production/control configuration. */
import { acceptOwnedRouterGuard } from "./router-configuration-guard.sql-helper.js"
import { createOwnedRouterGuardFixtureFactory } from "./router-configuration-guard.sql-fixture.js"
async function main() {
const admin = process.env.MMAPP_TEST_ROUTER_GUARD_ADMIN_URL
if (!admin) throw Error("Missing explicit disposable owned-cluster admin URL")
const make = createOwnedRouterGuardFixtureFactory(admin)
const report = await acceptOwnedRouterGuard(async name => {
process.stdout.write(JSON.stringify({ scenario: name, phase: "owner-provision" }) + "\n")
const fixture = await make(name)
process.stdout.write(JSON.stringify({ scenario: name, phase: "actual-acceptance" }) + "\n")
return fixture
})
process.stdout.write(JSON.stringify(report, null, 2) + "\n")
const { acceptOwnedRouterConfigurationWriter } = await import("./router-configuration-writer-context.sql-helper.js")
console.log("Owned router writer assembly:", JSON.stringify(await acceptOwnedRouterConfigurationWriter(make)))
const { acceptOwnedRouterConfigurationNativeTransport } = await import("./router-configuration-native-transport.sql-helper.js")
console.log("Owned fixed router native transport:", JSON.stringify(await acceptOwnedRouterConfigurationNativeTransport(admin)))
}
void main().catch(error => {
const name = error instanceof Error && /^[A-Za-z]+$/.test(error.name) ? error.name : "Error"
const code: unknown = error && typeof error === "object" ? error.code : undefined
process.stderr.write(JSON.stringify({ status: "refused", error: name, sqlState: typeof code === "string" && /^[0-9A-Z]{5}$/.test(code) ? code : undefined }) + "\n")
process.exitCode = 1
})