mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: add check to test-fs-readfile-tostring-fail
Check that all of the bytes were written to the temporary file before reading it to catch the case where there is insufficient disk space. PR-URL: https://github.com/nodejs/node/pull/43850 Refs: https://github.com/nodejs/node/issues/43833 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
6d07f4ca83
commit
604ac4bc6c
@ -25,13 +25,17 @@ stream.on('error', (err) => { throw err; });
|
||||
|
||||
const size = kStringMaxLength / 200;
|
||||
const a = Buffer.alloc(size, 'a');
|
||||
let expectedSize = 0;
|
||||
|
||||
for (let i = 0; i < 201; i++) {
|
||||
stream.write(a);
|
||||
stream.write(a, (err) => { assert.ifError(err); });
|
||||
expectedSize += a.length;
|
||||
}
|
||||
|
||||
stream.end();
|
||||
stream.on('finish', common.mustCall(function() {
|
||||
assert.strictEqual(stream.bytesWritten, expectedSize,
|
||||
`${stream.bytesWritten} bytes written (expected ${expectedSize} bytes).`);
|
||||
fs.readFile(file, 'utf8', common.mustCall(function(err, buf) {
|
||||
assert.ok(err instanceof Error);
|
||||
if (err.message !== 'Array buffer allocation failed') {
|
||||
|
Loading…
Reference in New Issue
Block a user