CreateBranch: Test that branches cannot be created with invalid names

This increases the test coverage of the CreateBranch REST endpoint.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I86e46cf34e49172be2fb15e8970c5dca5aa2dd1f
This commit is contained in:
Edwin Kempin
2020-03-25 10:54:34 +01:00
parent b4ab1d3a6a
commit c1571fb30a

View File

@@ -336,6 +336,14 @@ public class CreateBranchIT extends AbstractDaemonTest {
"not allowed to create branches under \"" + MagicBranch.NEW_CHANGE + "\"");
}
@Test
public void cannotCreateBranchWithInvalidName() throws Exception {
assertCreateFails(
BranchNameKey.create(project, RefNames.REFS_HEADS),
BadRequestException.class,
"invalid branch name \"" + RefNames.REFS_HEADS + "\"");
}
@Test
public void createBranchLeadingSlashesAreRemoved() throws Exception {
BranchNameKey expectedNameKey = BranchNameKey.create(project, "test");