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 2, 2022
1 parent 980e96a commit ec30bf0
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
{
// Create a file in dest with the same name as a 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 ec30bf0

Please sign in to comment.