Update tests to use ostree write-commit-id
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
This commit is contained in:
parent
754458823c
commit
a49510a9fb
@ -2,6 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
import json
|
||||||
import unittest
|
import unittest
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(OSTreeThreadTest, self).setUp()
|
super(OSTreeThreadTest, self).setUp()
|
||||||
self.repo = os.path.join(self.topdir, 'place/for/atomic')
|
self.repo = os.path.join(self.topdir, 'place/for/atomic')
|
||||||
|
os.makedirs(os.path.join(self.repo, 'refs', 'heads'))
|
||||||
self.cfg = {
|
self.cfg = {
|
||||||
'source_repo_from': 'Everything',
|
'source_repo_from': 'Everything',
|
||||||
'config_url': 'https://git.fedorahosted.org/git/fedora-atomic.git',
|
'config_url': 'https://git.fedorahosted.org/git/fedora-atomic.git',
|
||||||
@ -65,7 +67,9 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
|||||||
self.pool = mock.Mock()
|
self.pool = mock.Mock()
|
||||||
|
|
||||||
def _dummy_config_repo(self, scm_dict, target, logger=None):
|
def _dummy_config_repo(self, scm_dict, target, logger=None):
|
||||||
helpers.touch(os.path.join(target, 'fedora-atomic-docker-host.json'))
|
os.makedirs(target)
|
||||||
|
helpers.touch(os.path.join(target, 'fedora-atomic-docker-host.json'),
|
||||||
|
json.dumps({'ref': 'fedora-atomic/25/x86_64'}))
|
||||||
helpers.touch(os.path.join(target, 'fedora-rawhide.repo'),
|
helpers.touch(os.path.join(target, 'fedora-rawhide.repo'),
|
||||||
'mirrorlist=mirror-mirror-on-the-wall')
|
'mirrorlist=mirror-mirror-on-the-wall')
|
||||||
helpers.touch(os.path.join(target, 'fedora-24.repo'),
|
helpers.touch(os.path.join(target, 'fedora-24.repo'),
|
||||||
@ -73,13 +77,16 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
|||||||
helpers.touch(os.path.join(target, 'fedora-23.repo'),
|
helpers.touch(os.path.join(target, 'fedora-23.repo'),
|
||||||
'baseurl=why-not-zoidberg?')
|
'baseurl=why-not-zoidberg?')
|
||||||
|
|
||||||
def _mock_runroot(self, retcode, logs=None):
|
def _mock_runroot(self, retcode, writefiles=None):
|
||||||
"""Pretend to run a task in runroot, creating a log file with given line"""
|
"""Pretend to run a task in runroot, creating a log file with given line
|
||||||
|
|
||||||
|
Also allows for writing other files of requested"""
|
||||||
def fake_runroot(self, log_file, **kwargs):
|
def fake_runroot(self, log_file, **kwargs):
|
||||||
if logs:
|
if writefiles:
|
||||||
logdir = os.path.dirname(log_file)
|
logdir = os.path.dirname(log_file)
|
||||||
helpers.touch(os.path.join(logdir, 'create-ostree-repo.log'),
|
for filename in writefiles:
|
||||||
'\n'.join(['Doing work', logs]))
|
helpers.touch(os.path.join(logdir, filename),
|
||||||
|
'\n'.join(writefiles[filename]))
|
||||||
return {'task_id': 1234, 'retcode': retcode, 'output': 'Foo bar\n'}
|
return {'task_id': 1234, 'retcode': retcode, 'output': 'Foo bar\n'}
|
||||||
return fake_runroot
|
return fake_runroot
|
||||||
|
|
||||||
@ -165,7 +172,10 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
|||||||
|
|
||||||
koji = KojiWrapper.return_value
|
koji = KojiWrapper.return_value
|
||||||
koji.run_runroot_cmd.side_effect = self._mock_runroot(
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(
|
||||||
0, 'fedora-atomic/25/x86_64 => fca3465861a')
|
0,
|
||||||
|
{'commitid': 'fca3465861a',
|
||||||
|
'create-ostree-repo.log':
|
||||||
|
['Doing work', 'fedora-atomic/25/x86_64 -> fca3465861a']})
|
||||||
t = ostree.OSTreeThread(self.pool)
|
t = ostree.OSTreeThread(self.pool)
|
||||||
|
|
||||||
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
|
||||||
@ -185,7 +195,9 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
|||||||
self.compose.notifier = mock.Mock()
|
self.compose.notifier = mock.Mock()
|
||||||
|
|
||||||
koji = KojiWrapper.return_value
|
koji = KojiWrapper.return_value
|
||||||
koji.run_runroot_cmd.side_effect = self._mock_runroot(0, 'Weird output')
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(
|
||||||
|
0,
|
||||||
|
{'create-ostree-repo.log': ['Doing work', 'Weird output']})
|
||||||
t = ostree.OSTreeThread(self.pool)
|
t = ostree.OSTreeThread(self.pool)
|
||||||
|
|
||||||
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user