Skip to content

Commit

Permalink
Test with a branch with a slash in its name
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou authored and mikicz committed Dec 10, 2019
1 parent 15528e3 commit 04ca465
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,27 @@ def create_temp_repo(file) -> TempRepo:
git_dir = Path(tempfile.mkdtemp())
repo = Repo.init(str(git_dir))

return TempRepo(repo, git_dir, f"file://{git_dir}", "master", git_dir / file)
return TempRepo(
repo, git_dir, f"file://{git_dir}", "master", git_dir / file,
)


@pytest.fixture()
def temp_repo_func():
@pytest.fixture(params=["master", "branch/with/slash"])
def temp_repo_func(request):
temp_repo = create_temp_repo("test_file.py")

temp_repo.file_path.write_text(RETURN_STR_FUNCTION)

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

branch_name = request.param
if branch_name != "master":
# Now that there is a commit, create a branch
temp_repo = temp_repo._replace(branch=branch_name)
branch = temp_repo.repo.create_head(branch_name)
temp_repo.repo.head.reference = branch

yield temp_repo

shutil.rmtree(str(temp_repo.repo_path))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_backends(temp_repo_func, backend, requirements_location, file_location)
# test that tags work as well
assert arca.run(temp_repo_func.url, "test_tag", task).output == "Some string"

temp_repo_func.repo.branches.master.checkout()
temp_repo_func.repo.branches[temp_repo_func.branch].checkout()

requirements_path = temp_repo_func.repo_path / backend.requirements_location
requirements_path.parent.mkdir(exist_ok=True, parents=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_current_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_current_environment_backend(temp_repo_func, requirements_location, file
# test that tags work as well
assert arca.run(temp_repo_func.url, "test_tag", task).output == "Some string"

temp_repo_func.repo.branches.master.checkout()
temp_repo_func.repo.branches[temp_repo_func.branch].checkout()

requirements_path = temp_repo_func.repo_path / backend.requirements_location
requirements_path.parent.mkdir(exist_ok=True, parents=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vagrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_vagrant(temp_repo_func, destroy=False):
assert arca.run(temp_repo_func.url, "branch", task).output == TEST_UNICODE

# test timeout
temp_repo_func.repo.branches.master.checkout()
temp_repo_func.repo.branches[temp_repo_func.branch].checkout()
temp_repo_func.file_path.write_text(WAITING_FUNCTION)
temp_repo_func.repo.index.add([str(temp_repo_func.file_path)])
temp_repo_func.repo.index.commit("Waiting function")
Expand Down

0 comments on commit 04ca465

Please sign in to comment.