[IMP] runbot_merge: ensure inconsistent batches don't merge

I was pretty sure it wouldn't happen but it doesn't hurt to make sure,
also to check that splitting the batch does correctly make things work
out.
This commit is contained in:
Xavier Morel 2024-07-18 12:34:42 +02:00
parent 015c97b2cc
commit fd6eae0d1d

View File

@ -81,7 +81,7 @@ def test_close_multiple(env, make_repo2):
assert not batch_id.active
assert Batches.search_count([]) == 0
def test_inconsistent_target(env, project, make_repo2, users, page):
def test_inconsistent_target(env, project, make_repo2, users, page, config):
"""If a batch's PRs have inconsistent targets,
- only open PRs should count
@ -97,8 +97,8 @@ def test_inconsistent_target(env, project, make_repo2, users, page):
project.write({'branch_ids': [(0, 0, {'name': 'other'})]})
with repo1:
repo1.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/master')
repo1.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/other')
[m] = repo1.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/master')
repo1.make_ref('heads/other', m)
repo1.make_commits('master', Commit('b', tree={"b": "b"}), ref='heads/a_pr')
pr1 = repo1.make_pr(head='a_pr', target='master')
@ -161,6 +161,19 @@ Inconsistent targets:
assert b.target.name == False
assert to_pr(env, pr_other).label == f'{owner}:something_else'
# try staging
with repo1:
pr1.post_comment("hansen r+", config['role_reviewer']['token'])
repo1.post_status(pr1.head, "success")
with repo2:
pr2.post_comment("hansen r+", config['role_reviewer']['token'])
repo2.post_status(pr2.head, "success")
env.run_crons()
assert not pr1_id.blocked
assert not pr2_id.blocked
assert b.blocked
assert env['runbot_merge.stagings'].search_count([]) == 0
act = pr2_id.button_split()
assert act['type'] == 'ir.actions.act_window'
assert act['views'] == [[False, 'form']]
@ -178,3 +191,11 @@ Inconsistent targets:
assert len(b.prs) == 1, "the PR has been moved off of this batch entirely"
assert len(b.all_prs) == 2
# endregion
assert not pr1_id.blocked
assert not pr1_id.batch_id.blocked
assert not pr2_id.blocked
assert not pr2_id.batch_id.blocked
env.run_crons()
assert env['runbot_merge.stagings'].search_count([])