Brian C 50c06f9bc6
Remove test globals (#3264)
* Remove assert from globals

* Remove Client from globals

* Remove global test function

* Remove MemoryStream from globals

* Require assert in SASL integration tests

* Attempt to use a postgres with ssl?

* Use latest image

* Remove connection tests - they test internals that are better covered by testint the client
2024-06-19 13:46:16 -05:00

63 lines
1.6 KiB
JavaScript

'use strict'
var helper = require('./test-helper')
var Query = helper.pg.Query
var suite = new helper.Suite()
const assert = require('assert')
const Pool = helper.pg.Pool
suite.test('no domain', function (cb) {
assert(!process.domain)
const pool = new Pool()
pool.connect(
assert.success(function (client, done) {
assert(!process.domain)
done()
pool.end(cb)
})
)
})
suite.test('with domain', function (cb) {
assert(!process.domain)
const pool = new Pool()
var domain = require('domain').create()
domain.run(function () {
var startingDomain = process.domain
assert(startingDomain)
pool.connect(
assert.success(function (client, done) {
assert(process.domain, 'no domain exists in connect callback')
assert.equal(startingDomain, process.domain, 'domain was lost when checking out a client')
client.query(
'SELECT NOW()',
assert.success(function () {
assert(process.domain, 'no domain exists in query callback')
assert.equal(startingDomain, process.domain, 'domain was lost when checking out a client')
done(true)
process.domain.exit()
pool.end(cb)
})
)
})
)
})
})
suite.test('error on domain', function (cb) {
var domain = require('domain').create()
const pool = new Pool()
domain.on('error', function () {
pool.end(cb)
})
domain.run(function () {
pool.connect(
assert.success(function (client, done) {
client.query(new Query('SELECT SLDKJFLSKDJF'))
client.on('drain', done)
})
)
})
})