This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/node_modules/mysql2/test/integration/connection/test-errors.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-09-24 17:56:53 -04:00
var common = require('../../common');
var connection = common.createConnection();
var assert = require('assert');
var onExecuteResultError = undefined;
var onQueryResultError = undefined;
var onExecuteErrorEvent = undefined;
var onQueryErrorEvent = undefined;
var onExecuteErrorEvent1 = undefined;
var onQueryErrorEvent1 = undefined;
connection.execute('error in execute', [], function(err, _rows, _fields) {
if (err) {
onExecuteResultError = true;
}
}).on('error', function() {
onExecuteErrorEvent = true;
});
connection.query('error in query', [], function(err, _rows, _fields) {
if (err) {
onQueryResultError = true;
}
}).on('error', function() {
onQueryErrorEvent = true;
});
connection.execute('error in execute 1', []).on('error', function() {
onExecuteErrorEvent1 = true;
});
connection.query('error in query 1').on('error', function() {
onQueryErrorEvent1 = true;
});
connection.end();
process.on('exit', function() {
assert.equal(onExecuteResultError, true);
assert.equal(onQueryResultError, true);
assert.equal(onExecuteErrorEvent, undefined);
assert.equal(onQueryErrorEvent, undefined);
assert.equal(onExecuteErrorEvent1, true);
assert.equal(onQueryErrorEvent1, true);
});