Skip to content

Commit 5326b17

Browse files
committed
Update tests for LOB bind enhancement
1 parent 252acce commit 5326b17

File tree

2 files changed

+51
-16
lines changed

2 files changed

+51
-16
lines changed

test/list.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ Overview of node-oracledb functional tests
12261226
71.1.6 BIND_OUT, PL/SQL, a txt file
12271227
71.1.7 BIND_INOUT, PL/SQL, A String. IN LOB gets closed automatically.
12281228
71.1.8 BIND_INOUT, PL/SQL, a txt file
1229-
71.1.9 Negative: BIND_INOUT, PL/SQL, String as bind IN Value
1229+
71.1.9 BIND_INOUT, PL/SQL, a String as the bind IN Value
12301230
71.2 persistent BLOB
12311231
71.2.1 BIND_IN, DML, a Buffer value
12321232
71.2.2 BIND_IN, DML, null
@@ -1236,7 +1236,7 @@ Overview of node-oracledb functional tests
12361236
71.2.6 BIND_OUT, PL/SQL, a jpg file
12371237
71.2.7 BIND_INOUT, PL/SQL, a Buffer value
12381238
71.2.8 BIND_INOUT, PL/SQL, a jpg file
1239-
71.2.9 Negative: BIND_INOUT, PL/SQL, Buffer as bind IN value
1239+
71.2.9 BIND_INOUT, PL/SQL, a Buffer as the bind IN value
12401240

12411241
72. lobBind2.js
12421242
72.1 CLOB

test/lobBind1.js

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,11 @@ describe('71. lobBind1.js', function() {
792792

793793
}); // 71.1.8
794794

795-
it('71.1.9 Negative: BIND_INOUT, PL/SQL, String as bind IN Value', function(done) {
795+
it('71.1.9 BIND_INOUT, PL/SQL, a String as the bind IN Value', function(done) {
796796

797797
var seq = 9;
798-
var inStr = "I love the sunshine today!",
799-
outStr = "A new day has come.";
798+
var inStr = "I love the sunshine today!";
799+
var outStr = "A new day has come.";
800800

801801
var proc = "CREATE OR REPLACE PROCEDURE nodb_proc_clob_inout3 \n" +
802802
" (p_num IN NUMBER, p_inout IN OUT CLOB) \n" +
@@ -820,11 +820,26 @@ describe('71. lobBind1.js', function() {
820820
io: { val: inStr, type: oracledb.CLOB, dir: oracledb.BIND_INOUT }
821821
},
822822
{ autoCommit: true },
823-
function(err) {
824-
should.exist(err);
825-
// NJS-011: encountered bind value and type mismatch in parameter 2
826-
(err.message).should.startWith('NJS-011:');
827-
cb();
823+
function(err, result) {
824+
should.not.exist(err);
825+
should.exist(result);
826+
var lobout = result.outBinds.io;
827+
828+
lobout.setEncoding("utf8");
829+
var clobData = '';
830+
831+
lobout.on('data', function(chunk) {
832+
clobData += chunk;
833+
});
834+
835+
lobout.on('error',function(err) {
836+
should.not.exist(err, "lob.on 'error' event!");
837+
});
838+
839+
lobout.on('end', function() {
840+
should.strictEqual(clobData, outStr);
841+
return cb();
842+
});
828843
}
829844
);
830845
},
@@ -1541,7 +1556,7 @@ describe('71. lobBind1.js', function() {
15411556

15421557
}); // 71.2.8
15431558

1544-
it('71.2.9 Negative: BIND_INOUT, PL/SQL, Buffer as bind IN value', function(done) {
1559+
it('71.2.9 BIND_INOUT, PL/SQL, a Buffer as the bind IN value', function(done) {
15451560

15461561
var seq = 9;
15471562
var inBuf = assist.createBuffer(10);
@@ -1573,12 +1588,32 @@ describe('71. lobBind1.js', function() {
15731588
sql,
15741589
bindvar,
15751590
{ autoCommit: true },
1576-
function(err) {
1577-
should.exist(err);
1578-
(err.message).should.startWith('NJS-011:');
1579-
// NJS-011: encountered bind value and type mismatch in parameter 2
1591+
function(err, result) {
1592+
should.not.exist(err);
1593+
should.exist(result);
1594+
var lob = result.outBinds.io;
1595+
should.exist(lob);
1596+
1597+
var blobData, totalLength = 0;
1598+
blobData = node6plus ? Buffer.alloc(0) : new Buffer(0);
1599+
1600+
lob.on('data', function(chunk) {
1601+
totalLength = totalLength + chunk.length;
1602+
blobData = Buffer.concat([blobData, chunk], totalLength);
1603+
});
1604+
1605+
lob.on('error', function(err) {
1606+
should.not.exist(err, "lob.on 'error' event.");
1607+
});
1608+
1609+
lob.on('end', function() {
1610+
fs.readFile(jpgFileName, function(err, originalData) {
1611+
should.not.exist(err);
1612+
should.strictEqual(totalLength, originalData.length);
1613+
return cb();
1614+
});
1615+
});
15801616

1581-
cb();
15821617
}
15831618
);
15841619
},

0 commit comments

Comments
 (0)