mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: move testPath from CWD to temporary directory
PR-URL: https://github.com/nodejs/node/pull/46890 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
1 parent
886504fdf8
commit
512f28fa8b
1 file changed
+22
-19
@@ -1,8 +1,11 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const assert = require('node:assert');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const testPath = path.join(tmpdir.path, 'assert-encoding-error');
|
||||
const options = 'test';
|
||||
const expectedError = {
|
||||
code: 'ERR_INVALID_ARG_VALUE',
|
||||
@@ -10,69 +13,69 @@ const expectedError = {
|
||||
};
|
||||
|
||||
assert.throws(() => {
|
||||
fs.readFile('path', options, common.mustNotCall());
|
||||
fs.readFile(testPath, options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.readFileSync('path', options);
|
||||
fs.readFileSync(testPath, options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.readdir('path', options, common.mustNotCall());
|
||||
fs.readdir(testPath, options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.readdirSync('path', options);
|
||||
fs.readdirSync(testPath, options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.readlink('path', options, common.mustNotCall());
|
||||
fs.readlink(testPath, options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.readlinkSync('path', options);
|
||||
fs.readlinkSync(testPath, options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.writeFile('path', 'data', options, common.mustNotCall());
|
||||
fs.writeFile(testPath, 'data', options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.writeFileSync('path', 'data', options);
|
||||
fs.writeFileSync(testPath, 'data', options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.appendFile('path', 'data', options, common.mustNotCall());
|
||||
fs.appendFile(testPath, 'data', options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.appendFileSync('path', 'data', options);
|
||||
fs.appendFileSync(testPath, 'data', options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.watch('path', options, common.mustNotCall());
|
||||
fs.watch(testPath, options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.realpath('path', options, common.mustNotCall());
|
||||
fs.realpath(testPath, options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.realpathSync('path', options);
|
||||
fs.realpathSync(testPath, options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.mkdtemp('path', options, common.mustNotCall());
|
||||
fs.mkdtemp(testPath, options, common.mustNotCall());
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.mkdtempSync('path', options);
|
||||
fs.mkdtempSync(testPath, options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.ReadStream('path', options);
|
||||
fs.ReadStream(testPath, options);
|
||||
}, expectedError);
|
||||
|
||||
assert.throws(() => {
|
||||
fs.WriteStream('path', options);
|
||||
fs.WriteStream(testPath, options);
|
||||
}, expectedError);
|
||||
Reference in new issue
Block a user