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

Function testUnlockAfterEnd

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

Source from the content-addressed store, hash-verified

196// =============================================================================
197
198async function testUnlockAfterEnd() {
199 const filePath = path.join(tmpDir, 'writer-unlock.txt');
200 const fh = await open(filePath, 'w');
201
202 const w1 = fh.writer();
203 await w1.write(Buffer.from('first'));
204 await w1.end();
205
206 // Should work - handle is unlocked
207 const w2 = fh.writer();
208 await w2.write(Buffer.from(' second'));
209 await w2.end();
210 await fh.close();
211
212 assert.strictEqual(fs.readFileSync(filePath, 'utf8'), 'first second');
213}
214
215// =============================================================================
216// Unlock after fail - handle reusable

Calls 8

writerMethod · 0.80
openFunction · 0.70
closeMethod · 0.65
joinMethod · 0.45
writeMethod · 0.45
fromMethod · 0.45
endMethod · 0.45
readFileSyncMethod · 0.45

Tested by

no test coverage detected