mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
* Make active query a private prop * Make client.queryQueue private (with deprecation) * Deprecate some legacy features * Update packages/pg/lib/client.js Co-authored-by: Charmander <~@charmander.me> --------- Co-authored-by: Brian Carlson <brian.carlson@getcruise.com> Co-authored-by: Charmander <~@charmander.me>
39 lines
983 B
JavaScript
39 lines
983 B
JavaScript
'use strict'
|
|
const helper = require('./test-helper')
|
|
const Connection = require('../../../lib/connection')
|
|
const Client = require('../../../lib/client')
|
|
const assert = require('assert')
|
|
const suite = new helper.Suite()
|
|
|
|
suite.test('emits end when not in query', function () {
|
|
const stream = new (require('events').EventEmitter)()
|
|
stream.setNoDelay = () => {}
|
|
stream.connect = function () {
|
|
// NOOP
|
|
}
|
|
stream.write = function () {
|
|
// NOOP
|
|
}
|
|
|
|
const client = new Client({ connection: new Connection({ stream: stream }) })
|
|
client.connect(
|
|
assert.calls(function () {
|
|
client.query(
|
|
'SELECT NOW()',
|
|
assert.calls(function (err, result) {
|
|
assert(err)
|
|
})
|
|
)
|
|
})
|
|
)
|
|
assert.emits(client, 'error')
|
|
assert.emits(client, 'end')
|
|
client.connection.emit('connect')
|
|
process.nextTick(function () {
|
|
client.connection.emit('readyForQuery')
|
|
process.nextTick(function () {
|
|
stream.emit('close')
|
|
})
|
|
})
|
|
})
|