fix: handle errors on pkgbuild reading

This commit is contained in:
2026-03-22 13:10:09 +02:00
parent 5e090cebdb
commit cca931ccd0
4 changed files with 26 additions and 4 deletions

View File

@@ -605,3 +605,12 @@ def test_read(sources: Sources, mocker: MockerFixture) -> None:
check_output_mock = mocker.patch("ahriman.core.build_tools.sources.check_output", return_value="content")
assert sources.read(Path("local"), "sha", Path("PKGBUILD")) == "content"
check_output_mock.assert_called_once()
def test_read_failed(sources: Sources, mocker: MockerFixture) -> None:
"""
must return None in case if file cannot be read from commit
"""
mocker.patch("ahriman.core.build_tools.sources.check_output",
side_effect=CalledProcessError(1, ["command"], "error"))
assert sources.read(Path("local"), "sha", Path("PKGBUILD")) is None

View File

@@ -53,3 +53,12 @@ def test_changes_insert_remove_full(database: SQLite, package_ahriman: Package,
assert database.changes_get(package_ahriman.base).changes is None
assert database.changes_get(package_python_schedule.base).changes is None
assert database.changes_get(package_ahriman.base, RepositoryId("i686", database._repository_id.name)) == changes2
def test_changes_insert_pkgbuild_preserve(database: SQLite, package_ahriman: Package) -> None:
"""
must preserve existing pkgbuild when inserting changes without pkgbuild
"""
database.changes_insert(package_ahriman.base, Changes("sha1", "change1", "pkgbuild1"))
database.changes_insert(package_ahriman.base, Changes("sha2", "change2", None))
assert database.changes_get(package_ahriman.base) == Changes("sha2", "change2", "pkgbuild1")