Handle invalid ffprobe JSON during stage1
This commit is contained in:
@@ -161,6 +161,88 @@ def test_scan_command_processes_stage1_results_and_exports_reports(
|
||||
assert csv_path.exists()
|
||||
|
||||
|
||||
def test_scan_command_treats_invalid_probe_json_with_nonzero_exit_as_confirmed_broken(
|
||||
tmp_path: Path, monkeypatch
|
||||
) -> None:
|
||||
root = tmp_path / "videos"
|
||||
root.mkdir()
|
||||
broken = root / "broken.mp4"
|
||||
broken.write_bytes(b"broken")
|
||||
db_path = tmp_path / "scan_state.db"
|
||||
|
||||
def fake_run_ffprobe(path, **kwargs):
|
||||
return ProbeExecutionResult(
|
||||
status="completed",
|
||||
command=("ffprobe", str(path)),
|
||||
exit_code=1,
|
||||
stdout_text='{\n',
|
||||
stderr_text="",
|
||||
elapsed_ms=1,
|
||||
)
|
||||
|
||||
monkeypatch.setattr("tgvideo_check.cli.run_ffprobe", fake_run_ffprobe)
|
||||
|
||||
result = runner.invoke(
|
||||
app,
|
||||
[
|
||||
"scan",
|
||||
str(root),
|
||||
"--db",
|
||||
str(db_path),
|
||||
],
|
||||
)
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "Scanned 1 file(s)" in result.stdout
|
||||
assert "confirmed_broken=1" in result.stdout
|
||||
|
||||
store = ScanStore(db_path)
|
||||
rows = store.list_files(1)
|
||||
assert rows[0].final_status == "confirmed_broken"
|
||||
assert rows[0].reason_code == "ffprobe_exit_nonzero"
|
||||
|
||||
|
||||
def test_scan_command_treats_invalid_probe_json_with_zero_exit_as_command_error(
|
||||
tmp_path: Path, monkeypatch
|
||||
) -> None:
|
||||
root = tmp_path / "videos"
|
||||
root.mkdir()
|
||||
broken = root / "broken.mp4"
|
||||
broken.write_bytes(b"broken")
|
||||
db_path = tmp_path / "scan_state.db"
|
||||
|
||||
def fake_run_ffprobe(path, **kwargs):
|
||||
return ProbeExecutionResult(
|
||||
status="completed",
|
||||
command=("ffprobe", str(path)),
|
||||
exit_code=0,
|
||||
stdout_text='{\n',
|
||||
stderr_text="",
|
||||
elapsed_ms=1,
|
||||
)
|
||||
|
||||
monkeypatch.setattr("tgvideo_check.cli.run_ffprobe", fake_run_ffprobe)
|
||||
|
||||
result = runner.invoke(
|
||||
app,
|
||||
[
|
||||
"scan",
|
||||
str(root),
|
||||
"--db",
|
||||
str(db_path),
|
||||
],
|
||||
)
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "Scanned 1 file(s)" in result.stdout
|
||||
assert "command_error=1" in result.stdout
|
||||
|
||||
store = ScanStore(db_path)
|
||||
rows = store.list_files(1)
|
||||
assert rows[0].final_status == "command_error"
|
||||
assert rows[0].reason_code == "invalid_probe_output"
|
||||
|
||||
|
||||
def test_scan_command_leaves_stage2_pending_by_default(tmp_path, monkeypatch) -> None:
|
||||
root = tmp_path / "videos"
|
||||
root.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user