MCPcopy Create free account
hub / github.com/nodejs/node / testAutoCloseOnEnd

Function testAutoCloseOnEnd

test/parallel/test-fs-promises-file-handle-writer.js:104–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102// =============================================================================
103
104async function testAutoCloseOnEnd() {
105 const filePath = path.join(tmpDir, 'writer-autoclose-end.txt');
106 const fh = await open(filePath, 'w');
107 const w = fh.writer({ autoClose: true });
108 await w.write(Buffer.from('auto close test'));
109 await w.end();
110
111 // Handle should be closed
112 await assert.rejects(fh.stat(), { code: 'EBADF' });
113 assert.strictEqual(fs.readFileSync(filePath, 'utf8'), 'auto close test');
114}
115
116// =============================================================================
117// autoClose: true - handle closed after fail()

Calls 8

writerMethod · 0.80
openFunction · 0.70
joinMethod · 0.45
writeMethod · 0.45
fromMethod · 0.45
endMethod · 0.45
statMethod · 0.45
readFileSyncMethod · 0.45

Tested by

no test coverage detected