[FIX] runbot: fix oversight of logging reason in _skip

When giving a reason of a build skip, the reason paramater was missing
in the logging string.

Test is also added to verify the build skip.
This commit is contained in:
Christophe Monniez 2019-02-26 10:19:54 +01:00
parent 1617a2e339
commit 41ce858c93
2 changed files with 24 additions and 1 deletions

View File

@ -308,7 +308,7 @@ class runbot_build(models.Model):
def _skip(self, reason=None):
"""Mark builds ids as skipped"""
if reason:
self._logger('skip', reason)
self._logger('skip %s', reason)
self.write({'state': 'done', 'result': 'skipped'})
to_unduplicate = self.search([('id', 'in', self.ids), ('duplicate_id', '!=', False)])
to_unduplicate._force()

View File

@ -158,6 +158,29 @@ class Test_Build(common.TransactionCase):
})
self.assertEqual(build, self.Build, "build should be an empty recordset")
@patch('odoo.addons.runbot.models.build._logger')
def test_build_skip(self, mock_logger):
"""test build is skipped"""
build = self.Build.create({
'branch_id': self.branch.id,
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
'port': '1234',
})
build._skip()
self.assertEqual(build.state, 'done')
self.assertEqual(build.result, 'skipped')
other_build = self.Build.create({
'branch_id': self.branch.id,
'name': 'deadbeef0000ffffffffffffffffffffffffffff',
'port': '1234',
})
other_build._skip(reason='A good reason')
self.assertEqual(other_build.state, 'done')
self.assertEqual(other_build.result, 'skipped')
log_first_part = '%s skip %%s' % (other_build.dest)
mock_logger.debug.assert_called_with(log_first_part, 'A good reason')
@patch('odoo.addons.runbot.models.branch.runbot_branch._is_on_remote')
def test_closest_branch_01(self, mock_is_on_remote):
""" test find a matching branch in a target repo based on branch name """