Skip to content

Commit

Permalink
test: add additional deprecation warning tests for rmdir recursive
Browse files Browse the repository at this point in the history
PR-URL: #35683
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ben Coe <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
iansu authored and targos committed Nov 3, 2020
1 parent 4b7708a commit 0c5e8ed
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
19 changes: 19 additions & 0 deletions test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const fs = require('fs');
const path = require('path');

tmpdir.refresh();

{
// Should warn when trying to delete a nonexistent path
common.expectWarning(
'DeprecationWarning',
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +
'will throw if path does not exist or is a file. Use fs.rm(path, ' +
'{ recursive: true, force: true }) instead',
'DEP0147'
);
fs.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), { recursive: true });
}
21 changes: 21 additions & 0 deletions test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const fs = require('fs');
const path = require('path');

tmpdir.refresh();

{
// Should warn when trying to delete a file
common.expectWarning(
'DeprecationWarning',
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +
'will throw if path does not exist or is a file. Use fs.rm(path, ' +
'{ recursive: true, force: true }) instead',
'DEP0147'
);
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
fs.writeFileSync(filePath, '');
fs.rmdirSync(filePath, { recursive: true });
}
1 change: 0 additions & 1 deletion test/parallel/test-fs-rmdir-recursive-warns-not-found.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const path = require('path');

tmpdir.refresh();


{
// Should warn when trying to delete a nonexistent path
common.expectWarning(
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-rmdir-recursive-warns-on-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ tmpdir.refresh();
);
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
fs.writeFileSync(filePath, '');
fs.rmdirSync(filePath, { recursive: true });
fs.rmdir(filePath, { recursive: true }, common.mustSucceed());
}

0 comments on commit 0c5e8ed

Please sign in to comment.