Skip to content

Commit

Permalink
test: move testPath from CWD to temporary directory
Browse files Browse the repository at this point in the history
PR-URL: #46890
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
LiviaMedeiros authored and danielleadams committed Apr 11, 2023
1 parent 886504f commit 512f28f
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions test/parallel/test-fs-assert-encoding-error.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,81 @@
'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',
name: 'TypeError',
};

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);

0 comments on commit 512f28f

Please sign in to comment.