mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-25 16:03:13 +00:00
* Handle bad message ordering - make it catchable. Fixes 3174 * Close client in test * Mess w/ github action settings * update ci config * Remove redundant tests * Update code to use handle error event * Add tests for commandComplete message being out of order * Lint fix * Fix native tests * Fix lint again...airport computer not my friend * Not a native issue
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
var Client = require('../')
|
|
var async = require('async')
|
|
var ok = require('okay')
|
|
var bytes = require('crypto').pseudoRandomBytes
|
|
|
|
describe('many connections', function () {
|
|
describe('async', function () {
|
|
var test = function (count, times) {
|
|
it(`connecting ${count} clients ${times} times`, function (done) {
|
|
this.timeout(200000)
|
|
|
|
var connectClient = function (n, cb) {
|
|
var client = new Client()
|
|
client.connect(
|
|
ok(cb, function () {
|
|
bytes(
|
|
1000,
|
|
ok(cb, function (chunk) {
|
|
client.query(
|
|
'SELECT $1::text as txt',
|
|
[chunk.toString('base64')],
|
|
ok(cb, function (rows) {
|
|
client.end(cb)
|
|
})
|
|
)
|
|
})
|
|
)
|
|
})
|
|
)
|
|
}
|
|
|
|
var run = function (n, cb) {
|
|
async.times(count, connectClient, cb)
|
|
}
|
|
|
|
async.timesSeries(times, run, done)
|
|
})
|
|
}
|
|
|
|
test(1, 1)
|
|
test(5, 5)
|
|
test(10, 10)
|
|
test(20, 20)
|
|
test(30, 10)
|
|
})
|
|
})
|