Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e5b8896

Browse filesBrowse files
LiviaMedeirostargos
authored andcommitted
test: move testPath from CWD to temporary directory
PR-URL: #46890 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent f4a59b7 commit e5b8896
Copy full SHA for e5b8896

File tree

Expand file treeCollapse file tree

1 file changed

+22
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-19
lines changed
Open diff view settings
Collapse file
+22-19Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,81 @@
11
'use strict';
22
const common = require('../common');
3-
const assert = require('assert');
4-
const fs = require('fs');
3+
const assert = require('node:assert');
4+
const fs = require('node:fs');
5+
const path = require('node:path');
6+
const tmpdir = require('../common/tmpdir');
57

8+
const testPath = path.join(tmpdir.path, 'assert-encoding-error');
69
const options = 'test';
710
const expectedError = {
811
code: 'ERR_INVALID_ARG_VALUE',
912
name: 'TypeError',
1013
};
1114

1215
assert.throws(() => {
13-
fs.readFile('path', options, common.mustNotCall());
16+
fs.readFile(testPath, options, common.mustNotCall());
1417
}, expectedError);
1518

1619
assert.throws(() => {
17-
fs.readFileSync('path', options);
20+
fs.readFileSync(testPath, options);
1821
}, expectedError);
1922

2023
assert.throws(() => {
21-
fs.readdir('path', options, common.mustNotCall());
24+
fs.readdir(testPath, options, common.mustNotCall());
2225
}, expectedError);
2326

2427
assert.throws(() => {
25-
fs.readdirSync('path', options);
28+
fs.readdirSync(testPath, options);
2629
}, expectedError);
2730

2831
assert.throws(() => {
29-
fs.readlink('path', options, common.mustNotCall());
32+
fs.readlink(testPath, options, common.mustNotCall());
3033
}, expectedError);
3134

3235
assert.throws(() => {
33-
fs.readlinkSync('path', options);
36+
fs.readlinkSync(testPath, options);
3437
}, expectedError);
3538

3639
assert.throws(() => {
37-
fs.writeFile('path', 'data', options, common.mustNotCall());
40+
fs.writeFile(testPath, 'data', options, common.mustNotCall());
3841
}, expectedError);
3942

4043
assert.throws(() => {
41-
fs.writeFileSync('path', 'data', options);
44+
fs.writeFileSync(testPath, 'data', options);
4245
}, expectedError);
4346

4447
assert.throws(() => {
45-
fs.appendFile('path', 'data', options, common.mustNotCall());
48+
fs.appendFile(testPath, 'data', options, common.mustNotCall());
4649
}, expectedError);
4750

4851
assert.throws(() => {
49-
fs.appendFileSync('path', 'data', options);
52+
fs.appendFileSync(testPath, 'data', options);
5053
}, expectedError);
5154

5255
assert.throws(() => {
53-
fs.watch('path', options, common.mustNotCall());
56+
fs.watch(testPath, options, common.mustNotCall());
5457
}, expectedError);
5558

5659
assert.throws(() => {
57-
fs.realpath('path', options, common.mustNotCall());
60+
fs.realpath(testPath, options, common.mustNotCall());
5861
}, expectedError);
5962

6063
assert.throws(() => {
61-
fs.realpathSync('path', options);
64+
fs.realpathSync(testPath, options);
6265
}, expectedError);
6366

6467
assert.throws(() => {
65-
fs.mkdtemp('path', options, common.mustNotCall());
68+
fs.mkdtemp(testPath, options, common.mustNotCall());
6669
}, expectedError);
6770

6871
assert.throws(() => {
69-
fs.mkdtempSync('path', options);
72+
fs.mkdtempSync(testPath, options);
7073
}, expectedError);
7174

7275
assert.throws(() => {
73-
fs.ReadStream('path', options);
76+
fs.ReadStream(testPath, options);
7477
}, expectedError);
7578

7679
assert.throws(() => {
77-
fs.WriteStream('path', options);
80+
fs.WriteStream(testPath, options);
7881
}, expectedError);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.