[image-build] Fix resolving git urls

After config was modified to work with sections, the resolving broke.
This patch fixes it and adds a test to catch this problem in the future.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-02-29 08:23:26 +01:00
parent 73a560d63c
commit 4a4ef23e3c
2 changed files with 40 additions and 1 deletions

View File

@ -100,7 +100,7 @@ class ImageBuildPhase(PhaseBase):
continue
# Replace possible ambiguous ref name with explicit hash.
if 'ksurl' in image_conf:
if 'ksurl' in image_conf['image-build']:
image_conf["image-build"]['ksurl'] = resolve_git_url(image_conf["image-build"]['ksurl'])
image_conf["image-build"]["variant"] = variant

View File

@ -321,6 +321,45 @@ class TestImageBuildPhase(PungiTestCase):
args, kwargs = phase.pool.queue_put.call_args
self.assertTrue(args[0][1].get('scratch'))
@mock.patch('pungi.phases.image_build.resolve_git_url')
@mock.patch('pungi.phases.image_build.ThreadPool')
def test_image_build_resolve_ksurl(self, ThreadPool, resolve_git_url):
compose = DummyCompose(self.topdir, {
'image_build': {
'^Server$': [
{
'image-build': {
'format': [('docker', 'tar.xz')],
'name': 'Fedora-Docker-Base',
'target': 'f24',
'version': 'Rawhide',
'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git?#HEAD',
'kickstart': "fedora-docker-base.ks",
'distro': 'Fedora-20',
'disk_size': 3,
'arches': ['x86_64'],
'scratch': True,
}
}
]
},
'koji_profile': 'koji',
})
resolve_git_url.return_value = 'git://git.fedorahosted.org/git/spin-kickstarts.git?#BEEFCAFE'
phase = ImageBuildPhase(compose)
phase.run()
# assert at least one thread was started
self.assertTrue(phase.pool.add.called)
self.assertTrue(phase.pool.queue_put.called_once)
args, kwargs = phase.pool.queue_put.call_args
self.assertEqual(args[0][1]['image_conf'].get('image-build', {}).get('ksurl'),
resolve_git_url.return_value)
class TestCreateImageBuildThread(PungiTestCase):