Skip to content

Commit 6b69b47

Browse files
committed
Improve handing of dates/times in tests
1 parent 94a5605 commit 6b69b47

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

test/dataTypeAssist.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,10 @@ assist.dataTypeSupport = function(connection, tableName, array, done) {
495495
result.rows[i].CONTENT.should.eql(array[result.rows[i].NUM]);
496496
else if( Buffer.isBuffer(result.rows[i].CONTENT) )
497497
result.rows[i].CONTENT.toString('hex').should.eql(array[result.rows[i].NUM].toString('hex'));
498-
else
499-
result.rows[i].CONTENT.toUTCString().should.eql(array[result.rows[i].NUM].toUTCString());
498+
else if (Object.prototype.toString.call(result.rows[i].CONTENT) === '[object Date]')
499+
result.rows[i].CONTENT.getTime().should.eql(array[result.rows[i].NUM].getTime());
500+
else
501+
should.not.exist(new Error('Uncaught data type!'));
500502
}
501503
done();
502504
}
@@ -574,8 +576,10 @@ function fetchRowsFromRS(rs, array, cb)
574576
rows[i].CONTENT.should.eql(array[rows[i].NUM]);
575577
else if( Buffer.isBuffer(rows[i].CONTENT) )
576578
rows[i].CONTENT.toString('hex').should.eql(array[rows[i].NUM].toString('hex'));
577-
else
578-
rows[i].CONTENT.toUTCString().should.eql(array[rows[i].NUM].toUTCString());
579+
else if (Object.prototype.toString.call(rows[i].CONTENT) === '[object Date]')
580+
rows[i].CONTENT.getTime().should.eql(array[rows[i].NUM].getTime());
581+
else
582+
should.not.exist(new Error('Uncaught data type!'));
579583
}
580584
return fetchRowsFromRS(rs, array, cb);
581585
} else {

test/dataTypeDate.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ describe('32. dataTypeDate.js', function() {
8383
})
8484

8585
it('32.1.1 works well with SELECT query', function(done) {
86+
var arrayLength = dates.length;
87+
for (var i = 0; i < arrayLength; i++) {
88+
if (dates[i].getMilliseconds() > 0)
89+
dates[i].setMilliseconds(0);
90+
}
91+
8692
assist.dataTypeSupport(connection, tableName, dates, done);
8793
})
8894

0 commit comments

Comments
 (0)