()
| 217 | // ============================================================================= |
| 218 | |
| 219 | async function testUnlockAfterFail() { |
| 220 | const filePath = path.join(tmpDir, 'writer-unlock-fail.txt'); |
| 221 | const fh = await open(filePath, 'w'); |
| 222 | |
| 223 | const w1 = fh.writer(); |
| 224 | await w1.write(Buffer.from('failed')); |
| 225 | await w1.fail(new Error('test')); |
| 226 | |
| 227 | // Should work - handle is unlocked |
| 228 | const w2 = fh.writer(); |
| 229 | await w2.write(Buffer.from('recovered')); |
| 230 | await w2.end(); |
| 231 | await fh.close(); |
| 232 | |
| 233 | // 'recovered' is appended after 'failed' at current file offset |
| 234 | const content = fs.readFileSync(filePath, 'utf8'); |
| 235 | assert.ok(content.startsWith('failed')); |
| 236 | assert.ok(content.includes('recovered')); |
| 237 | } |
| 238 | |
| 239 | // ============================================================================= |
| 240 | // Write after end/fail rejects |
no test coverage detected