Skip to content

Commit

Permalink
Improved rename tests message and file names
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Jan 18, 2025
1 parent 5f53d2f commit 3d68f9d
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions tests/fs/rename.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,21 @@ suite('Rename', () => {
});

test('File to Directory and Directory to File Rename', async () => {
const dir = '/rename_filedir_test';
const file = '/rename_filedir_test.txt';
const dir = '/rename_file_dir_test';
const file = '/rename_file_dir_test.txt';

await fs.promises.mkdir(dir);
await fs.promises.writeFile(file, 'file contents go here');

await fs.promises.rename(file, dir).catch((error: ErrnoError) => {
assert(error instanceof ErrnoError);
assert(error.code === 'EISDIR' || error.code === 'EPERM');
assert.match(error.code, /EISDIR|EPERM/);
});

// JV: Removing test for now. I noticed that you can do that in Node v0.12 on Mac,
// but it might be FS independent.
/*fs.rename(dir, file, function (e) {
if (e == null) {
throw new Error("Failed invariant: Cannot rename a directory over a file.");
} else {
assert.strictEqual(e.code, 'ENOTDIR');
}
});*/
});

test('rename directory inside itself', async () => {
const renDir1 = '/renamedir_1';
const renDir2 = '/renamedir_1/lol';
const renDir1 = '/rename_dir_1';
const renDir2 = '/rename_dir_1/lol';

await fs.promises.mkdir(renDir1);

Expand Down

0 comments on commit 3d68f9d

Please sign in to comment.