MCPcopy Index your code
hub / github.com/nodejs/node / testAutoClose

Function testAutoClose

test/parallel/test-fs-promises-file-handle-pullsync.js:188–198  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186// =============================================================================
187
188async function testAutoClose() {
189 const filePath = path.join(tmpDir, 'pullsync-autoclose.txt');
190 fs.writeFileSync(filePath, 'auto close test');
191
192 const fh = await open(filePath, 'r');
193 const data = textSync(fh.pullSync({ autoClose: true }));
194 assert.strictEqual(data, 'auto close test');
195
196 // Handle should be closed
197 await assert.rejects(fh.stat(), { code: 'EBADF' });
198}
199
200// =============================================================================
201// autoClose: true with early break

Calls 5

textSyncFunction · 0.85
openFunction · 0.70
joinMethod · 0.45
writeFileSyncMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected