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
  • Loading branch information
iansu committed Oct 16, 2020
1 parent 7f25fe8 commit 4ea6e4a
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.mustCall());
}

0 comments on commit 4ea6e4a

Please sign in to comment.