CreateBranch: Test rejection if branch name in URL and input mismatch

This increases the test coverage of the CreateBranch REST endpoint.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I32bba5a086ab3630a496d0766e2a74af26b37611
This commit is contained in:
Edwin Kempin
2020-03-25 11:03:21 +01:00
parent c1571fb30a
commit c447a7b425

View File

@@ -365,6 +365,17 @@ public class CreateBranchIT extends AbstractDaemonTest {
.isEqualTo(expectedNameKey.branch());
}
@Test
public void branchNameInInputMustMatchBranchNameInUrl() throws Exception {
BranchInput branchInput = new BranchInput();
branchInput.ref = "foo";
BadRequestException ex =
assertThrows(
BadRequestException.class,
() -> gApi.projects().name(project.get()).branch("bar").create(branchInput));
assertThat(ex).hasMessageThat().isEqualTo("ref must match URL");
}
private void blockCreateReference() throws Exception {
projectOperations
.project(project)