feat(v2): complete v2 reimplementation

This commit is contained in:
2026-07-31 13:33:39 +02:00
parent 396219e776
commit bd107d6a30
137 changed files with 20737 additions and 155 deletions
+25
View File
@@ -0,0 +1,25 @@
from __future__ import annotations
import pytest
from backup_tool.exclusions import ExclusionError, matches
@pytest.mark.parametrize(
("path", "patterns", "expected"),
[
("notes.tmp", ["*.tmp"], True),
("nested/notes.tmp", ["*.tmp"], True),
("cache/item.txt", ["cache/"], True),
("cache/keep.txt", ["cache/", "!cache/keep.txt"], False),
("data/keep.txt", ["data/**"], True),
("data.txt", ["data/**"], False),
],
)
def test_gitignore_like_exclusions(path: str, patterns: list[str], expected: bool) -> None:
assert matches(path, patterns) is expected
@pytest.mark.parametrize("value", ["../escape", "/absolute", "windows\\path", ""])
def test_exclusions_reject_unsafe_paths(value: str) -> None:
with pytest.raises(ExclusionError):
matches("safe.txt", [value])