GeezerVison is showing github.com — test: use common.PIPE in fs.cp socket tests · nodejs/node@ae9c25a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-fs-cp-async-socket.mjs +3-7Lines changed: 3 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
2 | 2 |
|
3 | 3 | import * as common from '../common/index.mjs'; |
4 | 4 | import assert from 'node:assert'; |
5 | | -import { cp, mkdirSync } from 'node:fs'; |
| 5 | +import { cp } from 'node:fs'; |
6 | 6 | import { createServer } from 'node:net'; |
7 | | -import { join } from 'node:path'; |
8 | 7 | import { nextdir } from '../common/fs.js'; |
9 | 8 | import tmpdir from '../common/tmpdir.js'; |
10 | 9 |
|
@@ -21,13 +20,10 @@ if (common.isInsideDirWithUnusualChars) { |
21 | 20 | tmpdir.refresh(); |
22 | 21 |
|
23 | 22 | { |
24 | | - const src = nextdir(); |
25 | | - mkdirSync(src); |
26 | 23 | const dest = nextdir(); |
27 | | - const sock = join(src, `${process.pid}.sock`); |
28 | 24 | const server = createServer(); |
29 | | - server.listen(sock); |
30 | | - cp(sock, dest, common.mustCall((err) => { |
| 25 | + server.listen(common.PIPE); |
| 26 | + cp(common.PIPE, dest, common.mustCall((err) => { |
31 | 27 | assert.strictEqual(err.code, 'ERR_FS_CP_SOCKET'); |
32 | 28 | server.close(); |
33 | 29 | })); |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-fs-cp-sync-copy-socket-error.mjs +3-7Lines changed: 3 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
2 | 2 | import * as common from '../common/index.mjs'; |
3 | 3 | import { nextdir } from '../common/fs.js'; |
4 | 4 | import assert from 'node:assert'; |
5 | | -import { cpSync, mkdirSync } from 'node:fs'; |
| 5 | +import { cpSync } from 'node:fs'; |
6 | 6 | import { createServer } from 'node:net'; |
7 | | -import { join } from 'node:path'; |
8 | 7 | import tmpdir from '../common/tmpdir.js'; |
9 | 8 |
|
10 | 9 | const isWindows = process.platform === 'win32'; |
@@ -20,14 +19,11 @@ if (common.isInsideDirWithUnusualChars) { |
20 | 19 | tmpdir.refresh(); |
21 | 20 |
|
22 | 21 | { |
23 | | - const src = nextdir(); |
24 | | - mkdirSync(src); |
25 | 22 | const dest = nextdir(); |
26 | | - const sock = join(src, `${process.pid}.sock`); |
27 | 23 | const server = createServer(); |
28 | | - server.listen(sock); |
| 24 | + server.listen(common.PIPE); |
29 | 25 | assert.throws( |
30 | | - () => cpSync(sock, dest), |
| 26 | + () => cpSync(common.PIPE, dest), |
31 | 27 | { code: 'ERR_FS_CP_SOCKET' } |
32 | 28 | ); |
33 | 29 | server.close(); |
|