Skip to content

Commit

Permalink
fs: add test for cpSync
Browse files Browse the repository at this point in the history
  • Loading branch information
thoqbk committed Oct 1, 2022
1 parent 980e96a commit 4c84e46
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/parallel/test-fs-cp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,24 @@ if (!isWindows) {
}, { code: 'ERR_INVALID_RETURN_VALUE' });
}

// It should not throw exception if child folder
// does not pass filter function
{
// Mimic there's a file in dest with the same name as the child folder in src
// expect: this shouldn't throw error since filtered out by filter function
const src = nextdir();
mkdirSync(join(src, 'foo'), mustNotMutateObjectDeep({ recursive: true }));

const dest = nextdir();
mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true }));
writeFileSync(join(dest, 'foo'), 'foo-content', mustNotMutateObjectDeep({ mode: 0o444 }));

cpSync(src, dest, {
filter: (path) => !path.includes('foo'),
recursive: true,
});
}

// It throws error if errorOnExist is true, force is false, and file or folder
// copied over.
{
Expand Down

0 comments on commit 4c84e46

Please sign in to comment.