| 172 | // ============================================================================= |
| 173 | |
| 174 | async 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 |