mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-25 16:03:13 +00:00
Fix error handling test
#2569 introduced a bug in the test. The test never passed but because travis-ci lovingly broke the integration we had a long time ago the tests weren't run in CI until I merged. So, this fixes the tests & does a better job cleaning up the query in an errored state.
This commit is contained in:
parent
747485d342
commit
8bd43a5d81
@ -417,11 +417,11 @@ class Pool extends EventEmitter {
|
||||
client.release(err)
|
||||
if (err) {
|
||||
return cb(err)
|
||||
} else {
|
||||
return cb(undefined, res)
|
||||
}
|
||||
return cb(undefined, res)
|
||||
})
|
||||
} catch (err) {
|
||||
client.release(err)
|
||||
return cb(err)
|
||||
}
|
||||
})
|
||||
|
||||
@ -38,14 +38,15 @@ describe('pool error handling', function () {
|
||||
})
|
||||
|
||||
it('Catches errors in client.query', async function () {
|
||||
await expect((new Pool()).query(null)).to.throwError()
|
||||
await expect(async () => {
|
||||
try {
|
||||
await (new Pool()).query(null)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}).not.to.throwError()
|
||||
let caught = false
|
||||
const pool = new Pool()
|
||||
try {
|
||||
await pool.query(null)
|
||||
} catch (e) {
|
||||
caught = true
|
||||
}
|
||||
pool.end()
|
||||
expect(caught).to.be(true)
|
||||
})
|
||||
|
||||
describe('calling release more than once', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user