Resolve a race condition in tests
This commit is contained in:
parent
ea5aaedc3d
commit
6adbd12c04
|
@ -742,6 +742,7 @@ assist.verifyRefCursor = function(connection, tableName, array, done)
|
||||||
|
|
||||||
function fetchRowsFromRS(rs, array, cb)
|
function fetchRowsFromRS(rs, array, cb)
|
||||||
{
|
{
|
||||||
|
var numRows = 3;
|
||||||
rs.getRows(numRows, function(err, rows) {
|
rs.getRows(numRows, function(err, rows) {
|
||||||
if(rows.length > 0) {
|
if(rows.length > 0) {
|
||||||
for(var i = 0; i < rows.length; i++) {
|
for(var i = 0; i < rows.length; i++) {
|
||||||
|
@ -947,7 +948,7 @@ assist.verifyRefCursorWithFetchInfo = function(connection, tableName, array, don
|
||||||
},
|
},
|
||||||
function(err, result) {
|
function(err, result) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
fetchRowsFromRS_fetchas(connection, result.outBinds.out, array, tableName, callback);
|
_verifyFetchedValues(connection, result.outBinds.out, array, tableName, callback);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -990,7 +991,7 @@ assist.verifyRefCursorWithFetchAsString = function(connection, tableName, array,
|
||||||
{ outFormat: oracledb.OBJECT },
|
{ outFormat: oracledb.OBJECT },
|
||||||
function(err, result) {
|
function(err, result) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
fetchRowsFromRS_fetchas(connection, result.outBinds.out, array, tableName, callback);
|
_verifyFetchedValues(connection, result.outBinds.out, array, tableName, callback);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1006,40 +1007,34 @@ assist.verifyRefCursorWithFetchAsString = function(connection, tableName, array,
|
||||||
], done);
|
], done);
|
||||||
};
|
};
|
||||||
|
|
||||||
var numRows = 3; // number of rows to return from each call to getRows()
|
var _verifyFetchedValues = function(connection, rs, array, tableName, cb) {
|
||||||
|
var amount = array.length;
|
||||||
function fetchRowsFromRS_fetchas(connection, rs, array, tableName, cb) {
|
rs.getRows(amount, function(err, rows) {
|
||||||
rs.getRows(numRows, function(err, rsrows) {
|
async.each(
|
||||||
if(rsrows.length > 0) {
|
rows,
|
||||||
for(var i = 0; i < rsrows.length; i++) {
|
queryAndCompare,
|
||||||
(rsrows[i].CONTENT).should.be.a.String();
|
function(err) {
|
||||||
verifyFetchValues(connection, rsrows, i, array, tableName);
|
|
||||||
}
|
|
||||||
return fetchRowsFromRS_fetchas(connection, rs, array, tableName, cb);
|
|
||||||
} else {
|
|
||||||
rs.close(function(err) {
|
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
cb();
|
rs.close(function(err) {
|
||||||
});
|
should.not.exist(err);
|
||||||
}
|
return cb();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
function verifyFetchValues(connection, rsrows, i, array, tableName){
|
|
||||||
connection.execute(
|
|
||||||
"select CONTENT from " + tableName + " where NUM = " + rsrows[i].NUM,
|
|
||||||
[],
|
|
||||||
{
|
|
||||||
fetchInfo:
|
|
||||||
{
|
|
||||||
"CONTENT": { type: oracledb.STRING }
|
|
||||||
}
|
}
|
||||||
},
|
);
|
||||||
function(err, result) {
|
});
|
||||||
should.not.exist(err);
|
|
||||||
rsrows[i].CONTENT.should.eql(result.rows[0][0]);
|
var queryAndCompare = function(row, callback) {
|
||||||
}
|
var sql = "select content from " + tableName + " where num = " + row.NUM;
|
||||||
);
|
connection.execute(
|
||||||
}
|
sql,
|
||||||
|
[],
|
||||||
|
{ fetchInfo: { "CONTENT": { type: oracledb.STRING } } },
|
||||||
|
function(err, result) {
|
||||||
|
should.strictEqual(row.CONTENT, result.rows[0][0]);
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}; // _verifyFetchedValues()
|
||||||
|
|
||||||
module.exports = assist;
|
module.exports = assist;
|
||||||
|
|
|
@ -75,6 +75,7 @@ describe('34. dataTypeTimestamp2.js', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
|
oracledb.fetchAsString = [];
|
||||||
connection.execute(
|
connection.execute(
|
||||||
"DROP table " + tableName + " PURGE",
|
"DROP table " + tableName + " PURGE",
|
||||||
function(err) {
|
function(err) {
|
||||||
|
|
Loading…
Reference in New Issue