| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 11ac9c6 commit 695e982
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,3 +95,13 @@ fs.open(filename4, 'w+', common.mustSucceed((fd) => { | |||
| 95 | 95 | ||
| 96 | 96 | process.nextTick(() => controller.abort()); | |
| 97 | 97 | } | |
| 98 | + | ||
| 99 | + { | ||
| 100 | + // Test read-only mode | ||
| 101 | + const filename = join(tmpdir.path, 'test6.txt'); | ||
| 102 | + fs.writeFileSync(filename, ''); | ||
| 103 | + | ||
| 104 | + // TODO: Correct the error type | ||
| 105 | + const expectedError = common.isWindows ? /EPERM/ : /EBADF/; | ||
| 106 | + fs.writeFile(filename, s, { flag: 'r' }, common.expectsError(expectedError)); | ||
| 107 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,3 +55,31 @@ tmpdir.refresh(); | |||
| 55 | 55 | })); | |
| 56 | 56 | })); | |
| 57 | 57 | } | |
| 58 | + | ||
| 59 | + | ||
| 60 | + // Test read-only file descriptor | ||
| 61 | + { | ||
| 62 | + // TODO(pd4d10): https://github.com/nodejs/node/issues/38607 | ||
| 63 | + const expectedError = common.isWindows ? /EPERM/ : /EBADF/; | ||
| 64 | + | ||
| 65 | + const file = join(tmpdir.path, 'test.txt'); | ||
| 66 | + | ||
| 67 | + fs.open(file, 'r', common.mustSucceed((fd) => { | ||
| 68 | + fs.writeFile(fd, 'World', common.expectsError(expectedError)); | ||
| 69 | + })); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + // Test with an AbortSignal | ||
| 73 | + { | ||
| 74 | + const controller = new AbortController(); | ||
| 75 | + const signal = controller.signal; | ||
| 76 | + const file = join(tmpdir.path, 'test.txt'); | ||
| 77 | + | ||
| 78 | + fs.open(file, 'w', common.mustSucceed((fd) => { | ||
| 79 | + fs.writeFile(fd, 'World', { signal }, common.expectsError({ | ||
| 80 | + name: 'AbortError' | ||
| 81 | + })); | ||
| 82 | + })); | ||
| 83 | + | ||
| 84 | + controller.abort(); | ||
| 85 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments