chore(tests): проверить backend на PostgreSQL и убрать ожидание idle пула
This commit is contained in:
1 parent
fdddc52019
commit
7ad66f178b
15 files changed
+1249
-17
No files matched your search
@@ -19,6 +19,7 @@ export function createPool(max = 16): pg.Pool {
|
||||
connectionString: env.DATABASE_URL,
|
||||
max,
|
||||
idleTimeoutMillis: 30_000,
|
||||
allowExitOnIdle: process.env.NODE_ENV === "test",
|
||||
connectionTimeoutMillis: 8_000,
|
||||
statement_timeout: 120_000,
|
||||
})
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { createPool } from "./index.js"
|
||||
const original = process.env.NODE_ENV
|
||||
try {
|
||||
for (const mode of ["production", "development", "test"]) {
|
||||
process.env.NODE_ENV = mode
|
||||
const pool = createPool(1)
|
||||
assert.equal(pool.options.allowExitOnIdle, mode === "test")
|
||||
assert.equal(pool.options.idleTimeoutMillis, 30_000)
|
||||
assert.equal(pool.options.max, 1)
|
||||
await pool.end()
|
||||
}
|
||||
} finally {
|
||||
if (original === undefined) delete process.env.NODE_ENV
|
||||
else process.env.NODE_ENV = original
|
||||
}
|
||||
console.log("PG pool: tests may exit on idle; production/development retain normal pool lifecycle, no SQL connection")
|
||||
Reference in new issue
Block a user