node-postgres/test/integration/connection-pool/yield-support-body.js

29 lines
580 B
JavaScript
Raw Normal View History

var helper = require('./test-helper')
var co = require('co')
var tid = setTimeout(function() {
2016-07-19 23:17:40 +08:00
throw new Error('Tests did not complete in time')
}, 1000)
co(function * () {
var client = yield helper.pg.connect()
var res = yield client.query('SELECT $1::text as name', ['foo'])
assert.equal(res.rows[0].name, 'foo')
var threw = false
try {
yield client.query('SELECT LKDSJDSLKFJ')
} catch(e) {
threw = true
}
assert(threw)
client.release()
helper.pg.end()
clearTimeout(tid)
})
.catch(function(e) {
setImmediate(function() {
throw e
})
})