-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path1854-tests.js
33 lines (31 loc) · 951 Bytes
/
1854-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict"
var helper = require('./../test-helper')
const suite = new helper.Suite()
suite.test('Parameter serialization errors should not cause query to hang', (done) => {
if (helper.config.native) {
// pg-native cannot handle non-string parameters so skip this entirely
return done()
}
const client = new helper.pg.Client()
const expectedErr = new Error('Serialization error')
client.connect()
.then(() => {
const obj = {
toPostgres: function () {
throw expectedErr
}
}
return client.query('SELECT $1::text', [obj])
.then(() => {
throw new Error('Expected a serialization error to be thrown but no error was thrown')
})
})
.catch((err) => {
client.end(() => {})
if (err !== expectedErr) {
done(new Error('Expected a serialization error to be thrown but instead caught: ' + err))
return
}
done()
})
})