mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
* Work on converting lib to standard * Finish updating lib * Finish linting lib * Format test files * Add .eslintrc with standard format * Supply full path to eslint bin * Move lint command to package.json * Add eslint as dev dependency
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
'use strict'
|
|
var helper = require(__dirname + '/test-helper')
|
|
// http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
|
|
|
|
test('flushing once', function () {
|
|
helper.connect(function (con) {
|
|
con.parse({
|
|
text: 'select * from ids'
|
|
})
|
|
|
|
con.bind()
|
|
con.execute()
|
|
con.flush()
|
|
|
|
assert.emits(con, 'parseComplete')
|
|
assert.emits(con, 'bindComplete')
|
|
assert.emits(con, 'dataRow')
|
|
assert.emits(con, 'commandComplete', function () {
|
|
con.sync()
|
|
})
|
|
assert.emits(con, 'readyForQuery', function () {
|
|
con.end()
|
|
})
|
|
})
|
|
})
|
|
|
|
test('sending many flushes', function () {
|
|
helper.connect(function (con) {
|
|
assert.emits(con, 'parseComplete', function () {
|
|
con.bind()
|
|
con.flush()
|
|
})
|
|
|
|
assert.emits(con, 'bindComplete', function () {
|
|
con.execute()
|
|
con.flush()
|
|
})
|
|
|
|
assert.emits(con, 'dataRow', function (msg) {
|
|
assert.equal(msg.fields[0], 1)
|
|
assert.emits(con, 'dataRow', function (msg) {
|
|
assert.equal(msg.fields[0], 2)
|
|
assert.emits(con, 'commandComplete', function () {
|
|
con.sync()
|
|
})
|
|
assert.emits(con, 'readyForQuery', function () {
|
|
con.end()
|
|
})
|
|
})
|
|
})
|
|
|
|
con.parse({
|
|
text: 'select * from ids order by id'
|
|
})
|
|
|
|
con.flush()
|
|
})
|
|
})
|