PR#2477: hub: deleteBuild should skip deleted builds
Merges #2477 https://pagure.io/koji/pull-request/2477 Fixes: #2475 https://pagure.io/koji/issue/2475 deleteBuild should skip already deleted builds
This commit is contained in:
commit
4ae23c1847
2 changed files with 9 additions and 5 deletions
|
|
@ -8025,6 +8025,9 @@ def delete_build(build, strict=True, min_ref_age=604800):
|
|||
"""
|
||||
context.session.assertPerm('admin')
|
||||
binfo = get_build(build, strict=True)
|
||||
if binfo['state'] == koji.BUILD_STATES['DELETED']:
|
||||
# silently return on already deleted build
|
||||
return
|
||||
refs = build_references(binfo['id'], limit=10, lazy=True)
|
||||
if refs.get('tags'):
|
||||
if strict:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import mock
|
||||
import unittest
|
||||
import kojihub
|
||||
import time
|
||||
from koji import GenericError
|
||||
import unittest
|
||||
from collections import defaultdict
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
|
||||
class TestDeleteBuild(unittest.TestCase):
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ class TestDeleteBuild(unittest.TestCase):
|
|||
retval = defaultdict(dict)
|
||||
retval[ref] = True
|
||||
refs.return_value = retval
|
||||
with self.assertRaises(GenericError):
|
||||
with self.assertRaises(koji.GenericError):
|
||||
kojihub.delete_build(build='', strict=True)
|
||||
|
||||
@mock.patch('kojihub.context')
|
||||
|
|
@ -64,7 +65,7 @@ class TestDeleteBuild(unittest.TestCase):
|
|||
'''Test that we can handle lazy return from build_references'''
|
||||
context.session.assertPerm = mock.MagicMock()
|
||||
buildrefs.return_value = {'tags': []}
|
||||
binfo = {'id': 'BUILD ID'}
|
||||
binfo = {'id': 'BUILD ID', 'state': koji.BUILD_STATES['COMPLETE']}
|
||||
build.return_value = binfo
|
||||
kojihub.delete_build(build=binfo, strict=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue