import assert from "node:assert/strict"; import test from "node:test"; import { startPostgresFixture } from "./helpers/postgres-fixture.ts"; test("stdin PostgreSQL scripts carry large SQL and preserve transaction-local settings", () => { const fixture = startPostgresFixture(); try { const payload = "x".repeat(131_073); const script = ` select set_config('app.test_large_script', 'stdin-helper', true); select current_setting('app.test_large_script'); select length($$${payload}$$); `; assert.equal(Buffer.byteLength(script, "utf8") > 131_072, true); assert.equal( fixture.psqlScriptAs("postgres", "postgres-test-password", script), "stdin-helper\nstdin-helper\n131073", ); assert.equal( fixture.psqlScriptAs("postgres", "postgres-test-password", "select repeat('x', 1048577);"), "x".repeat(1_048_577), ); } finally { fixture.stop(); } });