Skip to content

Commit aa3e4f1

Browse files
committed
fs: add test for cpSync
1 parent 980e96a commit aa3e4f1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/parallel/test-fs-cp.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,24 @@ if (!isWindows) {
336336
}, { code: 'ERR_INVALID_RETURN_VALUE' });
337337
}
338338

339+
// It should not throw exception if child folder
340+
// does not pass filter function
341+
{
342+
// Mimic there's a file in dest with the same name as the child folder in src
343+
// expect: this shouldn't throw error since filtered out by filter function
344+
const src = nextdir();
345+
mkdirSync(join(src, 'foo'), mustNotMutateObjectDeep({ recursive: true }));
346+
347+
const dest = nextdir();
348+
mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true }));
349+
writeFileSync(join(dest, 'foo'), 'foo-content', mustNotMutateObjectDeep({ mode: 0o444 }));
350+
351+
cpSync(src, dest, {
352+
filter: (path) => !path.includes('foo'),
353+
recursive: true,
354+
});
355+
}
356+
339357
// It throws error if errorOnExist is true, force is false, and file or folder
340358
// copied over.
341359
{

0 commit comments

Comments
 (0)