Skip to content

Commit 4ef6c07

Browse files
committed
Update tests
1 parent 1b4b004 commit 4ef6c07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2309
-76
lines changed

test/binding.js

100644100755
File mode changed.

test/binding_functionBindInout.js

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ describe('95.binding_functionBindInout.js', function() {
7070
});
7171
});
7272

73-
var doTest = function(table_name, procPre, bindType, dbColType, content, sequence, nullBind, callback) {
73+
var doTest = function(table_name, proc_name, bindType, dbColType, content, sequence, nullBind, callback) {
7474
async.series([
7575
function(cb) {
7676
var bindVar = {
7777
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
7878
c: { val: content, type: bindType, dir: oracledb.BIND_INOUT, maxSize: 1000 },
7979
output: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }
8080
};
81-
inBind(table_name, procPre, dbColType, bindVar, bindType, nullBind, cb);
81+
inBind(table_name, proc_name, dbColType, bindVar, bindType, nullBind, cb);
8282
},
8383
function(cb) {
8484
var bindVar =[ { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }, sequence, { val: content, type: bindType, dir: oracledb.BIND_INOUT, maxSize: 1000 } ];
85-
inBind(table_name, procPre, dbColType, bindVar, bindType, nullBind, cb);
85+
inBind(table_name, proc_name, dbColType, bindVar, bindType, nullBind, cb);
8686
}
8787
], callback);
8888
};

test/binding_functionBindOut.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ describe('97.binding_functionBindOut.js', function() {
7070
});
7171
});
7272

73-
var doTest = function(table_name, procPre, bindType, dbColType, content, sequence, nullBind, callback) {
73+
var doTest = function(table_name, proc_name, bindType, dbColType, content, sequence, nullBind, callback) {
7474
async.series([
7575
function(cb) {
7676
var bindVar = {
7777
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
7878
c: { type: bindType, dir: oracledb.BIND_OUT, maxSize: 1000 },
7979
output: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT, maxSize: 1000 }
8080
};
81-
inBind(table_name, procPre, sequence, dbColType, bindVar, bindType, nullBind, cb);
81+
inBind(table_name, proc_name, sequence, dbColType, bindVar, bindType, nullBind, cb);
8282
},
8383
function(cb) {
8484
var bindVar =[ { type: oracledb.NUMBER, dir: oracledb.BIND_OUT, maxSize: 1000 }, sequence, { type: bindType, dir: oracledb.BIND_OUT, maxSize: 1000 } ];
85-
inBind(table_name, procPre, sequence, dbColType, bindVar, bindType, nullBind, cb);
85+
inBind(table_name, proc_name, sequence, dbColType, bindVar, bindType, nullBind, cb);
8686
}
8787
], callback);
8888
};

test/binding_procedureBindIn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ describe('93.binding_procedureBindIn.js', function() {
7474
async.series([
7575
function(cb) {
7676
var bindVar = { c: { val: content, type: bindType, dir: oracledb.BIND_IN } };
77-
inBind(table_name, procPre, dbColType, bindVar, bindType, nullBind, cb);
77+
inBind(table_name, proc_name, dbColType, bindVar, bindType, nullBind, cb);
7878
},
7979
function(cb) {
8080
var bindVar =[ { val: content, type: bindType, dir: oracledb.BIND_IN } ];
81-
inBind(table_name, procPre, dbColType, bindVar, bindType, nullBind, cb);
81+
inBind(table_name, proc_name, dbColType, bindVar, bindType, nullBind, cb);
8282
}
8383
], callback);
8484
};

test/binding_procedureBindInout.js

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ describe('94.binding_procedureBindInout.js', function() {
7070
});
7171
});
7272

