Skip to content

Commit c9e6370

Browse files
committed
some e2e tests [ugly_sync_tests]
1 parent 83939e5 commit c9e6370

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

test_sync.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import tempfile
2+
from pathlib import Path
3+
import shutil
4+
from sync import sync
5+
6+
7+
def test_when_a_file_exists_in_the_source_but_not_the_destination():
8+
try:
9+
source = tempfile.mkdtemp()
10+
dest = tempfile.mkdtemp()
11+
12+
content = "I am a very useful file"
13+
(Path(source) / "my-file").write_text(content)
14+
15+
sync(source, dest)
16+
17+
expected_path = Path(dest) / "my-file"
18+
assert expected_path.exists()
19+
assert expected_path.read_text() == content
20+
21+
finally:
22+
shutil.rmtree(source)
23+
shutil.rmtree(dest)
24+
25+
26+
def test_when_a_file_has_been_renamed_in_the_source():
27+
try:
28+
source = tempfile.mkdtemp()
29+
dest = tempfile.mkdtemp()
30+
31+
content = "I am a file that was renamed"
32+
source_path = Path(source) / "source-filename"
33+
old_dest_path = Path(dest) / "dest-filename"
34+
expected_dest_path = Path(dest) / "source-filename"
35+
source_path.write_text(content)
36+
old_dest_path.write_text(content)
37+
38+
sync(source, dest)
39+
40+
assert old_dest_path.exists() is False
41+
assert expected_dest_path.read_text() == content
42+
43+
finally:
44+
shutil.rmtree(source)
45+
shutil.rmtree(dest)

0 commit comments

Comments
 (0)