node/test/simple/test-file-read-noexist.js

21 lines
512 B
JavaScript
Raw Normal View History

require("../common");
var path = require('path');
var fs = require('fs');
2009-06-29 01:05:58 +08:00
var got_error = false;
2009-06-01 18:56:28 +08:00
var filename = path.join(fixturesDir, "does_not_exist.txt");
2010-02-20 08:02:30 +08:00
fs.readFile(filename, "raw", function (err, content) {
if (err) {
got_error = true;
} else {
debug("cat returned some content: " + content);
debug("this shouldn't happen as the file doesn't exist...");
assert.equal(true, false);
}
2009-08-27 00:22:00 +08:00
});
2009-06-01 18:56:28 +08:00
process.addListener("exit", function () {
puts("done");
assert.equal(true, got_error);
});