diff --git a/tests/actions/test_copy.py b/tests/actions/test_copy.py index 6f788573..7ca9fd1c 100644 --- a/tests/actions/test_copy.py +++ b/tests/actions/test_copy.py @@ -136,6 +136,44 @@ def test_copy_conflict(fs, mode, result): Config.from_string(config).execute(simulate=False) assert read_files("test") == result +def test_copy_deduplicate_conflict(fs): + files = { + "src.txt": "src", + "duplicate": { + "src.txt": "src", + }, + "nonduplicate": { + "src.txt": "src2", + }, + } + + config = """ + rules: + - locations: "/test" + subfolders: true + filters: + - name: src + actions: + - copy: + dest: "/test/dst.txt" + on_conflict: deduplicate + """ + make_files(files, "test") + + Config.from_string(config).execute(simulate=False) + result = read_files("test") + + assert result == { + "src.txt": "src", + "duplicate": { + "src.txt": "src", + }, + "nonduplicate": { + "src.txt": "src2", + }, + "dst.txt": "src", + "dst 2.txt": "src2", + } def test_does_not_create_folder_in_simulation(fs): config = """ diff --git a/tests/actions/test_move.py b/tests/actions/test_move.py index fae28a17..691ac77d 100644 --- a/tests/actions/test_move.py +++ b/tests/actions/test_move.py @@ -55,6 +55,41 @@ def test_move_conflict(fs, mode, result): Config.from_string(config).execute(simulate=False) assert read_files("test") == result +def test_move_deduplicate_conflict(fs): + files = { + "src.txt": "src", + "duplicate": { + "src.txt": "src", + }, + "nonduplicate": { + "src.txt": "src2", + }, + } + + config = """ + rules: + - locations: "/test" + subfolders: true + filters: + - name: src + actions: + - move: + dest: "/test/dst.txt" + on_conflict: deduplicate + """ + make_files(files, "test") + + Config.from_string(config).execute(simulate=False) + result = read_files("test") + + assert result == { + "duplicate": { + "src.txt": "src", + }, + "nonduplicate": {}, + "dst.txt": "src", + "dst 2.txt": "src2", + } def test_move_folder_conflict(fs): make_files(