From e5b88961862c94ab211d43a3feb01c9657fe943c Mon Sep 17 00:00:00 2001 From: Livia Medeiros Date: Fri, 3 Mar 2023 16:55:58 +0900 Subject: [PATCH] test: move testPath from CWD to temporary directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/46890 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- .../parallel/test-fs-assert-encoding-error.js | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/test/parallel/test-fs-assert-encoding-error.js b/test/parallel/test-fs-assert-encoding-error.js index f5e1d0f07e71ee..7f32c06ea89419 100644 --- a/test/parallel/test-fs-assert-encoding-error.js +++ b/test/parallel/test-fs-assert-encoding-error.js @@ -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);