mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: add missing await in fs-rm/fs-rmdir tests
Noticed that a few assertions were not being awaited, this could potentially be leading to flakiness in tmp cleanup. Refs: #41201 PR-URL: https://github.com/nodejs/node/pull/41545 Refs: https://github.com/nodejs/node/issues/41201 Reviewed-By: Ian Sutherland <ian@iansutherland.ca> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
This commit is contained in:
parent
8de858b96d
commit
6b9d2aefdb
@ -185,8 +185,8 @@ function removeAsync(dir) {
|
||||
makeNonEmptyDirectory(4, 10, 2, dir, true);
|
||||
|
||||
// Removal should fail without the recursive option set to true.
|
||||
assert.rejects(fs.promises.rm(dir), { syscall: 'rm' });
|
||||
assert.rejects(fs.promises.rm(dir, { recursive: false }), {
|
||||
await assert.rejects(fs.promises.rm(dir), { syscall: 'rm' });
|
||||
await assert.rejects(fs.promises.rm(dir, { recursive: false }), {
|
||||
syscall: 'rm'
|
||||
});
|
||||
|
||||
@ -194,10 +194,10 @@ function removeAsync(dir) {
|
||||
await fs.promises.rm(dir, { recursive: true });
|
||||
|
||||
// Attempted removal should fail now because the directory is gone.
|
||||
assert.rejects(fs.promises.rm(dir), { syscall: 'stat' });
|
||||
await assert.rejects(fs.promises.rm(dir), { syscall: 'stat' });
|
||||
|
||||
// Should fail if target does not exist
|
||||
assert.rejects(fs.promises.rm(
|
||||
await assert.rejects(fs.promises.rm(
|
||||
path.join(tmpdir.path, 'noexist.txt'),
|
||||
{ recursive: true }
|
||||
), {
|
||||
@ -207,7 +207,7 @@ function removeAsync(dir) {
|
||||
});
|
||||
|
||||
// Should not fail if target does not exist and force option is true
|
||||
fs.promises.rm(path.join(tmpdir.path, 'noexist.txt'), { force: true });
|
||||
await fs.promises.rm(path.join(tmpdir.path, 'noexist.txt'), { force: true });
|
||||
|
||||
// Should delete file
|
||||
const filePath = path.join(tmpdir.path, 'rm-promises-file.txt');
|
||||
|
@ -141,8 +141,8 @@ function removeAsync(dir) {
|
||||
makeNonEmptyDirectory(4, 10, 2, dir, true);
|
||||
|
||||
// Removal should fail without the recursive option set to true.
|
||||
assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
|
||||
assert.rejects(fs.promises.rmdir(dir, { recursive: false }), {
|
||||
await assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
|
||||
await assert.rejects(fs.promises.rmdir(dir, { recursive: false }), {
|
||||
syscall: 'rmdir'
|
||||
});
|
||||
|
||||
@ -154,7 +154,7 @@ function removeAsync(dir) {
|
||||
{ code: 'ENOENT' });
|
||||
|
||||
// Attempted removal should fail now because the directory is gone.
|
||||
assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
|
||||
await assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
|
||||
})().then(common.mustCall());
|
||||
|
||||
// Test input validation.
|
||||
|
Loading…
Reference in New Issue
Block a user