mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-13 22:59:54 +08:00
Make record_module_build_arches idempotent
This function could get called multiple times if the init handler runs more than once. This can happen if the build failed in the init handler due to external infrastructure being down and the user resumes their build.
This commit is contained in:
@@ -104,7 +104,8 @@ def record_module_build_arches(mmd, build):
|
||||
arch_obj = db_session.query(models.ModuleArch).filter_by(name=arch).first()
|
||||
if not arch_obj:
|
||||
arch_obj = models.ModuleArch(name=arch)
|
||||
build.arches.append(arch_obj)
|
||||
if arch_obj not in build.arches:
|
||||
build.arches.append(arch_obj)
|
||||
|
||||
db_session.commit()
|
||||
|
||||
|
||||
@@ -87,6 +87,10 @@ class TestSubmit:
|
||||
arches = {arch.name for arch in build.arches}
|
||||
assert arches == set(get_build_arches.return_value)
|
||||
|
||||
# Ensure the function is idempotent
|
||||
record_module_build_arches(build.mmd(), build)
|
||||
assert len(build.arches) == len(get_build_arches.return_value)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"scmurl",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user