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
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
'use strict'
|
|
var helper = require(__dirname + '/test-helper')
|
|
var assert = require('assert')
|
|
|
|
test('COPY FROM events check', function () {
|
|
helper.connect(function (con) {
|
|
var stdinStream = con.query('COPY person FROM STDIN')
|
|
con.on('copyInResponse', function () {
|
|
con.endCopyFrom()
|
|
})
|
|
assert.emits(con, 'copyInResponse',
|
|
function () {
|
|
con.endCopyFrom()
|
|
},
|
|
'backend should emit copyInResponse after COPY FROM query'
|
|
)
|
|
assert.emits(con, 'commandComplete',
|
|
function () {
|
|
con.end()
|
|
},
|
|
'backend should emit commandComplete after COPY FROM stream ends'
|
|
)
|
|
})
|
|
})
|
|
test('COPY TO events check', function () {
|
|
helper.connect(function (con) {
|
|
var stdoutStream = con.query('COPY person TO STDOUT')
|
|
assert.emits(con, 'copyOutResponse',
|
|
function () {
|
|
},
|
|
'backend should emit copyOutResponse after COPY TO query'
|
|
)
|
|
assert.emits(con, 'copyData',
|
|
function () {
|
|
},
|
|
'backend should emit copyData on every data row'
|
|
)
|
|
assert.emits(con, 'copyDone',
|
|
function () {
|
|
con.end()
|
|
},
|
|
'backend should emit copyDone after all data rows'
|
|
)
|
|
})
|
|
})
|