Skip to content

Commit 3b678a2

Browse files
committed
chore: set test timeout
1 parent da25ebf commit 3b678a2

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

test/server/query-timeout.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,33 @@ describe('test query timeout', () => {
1818
await pgMeta.query('DROP TABLE timeout_test;')
1919
})
2020

21-
test('query timeout after 5s and connection cleanup', async () => {
22-
const query = `SELECT pg_sleep(10);`
23-
// Execute a query that will sleep for 10 seconds
24-
const res = await app.inject({
25-
method: 'POST',
26-
path: '/query',
27-
payload: {
28-
query,
29-
},
30-
})
21+
test(
22+
'query timeout after 3s and connection cleanup',
23+
async () => {
24+
const query = `SELECT pg_sleep(10);`
25+
// Execute a query that will sleep for 10 seconds
26+
const res = await app.inject({
27+
method: 'POST',
28+
path: '/query',
29+
payload: {
30+
query,
31+
},
32+
})
3133

32-
// Check that we get the proper timeout error response
33-
expect(res.statusCode).toBe(408) // Request Timeout
34-
expect(res.json()).toMatchObject({
35-
error: expect.stringContaining('Query read timeout'),
36-
})
34+
// Check that we get the proper timeout error response
35+
expect(res.statusCode).toBe(408) // Request Timeout
36+
expect(res.json()).toMatchObject({
37+
error: expect.stringContaining('Query read timeout'),
38+
})
3739

38-
// Verify that the connection has been cleaned up by checking active connections
39-
const connectionsRes = await pgMeta.query(`
40+
// Verify that the connection has been cleaned up by checking active connections
41+
const connectionsRes = await pgMeta.query(`
4042
SELECT * FROM pg_stat_activity where application_name = 'postgres-meta 0.0.0-automated' and query ILIKE '%${query}%';
4143
`)
4244

43-
// Should have no active connections except for our current query
44-
expect(connectionsRes.data).toHaveLength(0)
45-
})
45+
// Should have no active connections except for our current query
46+
expect(connectionsRes.data).toHaveLength(0)
47+
},
48+
{ timeout: 5000 }
49+
)
4650
})

0 commit comments

Comments
 (0)