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

Function testLockedState

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

Source from the content-addressed store, hash-verified

172// =============================================================================
173
174async function testLockedState() {
175 const filePath = path.join(tmpDir, 'writer-locked.txt');
176 const fh = await open(filePath, 'w');
177 const w = fh.writer();
178
179 assert.throws(() => fh.writer(), {
180 name: 'Error',
181 message: /locked/,
182 });
183
184 // Also can't pull while writer is active
185 assert.throws(() => fh.pull(), {
186 name: 'Error',
187 message: /locked/,
188 });
189
190 await w.end();
191 await fh.close();
192}
193
194// =============================================================================
195// Unlock after end - handle reusable

Calls 6

writerMethod · 0.80
openFunction · 0.70
closeMethod · 0.65
joinMethod · 0.45
pullMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected