GeezerVison is showing github.com — test: move testPath from CWD to temporary directory · nodejs/node@512f28f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +22-19Lines changed: 22 additions & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 | 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'); | 5 | 7 |
| | 8 | +const testPath = path.join(tmpdir.path, 'assert-encoding-error'); | 6 | 9 | const options = 'test'; | 7 | 10 | const expectedError = { | 8 | 11 | code: 'ERR_INVALID_ARG_VALUE', | 9 | 12 | name: 'TypeError', | 10 | 13 | }; | 11 | 14 |
| 12 | 15 | assert.throws(() => { | 13 | | - fs.readFile('path', options, common.mustNotCall()); | | 16 | + fs.readFile(testPath, options, common.mustNotCall()); | 14 | 17 | }, expectedError); | 15 | 18 |
| 16 | 19 | assert.throws(() => { | 17 | | - fs.readFileSync('path', options); | | 20 | + fs.readFileSync(testPath, options); | 18 | 21 | }, expectedError); | 19 | 22 |
| 20 | 23 | assert.throws(() => { | 21 | | - fs.readdir('path', options, common.mustNotCall()); | | 24 | + fs.readdir(testPath, options, common.mustNotCall()); | 22 | 25 | }, expectedError); | 23 | 26 |
| 24 | 27 | assert.throws(() => { | 25 | | - fs.readdirSync('path', options); | | 28 | + fs.readdirSync(testPath, options); | 26 | 29 | }, expectedError); | 27 | 30 |
| 28 | 31 | assert.throws(() => { | 29 | | - fs.readlink('path', options, common.mustNotCall()); | | 32 | + fs.readlink(testPath, options, common.mustNotCall()); | 30 | 33 | }, expectedError); | 31 | 34 |
| 32 | 35 | assert.throws(() => { | 33 | | - fs.readlinkSync('path', options); | | 36 | + fs.readlinkSync(testPath, options); | 34 | 37 | }, expectedError); | 35 | 38 |
| 36 | 39 | assert.throws(() => { | 37 | | - fs.writeFile('path', 'data', options, common.mustNotCall()); | | 40 | + fs.writeFile(testPath, 'data', options, common.mustNotCall()); | 38 | 41 | }, expectedError); | 39 | 42 |
| 40 | 43 | assert.throws(() => { | 41 | | - fs.writeFileSync('path', 'data', options); | | 44 | + fs.writeFileSync(testPath, 'data', options); | 42 | 45 | }, expectedError); | 43 | 46 |
| 44 | 47 | assert.throws(() => { | 45 | | - fs.appendFile('path', 'data', options, common.mustNotCall()); | | 48 | + fs.appendFile(testPath, 'data', options, common.mustNotCall()); | 46 | 49 | }, expectedError); | 47 | 50 |
| 48 | 51 | assert.throws(() => { | 49 | | - fs.appendFileSync('path', 'data', options); | | 52 | + fs.appendFileSync(testPath, 'data', options); | 50 | 53 | }, expectedError); | 51 | 54 |
| 52 | 55 | assert.throws(() => { | 53 | | - fs.watch('path', options, common.mustNotCall()); | | 56 | + fs.watch(testPath, options, common.mustNotCall()); | 54 | 57 | }, expectedError); | 55 | 58 |
| 56 | 59 | assert.throws(() => { | 57 | | - fs.realpath('path', options, common.mustNotCall()); | | 60 | + fs.realpath(testPath, options, common.mustNotCall()); | 58 | 61 | }, expectedError); | 59 | 62 |
| 60 | 63 | assert.throws(() => { | 61 | | - fs.realpathSync('path', options); | | 64 | + fs.realpathSync(testPath, options); | 62 | 65 | }, expectedError); | 63 | 66 |
| 64 | 67 | assert.throws(() => { | 65 | | - fs.mkdtemp('path', options, common.mustNotCall()); | | 68 | + fs.mkdtemp(testPath, options, common.mustNotCall()); | 66 | 69 | }, expectedError); | 67 | 70 |
| 68 | 71 | assert.throws(() => { | 69 | | - fs.mkdtempSync('path', options); | | 72 | + fs.mkdtempSync(testPath, options); | 70 | 73 | }, expectedError); | 71 | 74 |
| 72 | 75 | assert.throws(() => { | 73 | | - fs.ReadStream('path', options); | | 76 | + fs.ReadStream(testPath, options); | 74 | 77 | }, expectedError); | 75 | 78 |
| 76 | 79 | assert.throws(() => { | 77 | | - fs.WriteStream('path', options); | | 80 | + fs.WriteStream(testPath, options); | 78 | 81 | }, expectedError); |
|