feat(v2): complete v2 reimplementation
This commit is contained in:
@@ -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])
|
||||
Reference in New Issue
Block a user