Change fs.utime test to remove constant times, prefering calculated duration. Fixes #103

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2014-03-04 15:30:46 -05:00
parent 503a2d2aca
commit f10b86b644
1 changed files with 4 additions and 5 deletions

View File

@ -158,22 +158,21 @@ define(["Filer", "util"], function(Filer, util) {
var fs = util.fs();
var atimeEst;
var mtimeEst;
var now;
fs.writeFile('/myfile', '', function (error) {
if (error) throw error;
var then = Date.now();
fs.utimes('/myfile', null, null, function (error) {
expect(error).not.to.exist;
now = Date.now();
fs.stat('/myfile', function (error, stat) {
expect(error).not.to.exist;
// Note: testing estimation as time may differ by a couple of milliseconds
// This number should be increased if tests are on slow systems
expect(now - stat.atime).to.be.below(75);
expect(now - stat.mtime).to.be.below(75);
var delta = Date.now() - then;
expect(then - stat.atime).to.be.below(delta);
expect(then - stat.mtime).to.be.below(delta);
done();
});
});