Skip to content

Commit 96cfb6a

Browse files
committed
fix tests not finishing (close test server)
1 parent a8496fc commit 96cfb6a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const { t, not, ot } = require('./test.js') // eslint-disable-line
44
const cp = require('child_process')
55
const path = require('path')
6+
const net = require('net')
67

78
/** @type {import('../types')} */
89
const postgres = require('../lib')
@@ -980,7 +981,7 @@ t('Query and parameters are enumerable if debug is set', async() => {
980981

981982
t('connect_timeout works', async() => {
982983
const connect_timeout = 0.2
983-
const server = require('net').createServer()
984+
const server = net.createServer()
984985
server.listen()
985986
const sql = postgres({ port: server.address().port, connect_timeout })
986987
const start = Date.now()
@@ -990,6 +991,7 @@ t('connect_timeout works', async() => {
990991
throw e
991992
end = Date.now()
992993
})
994+
server.close()
993995
return [connect_timeout, Math.floor((end - start) / 100) / 10]
994996
})
995997

@@ -1065,13 +1067,13 @@ t('Insert array in sql()', async() => {
10651067
})
10661068

10671069
t('Automatically creates prepared statements', async() => {
1068-
const sql = postgres({ no_prepare: false })
1070+
const sql = postgres({ ...options, no_prepare: false })
10691071
const result = await sql`select * from pg_prepared_statements`
10701072
return [result[0].statement, 'select * from pg_prepared_statements']
10711073
})
10721074

10731075
t('no_prepare: true disables prepared transactions', async() => {
1074-
const sql = postgres({ no_prepare: true })
1076+
const sql = postgres({ ...options, no_prepare: true })
10751077
const result = await sql`select * from pg_prepared_statements`
10761078
return [0, result.count]
10771079
})

0 commit comments

Comments
 (0)