Skip to content

Commit 9f728fe

Browse files
committed
chore: add query timeout params test
1 parent 6ca4850 commit 9f728fe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/server/query-timeout.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ import { app } from './utils'
33
import { pgMeta } from '../lib/utils'
44

55
const TIMEOUT = (Number(process.env.PG_QUERY_TIMEOUT_SECS) ?? 10) + 2
6+
const STATEMENT_TIMEOUT = (Number(process.env.PG_QUERY_TIMEOUT_SECS) ?? 10) + 1
67

78
describe('test query timeout', () => {
89
test(
910
`query timeout after ${TIMEOUT}s and connection cleanup`,
1011
async () => {
11-
const query = `SELECT pg_sleep(${TIMEOUT});`
12+
const query = `SELECT pg_sleep(${TIMEOUT + 10});`
1213
// Execute a query that will sleep for 10 seconds
1314
const res = await app.inject({
1415
method: 'POST',
1516
path: '/query',
16-
query: `statementTimeoutSecs=${TIMEOUT - 2}`,
17+
query: `statementTimeoutSecs=${STATEMENT_TIMEOUT}`,
1718
payload: {
1819
query,
1920
},
@@ -41,7 +42,7 @@ describe('test query timeout', () => {
4142
test(
4243
'query without timeout parameter should not have timeout',
4344
async () => {
44-
const query = `SELECT pg_sleep(${TIMEOUT});`
45+
const query = `SELECT pg_sleep(${TIMEOUT + 10});`
4546
// Execute a query that will sleep for 10 seconds without specifying timeout
4647
const res = await app.inject({
4748
method: 'POST',

0 commit comments

Comments
 (0)