mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Replaces __dirname concatentation in pg test scripts so that editors like VS Code can automatically generate typings and support code navigation (F12).
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
'use strict'
|
|
var helper = require('../test-helper')
|
|
var Client = require('../../lib/native')
|
|
var Query = Client.Query
|
|
|
|
test('many rows', function () {
|
|
var client = new Client(helper.config)
|
|
client.connect()
|
|
var q = client.query(new Query('SELECT * FROM person'))
|
|
var rows = []
|
|
q.on('row', function (row) {
|
|
rows.push(row)
|
|
})
|
|
assert.emits(q, 'end', function () {
|
|
client.end()
|
|
assert.lengthIs(rows, 26)
|
|
})
|
|
})
|
|
|
|
test('many queries', function () {
|
|
var client = new Client(helper.config)
|
|
client.connect()
|
|
var count = 0
|
|
var expected = 100
|
|
for (var i = 0; i < expected; i++) {
|
|
var q = client.query(new Query('SELECT * FROM person'))
|
|
assert.emits(q, 'end', function () {
|
|
count++
|
|
})
|
|
}
|
|
assert.emits(client, 'drain', function () {
|
|
client.end()
|
|
assert.equal(count, expected)
|
|
})
|
|
})
|
|
|
|
test('many clients', function () {
|
|
var clients = []
|
|
for (var i = 0; i < 10; i++) {
|
|
clients.push(new Client(helper.config))
|
|
}
|
|
clients.forEach(function (client) {
|
|
client.connect()
|
|
for (var i = 0; i < 20; i++) {
|
|
client.query('SELECT * FROM person')
|
|
}
|
|
assert.emits(client, 'drain', function () {
|
|
client.end()
|
|
})
|
|
})
|
|
})
|