2016-07-19 23:16:48 +08:00
|
|
|
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')
|
2016-07-19 23:16:48 +08:00
|
|
|
}, 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
|
|
|
|
})
|
|
|
|
})
|