(op)
| 28 | } |
| 29 | |
| 30 | async function checkOperationError(op) { |
| 31 | try { |
| 32 | const filePath = await createFile(); |
| 33 | Object.defineProperty(FileHandle.prototype, 'fd', { |
| 34 | get: common.mustCall(function() { |
| 35 | // Verify that close is called when an error is thrown |
| 36 | this.close = common.mustCall(this.close); |
| 37 | const opError = new Error('INTERNAL_ERROR'); |
| 38 | opError.code = 123; |
| 39 | throw opError; |
| 40 | }), |
| 41 | }); |
| 42 | |
| 43 | await assert.rejects(op(filePath), { |
| 44 | name: 'Error', |
| 45 | message: 'INTERNAL_ERROR', |
| 46 | code: 123, |
| 47 | }); |
| 48 | } finally { |
| 49 | Object.defineProperty(FileHandle.prototype, 'fd', originalFd); |
| 50 | } |
| 51 | } |
| 52 | (async function() { |
| 53 | tmpdir.refresh(); |
| 54 | await checkOperationError((filePath) => truncate(filePath)); |
no test coverage detected