This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from src.repository_name import is_valid_format
|
||||
from src.repository_name import get_repository_path, is_valid_format
|
||||
from tests.test_mirror_process import make_repo
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -13,3 +14,27 @@ from src.repository_name import is_valid_format
|
||||
)
|
||||
def test_name_formatting(name_format, expected):
|
||||
assert is_valid_format(name_format) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name_format",
|
||||
[
|
||||
"../{name}",
|
||||
"/tmp/{name}",
|
||||
],
|
||||
)
|
||||
def test_repository_path_rejects_paths_outside_out_dir(tmp_path, name_format):
|
||||
with pytest.raises(ValueError):
|
||||
get_repository_path(
|
||||
out_dir=str(tmp_path),
|
||||
name_format=name_format,
|
||||
repo=make_repo(),
|
||||
)
|
||||
|
||||
|
||||
def test_repository_path_returns_path_inside_out_dir(tmp_path):
|
||||
assert get_repository_path(
|
||||
out_dir=str(tmp_path),
|
||||
name_format="{owner}/{name}",
|
||||
repo=make_repo(),
|
||||
) == str(tmp_path / "alex" / "repo")
|
||||
|
||||
Reference in New Issue
Block a user