ChangeIT: Add test for rebasing on a specific change number

Change-Id: I4a4a9c86c6806173581d5f0dfe7ba10c2cdf772a
This commit is contained in:
Dave Borowitz 2018-03-23 09:48:37 -04:00
parent a01d3ab660
commit e33ccf7b63

View File

@ -819,6 +819,26 @@ public class ChangeIT extends AbstractDaemonTest {
gApi.changes().id(changeId).current().rebase();
}
@Test
public void rebaseOnChangeNumber() throws Exception {
String branchTip = testRepo.getRepository().exactRef("HEAD").getObjectId().name();
PushOneCommit.Result r1 = createChange();
testRepo.reset("HEAD~1");
PushOneCommit.Result r2 = createChange();
ChangeInfo ci2 = get(r2.getChangeId(), CURRENT_REVISION, CURRENT_COMMIT);
RevisionInfo ri2 = ci2.revisions.get(ci2.currentRevision);
assertThat(ri2.commit.parents.get(0).commit).isEqualTo(branchTip);
RebaseInput in = new RebaseInput();
in.base = Integer.toString(r1.getChange().getId().get());
gApi.changes().id(r2.getChangeId()).rebase(in);
ci2 = get(r2.getChangeId(), CURRENT_REVISION, CURRENT_COMMIT);
ri2 = ci2.revisions.get(ci2.currentRevision);
assertThat(ri2.commit.parents.get(0).commit).isEqualTo(r1.getCommit().name());
}
@Test
public void rebaseNotAllowedWithoutPermission() throws Exception {
// Create two changes both with the same parent