mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
* Make tests pass in github codespaces There were a few tests which didn't specify a host or port which wasn't working well inside the codespaces docker environment. Added host & port where required. Also noticed one test wasn't actually _testing_, it was just `console.log`-ing its output, so I added proper assertions there. Finally set `PGTESTNOSSL: true` in the codespaces environment until I can get the postgres docker container configured w/ SSL...which I will do l8r. * lint
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
'use strict'
|
|
|
|
const helper = require('./test-helper')
|
|
const pg = helper.pg
|
|
|
|
const suite = new helper.Suite()
|
|
|
|
suite.test('valid connection completes promise', () => {
|
|
const client = new pg.Client()
|
|
return client.connect().then(() => {
|
|
return client.end().then(() => {})
|
|
})
|
|
})
|
|
|
|
suite.test('valid connection completes promise', () => {
|
|
const client = new pg.Client()
|
|
return client.connect().then(() => {
|
|
return client.end().then(() => {})
|
|
})
|
|
})
|
|
|
|
suite.test('invalid connection rejects promise', (done) => {
|
|
const client = new pg.Client({ host: 'alksdjflaskdfj', port: 1234 })
|
|
return client.connect().catch((e) => {
|
|
assert(e instanceof Error)
|
|
done()
|
|
})
|
|
})
|
|
|
|
suite.test('connected client does not reject promise after connection', (done) => {
|
|
const client = new pg.Client()
|
|
return client.connect().then(() => {
|
|
setTimeout(() => {
|
|
client.on('error', (e) => {
|
|
assert(e instanceof Error)
|
|
client.end()
|
|
done()
|
|
})
|
|
// manually kill the connection
|
|
client.emit('error', new Error('something bad happened...but not really'))
|
|
}, 50)
|
|
})
|
|
})
|