[FIX] runbot_merge: the fix

The test was checking things would work properly with
required_statuses being an empty string, because I'd also forgotten an
empty field becomes stored as `False` in the database, so trying
things out live neither the PRs nor the staging would work as their
assumption that they could straight split the required_statuses would
always fail.

Update the test to better match expectations, and hopefully this is
the end of that saga.
This commit is contained in:
Xavier Morel 2020-02-07 09:54:08 +01:00
parent 4bdf7e5eda
commit 0831c899e8
2 changed files with 4 additions and 3 deletions

View File

@ -893,7 +893,7 @@ class PullRequests(models.Model):
# targets
failed = self.browse(())
for pr in self:
required = filter(None, pr.repository.required_statuses.split(','))
required = filter(None, (pr.repository.required_statuses or '').split(','))
success = True
for ci in required:
@ -1477,6 +1477,7 @@ class Stagings(models.Model):
(head, repos[repo].required_statuses.split(','))
for repo, head in json.loads(s.heads).items()
if not repo.endswith('^')
if repos[repo].required_statuses
]
# maps commits to their statuses
cmap = {
@ -1488,7 +1489,7 @@ class Stagings(models.Model):
st = 'success'
for head, reqs in required_statuses:
statuses = cmap.get(head) or {}
for v in map(lambda n: state_(statuses, n), filter(None, reqs)):
for v in map(lambda n: state_(statuses, n), reqs):
if st == 'failure' or v in ('error', 'failure'):
st = 'failure'
elif v is None:

View File

@ -940,7 +940,7 @@ def test_reopen_state(env, repo):
def test_no_required_statuses(env, repo, config):
""" check that mergebot can work on a repo with no CI at all
"""
env['runbot_merge.repository'].search([('name', '=', repo.name)]).required_statuses = ''
env['runbot_merge.repository'].search([('name', '=', repo.name)]).required_statuses = False
with repo:
m = repo.make_commit(None, 'initial', None, tree={'0': '0'})
repo.make_ref('heads/master', m)