73-
var doTest = function(table_name, procPre, bindType, dbColType, content, sequence, nullBind, callback) {
73+
var doTest = function(table_name, proc_name, bindType, dbColType, content, sequence, nullBind, callback) {
7474
async.series([
7575
function(cb) {
7676
var bindVar = {
7777
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
7878
c: { val: content, type: bindType, dir: oracledb.BIND_INOUT, maxSize: 1000 }
7979
};
80-
inBind(table_name, procPre, dbColType, bindVar, bindType, nullBind, cb);
80+
inBind(table_name, proc_name, dbColType, bindVar, bindType, nullBind, cb);
8181
},
8282
function(cb) {
8383
var bindVar =[ sequence, { val: content, type: bindType, dir: oracledb.BIND_INOUT, maxSize: 1000 } ];
84-
inBind(table_name, procPre, dbColType, bindVar, bindType, nullBind, cb);
84+
inBind(table_name, proc_name, dbColType, bindVar, bindType, nullBind, cb);
8585
}
8686
], callback);
8787
};

test/binding_procedureBindOut.js

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ describe('96.binding_procedureBindOut.js', function() {
7676
procName = procName + "_1";
7777
var bindVar = {
7878
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
79-
c: { val: content, type: bindType, dir: oracledb.BIND_OUT, maxSize: 1000 }
79+
c: { type: bindType, dir: oracledb.BIND_OUT, maxSize: 1000 }
8080
};
8181
inBind(table_name, procName, sequence, dbColType, bindVar, bindType, nullBind, cb);
8282
},
8383
function(cb) {
8484
procName = procName + "_2";
85-
var bindVar =[ sequence, { val: content, type: bindType, dir: oracledb.BIND_OUT, maxSize: 1000 } ];
85+
var bindVar =[ sequence, { type: bindType, dir: oracledb.BIND_OUT, maxSize: 1000 } ];
8686
inBind(table_name, procName, sequence, dbColType, bindVar, bindType, nullBind, cb);
8787
}
8888
], callback);

test/clobPlsqlBindAsString_bindout.js

100644100755
File mode changed.

test/dataTypeAssist.js

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,6 @@ assist.verifyRefCursor = function(connection, tableName, array, done)
740740
], done);
741741
};
742742

