Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(copr): do not error out for already created repo #1527

Merged
merged 2 commits into from Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packit/copr_helper.py
Expand Up @@ -282,6 +282,13 @@ def create_copr_project(
)
# TODO: additional_packages
except CoprException as ex:
# TODO: Remove once Copr doesn't throw for existing projects or new
# API endpoint is established.
if "You already have a project named" in ex.result.error:
# race condition between workers
logger.debug(f"Copr project ({owner}/{project}) is already present.")
return

error = (
f"Cannot create a new Copr project "
f"(owner={owner} project={project} chroots={chroots}): {ex}"
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/test_copr_build.py
Expand Up @@ -633,3 +633,23 @@ def test_copr_build_cli_project_set_from_config(upstream_and_remote, copr_client
).and_return(("id", "url")).once()

run_packit(["copr-build", "--nowait"], working_dir=upstream)


def test_create_copr_project(copr_client_mock):
copr_helper = CoprHelper(flexmock(git_url="https://gitlab.com/"))
flexmock(packit.copr_helper.CoprClient).should_receive(
"create_from_config_file"
).and_return(copr_client_mock)

copr_client_mock.project_proxy = flexmock()
flexmock(copr_client_mock.project_proxy).should_receive("add").and_raise(
CoprRequestException, "You already have a project named 'already-present'."
)

copr_helper.create_copr_project(
chroots=["centos-stream-8-x86_64"],
description="my fabulous test",
instructions=None,
owner="me",
project="already-present",
)