Skip to content

Commit f2445f5

Browse files
committed
Refactor tests phase IV
1 parent 34f1487 commit f2445f5

22 files changed

+1094
-1251
lines changed

test/dataTypeAssist.js

Lines changed: 89 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ var should = require('should');
3737
var async = require('async');
3838

3939
var assist = exports;
40+
41+
/* Mapping between table names and data types */
42+
assist.allDataTypeNames =
43+
{
44+
"oracledb_char" : "CHAR(2000)",
45+
"oracledb_nchar" : "NCHAR(1000)",
46+
"oracledb_varchar2" : "VARCHAR2(4000)",
47+
"oracledb_nvarchar2" : "NVARCHAR2(2000)",
48+
"oracledb_number" : "NUMBER",
49+
"oracledb_number2" : "NUMBER(15, 5)",
50+
"oracledb_float" : "FLOAT",
51+
"oracledb_float2" : "FLOAT(90)",
52+
"oracledb_binary_float" : "BINARY_FLOAT",
53+
"oracledb_double" : "BINARY_DOUBLE",
54+
"oracledb_date" : "DATE",
55+
"oracledb_timestamp1" : "TIMESTAMP",
56+
"oracledb_timestamp2" : "TIMESTAMP(5)",
57+
"oracledb_timestamp3" : "TIMESTAMP WITH TIME ZONE",
58+
"oracledb_timestamp4" : "TIMESTAMP (2) WITH TIME ZONE",
59+
"oracledb_timestamp5" : "TIMESTAMP WITH LOCAL TIME ZONE",
60+
"oracledb_timestamp6" : "TIMESTAMP (9) WITH LOCAL TIME ZONE",
61+
"oracledb_rowid" : "ROWID",
62+
"oracledb_myclobs" : "CLOB",
63+
"oracledb_myblobs" : "BLOB"
64+
};
65+
4066
assist.data = {
4167
specialChars: [
4268
'\"',
@@ -111,6 +137,22 @@ assist.data = {
111137
't', 'u', 'v', 'w', 'x',
112138
'y', 'z'
113139
],
140+
numbers: [
141+
1,
142+
0,
143+
8,
144+
-8,
145+
1234,
146+
-1234,
147+
9876.54321,
148+
-9876.54321,
149+
0.01234,
150+
-0.01234,
151+
0.00000123,
152+
-0.00000123,
153+
1234567890.0123,
154+
-1234567890.0123
155+
],
114156
dates: [
115157
new Date(-100000000),
116158
new Date(0),
@@ -126,18 +168,6 @@ assist.data = {
126168
]
127169
};
128170

129-
assist.allDataTypeNames =
130-
{
131-
"oracledb_varchar2" : "VARCHAR2(4000)",
132-
"oracledb_date" : "DATE",
133-
"oracledb_timestamp1" : "TIMESTAMP",
134-
"oracledb_timestamp2" : "TIMESTAMP(5)",
135-
"oracledb_timestamp3" : "TIMESTAMP WITH TIME ZONE",
136-
"oracledb_timestamp4" : "TIMESTAMP (2) WITH TIME ZONE",
137-
"oracledb_timestamp5" : "TIMESTAMP WITH LOCAL TIME ZONE",
138-
"oracledb_timestamp6" : "TIMESTAMP (9) WITH LOCAL TIME ZONE"
139-
};
140-
141171
assist.DATE_STRINGS =
142172
[
143173
"TO_DATE('2005-01-06','YYYY-DD-MM') ",
@@ -253,45 +283,45 @@ assist.content =
253283
],
254284
timestamps5:
255285
[
256-
'01-06-2005 00:00:00.000000 ',
257-
'01-09-2005 00:00:00.000000 ',
258-
'05-08-2005 00:00:00.000000 ',
259-
'05-07-1998 00:00:00.000000 ',
260-
'07-05-1998 00:00:00.000000 ',
261-
'02-12-1999 03:00:00.100000 ',
262-
'02-12-1999 03:00:00.120000 ',
263-
'02-12-1999 03:00:00.123000 ',
264-
'02-12-1999 03:00:00.012300 ',
265-
'02-12-1999 03:00:00.123400 ',
266-
'02-12-1999 03:00:00.001230 ',
267-
'02-12-1999 03:00:00.123450 ',
268-
'02-12-1999 03:00:00.123456 ',
269-
'02-12-1999 03:00:00.123457 ',
270-
'02-12-1999 03:20:02.000012 ',
271-
'02-12-1999 03:00:00.123457 ',
272-
'02-12-1999 03:00:00.123457 ',
273-
'02-12-1999 03:00:00.000000 '
286+
'31-05-2005 23:00:00.000000 -08:00',
287+
'31-08-2005 23:00:00.000000 -08:00',
288+
'04-08-2005 23:00:00.000000 -08:00',
289+
'04-07-1998 23:00:00.000000 -08:00',
290+
'06-05-1998 23:00:00.000000 -08:00',
291+
'01-12-1999 11:00:00.100000 -08:00',
292+
'01-12-1999 11:00:00.120000 -08:00',
293+
'01-12-1999 11:00:00.123000 -08:00',
294+
'01-12-1999 11:00:00.012300 -08:00',
295+
'01-12-1999 11:00:00.123400 -08:00',
296+
'01-12-1999 11:00:00.001230 -08:00',
297+
'01-12-1999 11:00:00.123450 -08:00',
298+
'01-12-1999 11:00:00.123456 -08:00',
299+
'01-12-1999 11:00:00.123457 -08:00',
300+
'01-12-1999 11:20:02.000012 -08:00',
301+
'01-12-1999 11:00:00.123457 -08:00',
302+
'01-12-1999 11:00:00.123457 -08:00',
303+
'01-12-1999 11:00:00.000000 -08:00'
274304
],
275305
timestamps6:
276306
[
277-
'01-06-2005 00:00:00.000000000 ',
278-
'01-09-2005 00:00:00.000000000 ',
279-
'05-08-2005 00:00:00.000000000 ',
280-
'05-07-1998 00:00:00.000000000 ',
281-
'07-05-1998 00:00:00.000000000 ',
282-
'02-12-1999 03:00:00.100000000 ',
283-
'02-12-1999 03:00:00.120000000 ',
284-
'02-12-1999 03:00:00.123000000 ',
285-
'02-12-1999 03:00:00.012300000 ',
286-
'02-12-1999 03:00:00.123400000 ',
287-
'02-12-1999 03:00:00.001230000 ',
288-
'02-12-1999 03:00:00.123450000 ',
289-
'02-12-1999 03:00:00.123456000 ',
290-
'02-12-1999 03:00:00.123456700 ',
291-
'02-12-1999 03:20:02.000012300 ',
292-
'02-12-1999 03:00:00.123456780 ',
293-
'02-12-1999 03:00:00.123456789 ',
294-
'02-12-1999 03:00:00.000000000 '
307+
'31-05-2005 23:00:00.000000000 -08:00',
308+
'31-08-2005 23:00:00.000000000 -08:00',
309+
'04-08-2005 23:00:00.000000000 -08:00',
310+
'04-07-1998 23:00:00.000000000 -08:00',
311+
'06-05-1998 23:00:00.000000000 -08:00',
312+
'01-12-1999 11:00:00.100000000 -08:00',
313+
'01-12-1999 11:00:00.120000000 -08:00',
314+
'01-12-1999 11:00:00.123000000 -08:00',
315+
'01-12-1999 11:00:00.012300000 -08:00',
316+
'01-12-1999 11:00:00.123400000 -08:00',
317+
'01-12-1999 11:00:00.001230000 -08:00',
318+
'01-12-1999 11:00:00.123450000 -08:00',
319+
'01-12-1999 11:00:00.123456000 -08:00',
320+
'01-12-1999 11:00:00.123456700 -08:00',
321+
'01-12-1999 11:20:02.000012300 -08:00',
322+
'01-12-1999 11:00:00.123456780 -08:00',
323+
'01-12-1999 11:00:00.123456789 -08:00',
324+
'01-12-1999 11:00:00.000000000 -08:00'
295325
]
296326
};
297327

@@ -333,35 +363,6 @@ assist.createCharString = function(size) {
333363
return buffer.toString();
334364
}
335365

336-
assist.setup = function(connection, tableName, sqlCreate, array, done) {
337-
async.series([
338-
function(callback) {
339-
connection.execute(
340-
sqlCreate,
341-
function(err) {
342-
should.not.exist(err);
343-
callback();
344-
}
345-
);
346-
},
347-
function(callback) {
348-
async.forEach(array, function(element, cb) {
349-
connection.execute(
350-
"INSERT INTO " + tableName + " VALUES(:no, :bindValue)",
351-
{ no: array.indexOf(element), bindValue: element },
352-
function(err) {
353-
should.not.exist(err);
354-
cb();
355-
}
356-
);
357-
}, function(err) {
358-
should.not.exist(err);
359-
callback();
360-
});
361-
}
362-
], done);
363-
}
364-
365366
assist.setUp = function(connection, tableName, array, done)
366367
{
367368
async.series([
@@ -585,87 +586,6 @@ assist.selectOriginalData = function(connection, tableName, array, done)
585586
});
586587
}
587588

588-
assist.resultSetSupport = function(connection, tableName, array, done) {
589-
connection.should.be.ok;
590-
var numRows = 3; // number of rows to return from each call to getRows()
591-
connection.execute(
592-
"SELECT * FROM " + tableName,
593-
[],
594-
{ resultSet: true, outFormat: oracledb.OBJECT },
595-
function(err, result) {
596-
should.not.exist(err);
597-
(result.resultSet.metaData[0]).name.should.eql('NUM');
598-
(result.resultSet.metaData[1]).name.should.eql('CONTENT');
599-
fetchRowsFromRS(result.resultSet);
600-
}
601-
);
602-
603-
function fetchRowsFromRS(rs) {
604-
rs.getRows(numRows, function(err, rows) {
605-
should.not.exist(err);
606-
if(rows.length > 0) {
607-
for(var i = 0; i < rows.length; i++) {
608-
if( (typeof rows[i].CONTENT) === 'string' )
609-
rows[i].CONTENT.trim().should.eql(array[rows[i].NUM]);
610-
else if( (typeof rows[i].CONTENT) === 'number' )
611-
rows[i].CONTENT.should.eql(array[rows[i].NUM]);
612-
else
613-
rows[i].CONTENT.toUTCString().should.eql(array[rows[i].NUM].toUTCString());
614-
}
615-
return fetchRowsFromRS(rs);
616-
} else if(rows.length == 0) {
617-
rs.close(function(err) {
618-
should.not.exist(err);
619-
done();
620-
});
621-
} else {
622-
var lengthLessThanZero = true;
623-
should.not.exist(lengthLessThanZero);
624-
done();
625-
}
626-
});
627-
}
628-
}
629-
630-
assist.nullValueSupport = function(connection, tableName, done) {
631-
connection.should.be.ok;
632-
var sqlInsert = "INSERT INTO " + tableName + " VALUES(:no, :bindValue)";
633-
async.series([
634-
function(callback) {
635-
connection.execute(
636-
sqlInsert,
637-
{ no: 998, bindValue: '' },
638-
function(err) {
639-
should.not.exist(err);
640-
callback();
641-
}
642-
);
643-
},
644-
function(callback) {
645-
connection.execute(
646-
sqlInsert,
647-
{ no: 999, bindValue: null },
648-
function(err) {
649-
should.not.exist(err);
650-
callback();
651-
}
652-
);
653-
},
654-
function(callback) {
655-
connection.execute(
656-
"SELECT * FROM " + tableName + " WHERE num > :1 ORDER BY num",
657-
[990],
658-
function(err, result) {
659-
should.not.exist(err);
660-
// console.log(result);
661-
result.rows.should.eql([ [998, null], [999, null] ]);
662-
callback();
663-
}
664-
);
665-
}
666-
], done);
667-
}
668-
669589
/* Null value verfication */
670590
assist.verifyNullValues = function(connection, tableName, done)
671591
{
@@ -739,6 +659,17 @@ assist.verifyNullValues = function(connection, tableName, done)
739659
}
740660
);
741661
},
662+
function sqlNullColumn(callback) {
663+
var num = 6;
664+
connection.execute(
665+
"INSERT INTO " + tableName + "(num) VALUES(:1)",
666+
[num],
667+
function(err) {
668+
should.not.exist(err);
669+
verifyNull(num, callback);
670+
}
671+
);
672+
},
742673
function dropTable(callback) {
743674
connection.execute(
744675
"DROP table " + tableName,

0 commit comments

Comments
 (0)