743-
var numRows = 3; // number of rows to return from each call to getRows()
744743
function fetchRowsFromRS(rs, array, cb)
745744
{
746745
rs.getRows(numRows, function(err, rows) {
@@ -915,4 +914,132 @@ assist.compareNodejsVersion = function(nowVersion, comparedVersion) {
915914
}
916915
};
917916

917+
assist.verifyRefCursorWithFetchInfo = function(connection, tableName, array, done){
918+
var createProc =
919+
"CREATE OR REPLACE PROCEDURE testproc (p_out OUT SYS_REFCURSOR) " +
920+
"AS " +
921+
"BEGIN " +
922+
" OPEN p_out FOR " +
923+
"SELECT * FROM " + tableName + "; " +
924+
"END; ";
925+
async.series([
926+
function createProcedure(callback) {
927+
connection.execute(
928+
createProc,
929+
function(err) {
930+
should.not.exist(err);
931+
callback();
932+
}
933+
);
934+
},
935+
function verify(callback) {
936+
connection.execute(
937+
"begin testproc(:out); end;",
938+
{
939+
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
940+
},
941+
{
942+
outFormat: oracledb.OBJECT,
943+
fetchInfo:
944+
{
945+
"CONTENT": { type: oracledb.STRING }
946+
}
947+
},
948+
function(err, result) {
949+
should.not.exist(err);
950+
fetchRowsFromRS_fetchas(connection, result.outBinds.out, array, tableName, callback);
951+
}
952+
);
953+
},
954+
function dropProcedure(callback) {
955+
connection.execute(
956+
"DROP PROCEDURE testproc",
957+
function(err) {
958+
should.not.exist(err);
959+
callback();
960+
}
961+
);
962+
}
963+
], done);
964+
};
965+
966+
assist.verifyRefCursorWithFetchAsString = function(connection, tableName, array, done){
967+
var createProc =
968+
"CREATE OR REPLACE PROCEDURE testproc (p_out OUT SYS_REFCURSOR) " +
969+
"AS " +
970+
"BEGIN " +
971+
" OPEN p_out FOR " +
972+
"SELECT * FROM " + tableName + "; " +
973+
"END; ";
974+
async.series([
975+
function createProcedure(callback) {
976+
connection.execute(
977+
createProc,
978+
function(err) {
979+
should.not.exist(err);
980+
callback();
981+
}
982+
);
983+
},
984+
function verify(callback) {
985+
connection.execute(
986+
"begin testproc(:out); end;",
987+
{
988+
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
989+
},
990+
{ outFormat: oracledb.OBJECT },
991+
function(err, result) {
992+
should.not.exist(err);
993+
fetchRowsFromRS_fetchas(connection, result.outBinds.out, array, tableName, callback);
994+
}
995+
);
996+
},
997+
function dropProcedure(callback) {
998+
connection.execute(
999+
"DROP PROCEDURE testproc",
1000+
function(err) {
1001+
should.not.exist(err);
1002+
callback();
1003+
}
1004+
);
1005+
}
1006+
], done);
1007+
};
1008+
1009+
var numRows = 3; // number of rows to return from each call to getRows()
1010+
1011+
function fetchRowsFromRS_fetchas(connection, rs, array, tableName, cb) {
1012+
rs.getRows(numRows, function(err, rsrows) {
1013+
if(rsrows.length > 0) {
1014+
for(var i = 0; i < rsrows.length; i++) {
1015+
(rsrows[i].CONTENT).should.be.a.String();
1016+
verifyFetchValues(connection, rsrows, i, array, tableName);
1017+
}
1018+
return fetchRowsFromRS_fetchas(connection, rs, array, tableName, cb);
1019+
} else {
1020+
rs.close(function(err) {
1021+
should.not.exist(err);
1022+
cb();
1023+
});
1024+
}
1025+
});
1026+
}
1027+
1028+
function verifyFetchValues(connection, rsrows, i, array, tableName){
1029+
connection.execute(
1030+
"select CONTENT from " + tableName + " where NUM = " + rsrows[i].NUM,
1031+
[],
1032+
{
1033+
fetchInfo:
1034+
{
1035+
"CONTENT": { type: oracledb.STRING }
1036+
}
1037+
},
1038+
function(err, result) {
1039+
should.not.exist(err);
1040+
rsrows[i].CONTENT.should.eql(result.rows[0][0]);
1041+
}
1042+
);
1043+
}
1044+
9181045
module.exports = assist;

test/dataTypeBinaryDouble.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ describe('31. dataTypeBinaryDouble.js', function() {
7474
});
7575

7676
after(function(done) {
77+
oracledb.fetchAsString = [];
7778
connection.execute(
7879
"DROP table " + tableName + " PURGE",
7980
function(err) {
@@ -95,6 +96,15 @@ describe('31. dataTypeBinaryDouble.js', function() {
9596
assist.verifyRefCursor(connection, tableName, numbers, done);
9697
});
9798

99+
it('31.1.4 columns fetched from REF CURSORS can be mapped by fetchInfo settings', function(done) {
100+
assist.verifyRefCursorWithFetchInfo(connection, tableName, numbers, done);
101+
});
102+
103+
it('31.1.5 columns fetched from REF CURSORS can be mapped by oracledb.fetchAsString', function(done) {
104+
oracledb.fetchAsString = [ oracledb.NUMBER ];
105+
assist.verifyRefCursorWithFetchAsString(connection, tableName, numbers, done);
106+
});
107+
98108
});
99109

100110
describe('31.2 stores null value correctly', function() {
@@ -141,4 +151,6 @@ describe('31. dataTypeBinaryDouble.js', function() {
141151
});
142152

143153
}); // 31.3
154+
155+
144156
});

test/dataTypeBinaryFloat.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ describe('30. dataTypeBinaryFloat.js', function() {
7474
});
7575

7676
after(function(done) {
77+
oracledb.fetchAsString = [];
7778
connection.execute(
7879
"DROP table " + tableName + " PURGE",
7980
function(err) {
@@ -95,6 +96,15 @@ describe('30. dataTypeBinaryFloat.js', function() {
9596
assist.verifyRefCursor(connection, tableName, numbers, done);
9697
});
9798

99+
it('30.1.4 columns fetched from REF CURSORS can be mapped by fetchInfo settings', function(done) {
100+
assist.verifyRefCursorWithFetchInfo(connection, tableName, numbers, done);
101+
});
102+
103+
it('30.1.5 columns fetched from REF CURSORS can be mapped by oracledb.fetchAsString', function(done) {
104+
oracledb.fetchAsString = [ oracledb.NUMBER ];
105+
assist.verifyRefCursorWithFetchAsString(connection, tableName, numbers, done);
106+
});
107+
98108
}); // 30.1
99109

100110
describe('30.2 stores null value correctly', function() {

0 commit comments

Comments
 (0)