Add IT to verify copyAllScoresOnMergeFirstParentUpdate policy

This is the patch following [1] in functionality aspect
[1] https://gerrit-review.googlesource.com/#/c/74444/

Change-Id: Ib1e1f67534af9beb9a7ea621962bdae572f27487
Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
This commit is contained in:
Jacek Centkowski
2016-03-18 16:23:37 +01:00
parent a867981a1c
commit 339937adf3

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.server.project;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
@@ -167,6 +168,26 @@ public class LabelTypeIT extends AbstractDaemonTest {
assertApproval(patchSet, 1);
}
@Test
public void copyAllScoresOnMergeFirstParentUpdateAppliesToMergeParentUpdate()
throws Exception {
codeReview.setCopyAllScoresOnMergeFirstParentUpdate(true);
saveLabelConfig();
PushOneCommit.Result merge = createMergeCommitAndUpdateFirstParent();
assertApproval(merge, 1);
}
@Test
public void copyAllScoresOnMergeFirstParentUpdateNotAppliesIfNotSet()
throws Exception {
codeReview.setCopyAllScoresOnMergeFirstParentUpdate(false);
saveLabelConfig();
PushOneCommit.Result merge = createMergeCommitAndUpdateFirstParent();
assertApproval(merge, 0);
}
@Test
public void copyAllScoresIfNoChange() throws Exception {
PushOneCommit.Result patchSet = readyPatchSetForNoChangeRebase();
@@ -319,6 +340,47 @@ public class LabelTypeIT extends AbstractDaemonTest {
.get());
}
private PushOneCommit.Result createMergeCommitAndUpdateFirstParent()
throws Exception {
String file = "m.txt";
String contents = "contents";
PushOneCommit.Result base = pushToMaster(file, contents);
// create feature commit and push it to feature branch
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
PushOneCommit.SUBJECT, file, contents + "feature");
PushOneCommit.Result feature = push.to("refs/heads/feature");
// create merge commit and push it for review
testRepo.reset(base.getCommit());
push = pushFactory.create(db, admin.getIdent(), testRepo,
PushOneCommit.SUBJECT, PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT);
push.setParents(ImmutableList.of(base.getCommit(), feature.getCommit()));
PushOneCommit.Result merge = push.to("refs/for/master");
revision(merge).review(ReviewInput.recommend());
// advance master
testRepo.reset(base.getCommit());
PushOneCommit.Result advanced = pushToMaster(file, contents + "master_advances");
// update first parent of merge commit
push = pushFactory.create(db, admin.getIdent(), testRepo,
PushOneCommit.SUBJECT, PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT,
merge.getChangeId());
push.setParents(ImmutableList.of(advanced.getCommit(), feature.getCommit()));
merge = push.to("refs/for/master");
return merge;
}
private PushOneCommit.Result pushToMaster(String file, String contents)
throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
PushOneCommit.SUBJECT, file, contents);
PushOneCommit.Result base = push.to("refs/for/master");
merge(base);
return base;
}
private PushOneCommit.Result readyPatchSetForNoChangeRebase()
throws Exception {
String file = "a.txt";