1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-05-08 08:58:31 +01:00

Fix add-on store reset (#5669)

Make sure that add-on store resets do not delete the root folder. This
is important so that successive reset attempts do not fail (the
directory passed to `remove_folder` must exist, otherwise find fails
with an non-zero exit code).

While at it, handle find errors properly and report errors as critical.
This commit is contained in:
Stefan Agner
2025-02-25 17:11:34 +01:00
committed by GitHub
parent 15e8940c7f
commit 42e78408a7
3 changed files with 9 additions and 4 deletions
@@ -1,6 +1,7 @@
"""Test evaluation base."""
# pylint: disable=import-error,protected-access
from os import listdir
from pathlib import Path
from unittest.mock import AsyncMock, patch
@@ -25,16 +26,18 @@ async def test_fixup(coresys: CoreSys, tmp_path):
)
test_repo.mkdir()
(test_repo / ".git").mkdir()
assert test_repo.exists()
mock_repositorie = AsyncMock()
mock_repositorie.git.path = test_repo
coresys.store.repositories["test"] = mock_repositorie
assert len(listdir(test_repo)) > 0
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0**3))):
await store_execute_reset()
assert not test_repo.exists()
assert len(listdir(test_repo)) == 0
assert mock_repositorie.load.called
assert len(coresys.resolution.suggestions) == 0
assert len(coresys.resolution.issues) == 0