Add broken symlink diagnostics
This commit is contained in:
+34
-1
@@ -1,4 +1,6 @@
|
||||
from serato_doctor.scanner import scan_audio
|
||||
from pathlib import Path
|
||||
|
||||
from serato_doctor.scanner import scan_audio, scan_filesystem
|
||||
|
||||
|
||||
def test_scan_audio_finds_supported_files(tmp_path):
|
||||
@@ -15,3 +17,34 @@ def test_scan_audio_finds_supported_files(tmp_path):
|
||||
first = next(track for track in tracks if track.filename == "First.MP3")
|
||||
assert first.suffix == ".mp3"
|
||||
assert first.size == len(b"synthetic audio")
|
||||
|
||||
|
||||
def test_scan_filesystem_reports_broken_symlink(tmp_path):
|
||||
music = tmp_path / "music"
|
||||
music.mkdir()
|
||||
link = music / "Missing.mp3"
|
||||
link.symlink_to("not-there.mp3")
|
||||
|
||||
result = scan_filesystem(music)
|
||||
|
||||
assert result.tracks == ()
|
||||
assert len(result.broken_symlinks) == 1
|
||||
assert result.broken_symlinks[0].path == link
|
||||
assert result.broken_symlinks[0].target == Path("not-there.mp3")
|
||||
|
||||
|
||||
def test_valid_audio_symlink_is_scanned_normally(tmp_path):
|
||||
music = tmp_path / "music"
|
||||
music.mkdir()
|
||||
target = music / "Target.mp3"
|
||||
target.write_bytes(b"synthetic audio")
|
||||
link = music / "Linked.mp3"
|
||||
link.symlink_to(target)
|
||||
|
||||
result = scan_filesystem(music)
|
||||
|
||||
assert {track.filename for track in result.tracks} == {
|
||||
"Linked.mp3",
|
||||
"Target.mp3",
|
||||
}
|
||||
assert result.broken_symlinks == ()
|
||||
|
||||
Reference in New Issue
Block a user