Test cherry-pick to a non-existing branch
Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I050c60945f9f1e9fff19ff283c34a36ca3df2367
This commit is contained in:

committed by
David Pursehouse

parent
becc6beb78
commit
3cd05476c2
@@ -87,6 +87,7 @@ import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.change.RevisionResource;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.restapi.change.GetRevisionActions;
|
||||
@@ -908,6 +909,24 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
assertCherryPickResult(changeInfo, input, srcChange.getChangeId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cherryPickToNonExistingBranch() throws Exception {
|
||||
PushOneCommit.Result result = createChange();
|
||||
|
||||
CherryPickInput input = new CherryPickInput();
|
||||
input.message = "foo bar";
|
||||
input.destination = "non-existing";
|
||||
// TODO(ekempin): This should rather result in an UnprocessableEntityException.
|
||||
BadRequestException thrown =
|
||||
assertThrows(
|
||||
BadRequestException.class,
|
||||
() -> gApi.changes().id(result.getChangeId()).current().cherryPick(input));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
String.format("Branch %s does not exist.", RefNames.REFS_HEADS + input.destination));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cherryPickToNonExistingBaseCommit() throws Exception {
|
||||
createBranch(new Branch.NameKey(project, "foo"));
|
||||
|
Reference in New Issue
Block a user