Skip to content

Commit dae7b2b

Browse files
committed
Add test for LOB error event
1 parent 8e57f96 commit dae7b2b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

test/dataTypeClob.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,46 @@ describe('40. dataTypeClob.js', function() {
221221
], done); // async
222222

223223
}) // 40.1.1
224+
225+
it('40.1.2 catches Error event correctly', function(done) {
226+
var lobErrorEvent = false;
227+
setTimeout( function() {
228+
lobErrorEvent.should.equal(true, "LOB should catch the 'error' event!");
229+
done();
230+
}, 1000);
231+
232+
connection.execute(
233+
"INSERT INTO oracledb_myclobs (num, content) VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv",
234+
{ n: 2, lobbv: {type: oracledb.CLOB, dir: oracledb.BIND_OUT} },
235+
{ autoCommit: true },
236+
function(err, result) {
237+
should.not.exist(err);
238+
(result.rowsAffected).should.be.exactly(1);
239+
(result.outBinds.lobbv.length).should.be.exactly(1);
240+
241+
var inStream = fs.createReadStream(inFileName);
242+
var lob = result.outBinds.lobbv[0];
243+
244+
lob.on('error', function(err) {
245+
should.exist(err, "lob.on 'error' event");
246+
(err.message).should.startWith('ORA-22990');
247+
// ORA-22990: LOB locators cannot span transactions
248+
lobErrorEvent = true;
249+
});
250+
251+
inStream.on('error', function(err) {
252+
should.not.exist(err, "inStream.on 'error' event");
253+
});
254+
255+
inStream.on('end', function() {
256+
connection.commit( function(err) {
257+
should.not.exist(err);
258+
});
259+
});
260+
inStream.pipe(lob);
261+
}
262+
);
263+
})
224264
}) // 40.1
225265

226266
describe('40.2 stores null value correctly', function() {

test/list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
40. dataTypeClob.js
375375
40.1 testing CLOB data type
376376
40.1.1 stores CLOB value correctly
377+
40.1.2 catches Error event correctly
377378
40.2 stores null value correctly
378379
40.2.1 testing Null, Empty string and Undefined
379380

0 commit comments

Comments
 (0)