mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
* 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
39 lines
907 B
JavaScript
39 lines
907 B
JavaScript
'use strict'
|
|
const helper = require('./test-helper')
|
|
const { Client } = helper
|
|
var Connection = require('../../../lib/connection')
|
|
const assert = require('assert')
|
|
const suite = new helper.Suite()
|
|
const test = suite.test.bind(suite)
|
|
|
|
test('drain', function () {
|
|
var con = new Connection({ stream: 'NO' })
|
|
var client = new Client({ connection: con })
|
|
con.connect = function () {
|
|
con.emit('connect')
|
|
}
|
|
con.query = function () {}
|
|
client.connect()
|
|
|
|
var raisedDrain = false
|
|
client.on('drain', function () {
|
|
raisedDrain = true
|
|
})
|
|
|
|
client.query('hello')
|
|
client.query('sup')
|
|
client.query('boom')
|
|
assert.equal(raisedDrain, false)
|
|
con.emit('readyForQuery')
|
|
|
|
assert.equal(raisedDrain, false)
|
|
con.emit('readyForQuery')
|
|
con.emit('readyForQuery')
|
|
assert.equal(raisedDrain, false)
|
|
con.emit('readyForQuery')
|
|
|
|
process.nextTick(function () {
|
|
assert.ok(raisedDrain)
|
|
})
|
|
})
|