basic unit test for genMockConfig

This commit is contained in:
Mike McLean 2018-02-28 10:39:22 -05:00
parent cfca804acd
commit c7e16a993d
4 changed files with 58 additions and 0 deletions

View file

View file

@ -0,0 +1,8 @@
{
"name": "ROOTNAME",
"arch": "x86_64",
"managed": false,
"repoid": 99,
"tag_name": "TAG",
"opts": {}
}

View file

@ -0,0 +1,23 @@
# Auto-generated by the Koji build system
config_opts['chroothome'] = '/builddir'
config_opts['use_host_resolv'] = False
config_opts['basedir'] = '/var/lib/mock'
config_opts['rpmbuild_timeout'] = 86400
config_opts['yum.conf'] = u'[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
config_opts['chroot_setup_cmd'] = 'groupinstall build'
config_opts['target_arch'] = u'x86_64'
config_opts['root'] = u'ROOTNAME'
config_opts['plugin_conf']['root_cache_enable'] = False
config_opts['plugin_conf']['yum_cache_enable'] = False
config_opts['plugin_conf']['ccache_enable'] = False
config_opts['macros']['%_host'] = u'x86_64-koji-linux-gnu'
config_opts['macros']['%_host_cpu'] = u'x86_64'
config_opts['macros']['%vendor'] = 'Koji'
config_opts['macros']['%distribution'] = 'Unknown'
config_opts['macros']['%_topdir'] = '/builddir/build'
config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
config_opts['macros']['%packager'] = 'Koji'

View file

@ -0,0 +1,27 @@
import json
import os
import os.path
import unittest
import koji
class TestGenMockConfig(unittest.TestCase):
def test_gen_mock_config(self):
datadir = os.path.join(os.path.dirname(__file__), 'data/mock')
count = 0
for fn in os.listdir(datadir):
if not fn.endswith('.json'):
continue
path = os.path.join(datadir, fn)
with open(path) as fo:
params = json.load(fo)
with open(path[:-5] + '.out') as fo:
expected = fo.read()
output = koji.genMockConfig(**params)
self.assertMultiLineEqual(output, expected)
count += 1
if not count:
raise Exception('no test data found')