1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-07-08 22:33:48 +01:00
Files
supervisor/tests/store/test_validate.py
T
Franck Nijhof 3c9af57d26 Allow slashes in add-on repository branch names (#6957)
Add-on repositories can pin a branch with the "url#branch" syntax. The
branch part of the repository regex only accepted word characters,
hyphens and dots, so a branch with a slash like "feature/hot-new-stuff"
failed to match and the repository was rejected as invalid.

Git branch names commonly use prefixes such as "feature/" or "fix/", so
allow slashes in the captured branch name.
2026-06-19 09:45:00 +02:00

27 lines
828 B
Python

"""Test schema validation."""
import pytest
from voluptuous import Invalid
from supervisor.store.validate import repositories
@pytest.mark.parametrize(
("repo_list", "valid"),
[
(["core", "local"], True),
(["https://github.com/hassio-addons/repository"], True),
(["https://github.com/hassio-addons/repository#beta"], True),
(["https://github.com/hassio-addons/repository#feature/hot-new-stuff"], True),
(["not_a_url"], False),
(["https://fail.com/duplicate", "https://fail.com/duplicate"], False),
],
)
async def test_repository_validate(repo_list: list[str], valid: bool):
"""Test repository list validate."""
if valid:
assert repositories(repo_list) == repo_list
else:
with pytest.raises(Invalid):
repositories(repo_list)