ChangeIT: Fix/improve tests for CreateMergePatchSet REST endpoint
1. Instead of creating and pushing a commit to have a start commit, just retrieve the already existing commit from the master branch. 2. Rename the variable for the start commit from 'start' to 'initialHead' to have the naming consistent with the other tests. 3. Create the dev branch before pushing a commit to the master branch, so that the commit that is pushed to the dev branch is a sibling and not a follow-up commit. This way we test a real merge and not just the fast-forward merge case. This requires to reset the testRepo to the start commit before creating and pushing a commit to the dev branch. 4. Remove the redundant call to PushOneCommit.Result#assertOkStatus() after calling createChange(). The createChange() method already calls assertOkStatus(). Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I672c5e784a006cb65b8d193daea6f821e1cbfb38
This commit is contained in:
committed by
David Pursehouse
parent
c36abc746b
commit
b9cf6d896e
@@ -3167,20 +3167,19 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createMergePatchSet() throws Exception {
|
public void createMergePatchSet() throws Exception {
|
||||||
PushOneCommit.Result start = pushTo("refs/heads/master");
|
RevCommit initialHead = projectOperations.project(project).getHead("master");
|
||||||
start.assertOkStatus();
|
createBranch("dev");
|
||||||
// create a change for master
|
|
||||||
PushOneCommit.Result r = createChange();
|
|
||||||
r.assertOkStatus();
|
|
||||||
String changeId = r.getChangeId();
|
|
||||||
|
|
||||||
testRepo.reset(start.getCommit());
|
// create a change for master
|
||||||
|
String changeId = createChange().getChangeId();
|
||||||
|
|
||||||
|
testRepo.reset(initialHead);
|
||||||
PushOneCommit.Result currentMaster = pushTo("refs/heads/master");
|
PushOneCommit.Result currentMaster = pushTo("refs/heads/master");
|
||||||
currentMaster.assertOkStatus();
|
currentMaster.assertOkStatus();
|
||||||
String parent = currentMaster.getCommit().getName();
|
String parent = currentMaster.getCommit().getName();
|
||||||
|
|
||||||
// push a commit into dev branch
|
// push a commit into dev branch
|
||||||
createBranch("dev");
|
testRepo.reset(initialHead);
|
||||||
PushOneCommit.Result changeA =
|
PushOneCommit.Result changeA =
|
||||||
pushFactory
|
pushFactory
|
||||||
.create(user.newIdent(), testRepo, "change A", "A.txt", "A content")
|
.create(user.newIdent(), testRepo, "change A", "A.txt", "A content")
|
||||||
@@ -3202,21 +3201,21 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createMergePatchSetInheritParent() throws Exception {
|
public void createMergePatchSetInheritParent() throws Exception {
|
||||||
PushOneCommit.Result start = pushTo("refs/heads/master");
|
RevCommit initialHead = projectOperations.project(project).getHead("master");
|
||||||
start.assertOkStatus();
|
createBranch("dev");
|
||||||
|
|
||||||
// create a change for master
|
// create a change for master
|
||||||
PushOneCommit.Result r = createChange();
|
PushOneCommit.Result r = createChange();
|
||||||
r.assertOkStatus();
|
|
||||||
String changeId = r.getChangeId();
|
String changeId = r.getChangeId();
|
||||||
String parent = r.getCommit().getParent(0).getName();
|
String parent = r.getCommit().getParent(0).getName();
|
||||||
|
|
||||||
// advance master branch
|
// advance master branch
|
||||||
testRepo.reset(start.getCommit());
|
testRepo.reset(initialHead);
|
||||||
PushOneCommit.Result currentMaster = pushTo("refs/heads/master");
|
PushOneCommit.Result currentMaster = pushTo("refs/heads/master");
|
||||||
currentMaster.assertOkStatus();
|
currentMaster.assertOkStatus();
|
||||||
|
|
||||||
// push a commit into dev branch
|
// push a commit into dev branch
|
||||||
createBranch("dev");
|
testRepo.reset(initialHead);
|
||||||
PushOneCommit.Result changeA =
|
PushOneCommit.Result changeA =
|
||||||
pushFactory
|
pushFactory
|
||||||
.create(user.newIdent(), testRepo, "change A", "A.txt", "A content")
|
.create(user.newIdent(), testRepo, "change A", "A.txt", "A content")
|
||||||
|
|||||||
Reference in New Issue
Block a user