#2477 hub: deleteBuild should skip deleted builds
Merged 3 years ago by tkopecek. Opened 3 years ago by tkopecek.
tkopecek/koji issue2475  into  master

file modified
+3
@@ -8025,6 +8025,9 @@ 

      """

      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 @@ 

                  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 @@ 

          '''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)

  

We can return ASAP from the call if build is already deleted.

Fixes: https://pagure.io/koji/issue/2475

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

3 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

3 years ago

Commit 4ae23c1 fixes this pull-request

Pull-Request has been merged by tkopecek

3 years ago