2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-01-13 21:42:45 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
2010-12-05 22:15:30 +03:00
|
|
|
|
|
|
|
var file = path.join(common.tmpDir, 'write.txt');
|
2010-09-08 13:19:25 +02:00
|
|
|
|
2015-06-09 11:40:55 -07:00
|
|
|
common.refreshTmpDir();
|
|
|
|
|
2010-09-08 13:19:25 +02:00
|
|
|
(function() {
|
2016-01-13 21:42:45 +01:00
|
|
|
const stream = fs.WriteStream(file);
|
|
|
|
const _fs_close = fs.close;
|
2010-12-05 22:15:30 +03:00
|
|
|
|
2010-09-08 13:19:25 +02:00
|
|
|
fs.close = function(fd) {
|
2010-12-05 22:15:30 +03:00
|
|
|
assert.ok(fd, 'fs.close must not be called without an undefined fd.');
|
2010-09-08 13:19:25 +02:00
|
|
|
fs.close = _fs_close;
|
2015-05-19 13:00:06 +02:00
|
|
|
};
|
2010-09-08 13:19:25 +02:00
|
|
|
stream.destroy();
|
|
|
|
})();
|
|
|
|
|
2010-09-08 14:28:31 +02:00
|
|
|
(function() {
|
|
|
|
var stream = fs.createWriteStream(file);
|
2010-12-05 22:15:30 +03:00
|
|
|
|
2011-10-15 01:08:36 +02:00
|
|
|
stream.on('drain', function() {
|
2015-10-14 21:22:55 -07:00
|
|
|
assert.fail(null, null, '\'drain\' event must not be emitted before ' +
|
2010-12-05 22:15:30 +03:00
|
|
|
'stream.write() has been called at least once.');
|
2010-09-08 14:28:31 +02:00
|
|
|
});
|
|
|
|
stream.destroy();
|
|
|
|
})();
|
|
|
|
|