()
| 238 | // ============================================================================= |
| 239 | |
| 240 | async function testLocked() { |
| 241 | const filePath = path.join(tmpDir, 'pullsync-locked.txt'); |
| 242 | fs.writeFileSync(filePath, 'lock test'); |
| 243 | |
| 244 | const fh = await open(filePath, 'r'); |
| 245 | const iter = fh.pullSync()[Symbol.iterator](); |
| 246 | iter.next(); // Start iteration, handle is locked |
| 247 | |
| 248 | assert.throws(() => fh.pullSync(), { |
| 249 | code: 'ERR_INVALID_STATE', |
| 250 | }); |
| 251 | |
| 252 | assert.throws(() => fh.pull(), { |
| 253 | code: 'ERR_INVALID_STATE', |
| 254 | }); |
| 255 | |
| 256 | // Finish iteration to unlock |
| 257 | while (!iter.next().done) { /* drain */ } |
| 258 | await fh.close(); |
| 259 | } |
| 260 | |
| 261 | // ============================================================================= |
| 262 | // Empty file |
no test coverage detected