Skip to content

Commit 04ca465

Browse files
encukoumikicz
authored andcommitted
Test with a branch with a slash in its name
1 parent 15528e3 commit 04ca465

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

tests/conftest.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,27 @@ def create_temp_repo(file) -> TempRepo:
1616
git_dir = Path(tempfile.mkdtemp())
1717
repo = Repo.init(str(git_dir))
1818

19-
return TempRepo(repo, git_dir, f"file://{git_dir}", "master", git_dir / file)
19+
return TempRepo(
20+
repo, git_dir, f"file://{git_dir}", "master", git_dir / file,
21+
)
2022

2123

22-
@pytest.fixture()
23-
def temp_repo_func():
24+
@pytest.fixture(params=["master", "branch/with/slash"])
25+
def temp_repo_func(request):
2426
temp_repo = create_temp_repo("test_file.py")
2527

2628
temp_repo.file_path.write_text(RETURN_STR_FUNCTION)
2729

2830
temp_repo.repo.index.add([str(temp_repo.file_path)])
2931
temp_repo.repo.index.commit("Initial")
3032

33+
branch_name = request.param
34+
if branch_name != "master":
35+
# Now that there is a commit, create a branch
36+
temp_repo = temp_repo._replace(branch=branch_name)
37+
branch = temp_repo.repo.create_head(branch_name)
38+
temp_repo.repo.head.reference = branch
39+
3140
yield temp_repo
3241

3342
shutil.rmtree(str(temp_repo.repo_path))

tests/test_backends.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_backends(temp_repo_func, backend, requirements_location, file_location)
6868
# test that tags work as well
6969
assert arca.run(temp_repo_func.url, "test_tag", task).output == "Some string"
7070

71-
temp_repo_func.repo.branches.master.checkout()
71+
temp_repo_func.repo.branches[temp_repo_func.branch].checkout()
7272

7373
requirements_path = temp_repo_func.repo_path / backend.requirements_location
7474
requirements_path.parent.mkdir(exist_ok=True, parents=True)

tests/test_current_environment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_current_environment_backend(temp_repo_func, requirements_location, file
8585
# test that tags work as well
8686
assert arca.run(temp_repo_func.url, "test_tag", task).output == "Some string"
8787

88-
temp_repo_func.repo.branches.master.checkout()
88+
temp_repo_func.repo.branches[temp_repo_func.branch].checkout()
8989

9090
requirements_path = temp_repo_func.repo_path / backend.requirements_location
9191
requirements_path.parent.mkdir(exist_ok=True, parents=True)

tests/test_vagrant.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_vagrant(temp_repo_func, destroy=False):
106106
assert arca.run(temp_repo_func.url, "branch", task).output == TEST_UNICODE
107107

108108
# test timeout
109-
temp_repo_func.repo.branches.master.checkout()
109+
temp_repo_func.repo.branches[temp_repo_func.branch].checkout()
110110
temp_repo_func.file_path.write_text(WAITING_FUNCTION)
111111
temp_repo_func.repo.index.add([str(temp_repo_func.file_path)])
112112
temp_repo_func.repo.index.commit("Waiting function")

0 commit comments

Comments
 (0)