Skip to content

Commit bfc177d

Browse files
committed
feat: add repository provider as a part of the testing fixture options and add some basic tests to ensure files are removed properly in the post gen hook
1 parent 5d756a8 commit bfc177d

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

tests/conftest.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
from pathlib import Path
55
from typing import Any
6+
from typing import Literal
67

78
import pytest
89
import toml
@@ -84,10 +85,15 @@ def robust_demo__name(robust_demo__add_rust_extension: str, robust_demo__is_setu
8485

8586

8687
@pytest.fixture(scope="session")
87-
def robust_demo__extra_context(robust_demo__name: str, robust_demo__add_rust_extension: bool) -> dict[str, Any]:
88+
def robust_demo__extra_context(
89+
robust_demo__name: str,
90+
robust_demo__add_rust_extension: bool,
91+
robust_demo__repository_provider: Literal["github", "gitlab", "bitbucket"]
92+
) -> dict[str, Any]:
8893
return {
8994
"project_name": robust_demo__name,
90-
"add_rust_extension": robust_demo__add_rust_extension
95+
"add_rust_extension": robust_demo__add_rust_extension,
96+
"repository_provider": robust_demo__repository_provider,
9197
}
9298

9399

@@ -96,6 +102,11 @@ def robust_demo__add_rust_extension(request: FixtureRequest) -> bool:
96102
return getattr(request, "param", False)
97103

98104

105+
@pytest.fixture(scope="session")
106+
def robust_demo__repository_provider(request: FixtureRequest) -> Literal["github", "gitlab", "bitbucket"]:
107+
return getattr(request, "param", "github")
108+
109+
99110
@pytest.fixture(scope="session")
100111
def robust_demo__is_setup(request: FixtureRequest) -> bool:
101112
return getattr(request, "param", True)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
6+
@pytest.mark.parametrize(
7+
argnames="removed_relative_path",
8+
argvalues=[".gitlab-ci.yml", "bitbucket-pipelines.yml"]
9+
)
10+
@pytest.mark.parametrize(
11+
argnames="robust_demo__repository_provider",
12+
argvalues=["github"],
13+
indirect=True
14+
)
15+
def test_files_removed_for_github(robust_demo: Path, removed_relative_path: str) -> None:
16+
path: Path = robust_demo / removed_relative_path
17+
assert not path.exists()
18+
19+
20+
@pytest.mark.parametrize(
21+
argnames="removed_relative_path",
22+
argvalues=[".github", "bitbucket-pipelines.yml"]
23+
)
24+
@pytest.mark.parametrize(
25+
argnames="robust_demo__repository_provider",
26+
argvalues=["gitlab"],
27+
indirect=True
28+
)
29+
def test_files_removed_for_gitlab(robust_demo: Path, removed_relative_path: str) -> None:
30+
path: Path = robust_demo / removed_relative_path
31+
assert not path.exists()
32+
33+
34+
@pytest.mark.parametrize(
35+
argnames="removed_relative_path",
36+
argvalues=[".github", ".gitlab-ci.yml"]
37+
)
38+
@pytest.mark.parametrize(
39+
argnames="robust_demo__repository_provider",
40+
argvalues=["bitbucket"],
41+
indirect=True
42+
)
43+
def test_files_removed_for_bitbucket(robust_demo: Path, removed_relative_path: str) -> None:
44+
path: Path = robust_demo / removed_relative_path
45+
assert not path.exists()
46+
47+
48+
@pytest.mark.parametrize(
49+
argnames="removed_relative_path",
50+
argvalues=[
51+
"rust",
52+
".github/workflows/lint-rust.yml",
53+
".github/workflows/build-rust.yml",
54+
".github/workflows/test-rust.yml"
55+
]
56+
)
57+
@pytest.mark.parametrize(
58+
argnames="robust_demo__add_rust_extension",
59+
argvalues=[False],
60+
indirect=True,
61+
ids=["no-rust"]
62+
)
63+
@pytest.mark.parametrize(
64+
argnames="robust_demo__repository_provider",
65+
argvalues=["github"],
66+
indirect=True,
67+
)
68+
def test_files_removed_for_no_rust_extension(robust_demo: Path, removed_relative_path: str) -> None:
69+
path: Path = robust_demo / removed_relative_path
70+
assert not path.exists()

0 commit comments

Comments
 (0)