CreateBranch: Test creation of a conflicting branch

If a branch refs/heads/test exists it's not possible to create another
branch under that namespace (e.g. refs/heads/test/foo).

Add a test for this to increase the test coverage of the CreateBranch
REST endpoint.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Id6d004e802775bf1d8ebb34860ebe5554157a2bc
This commit is contained in:
Edwin Kempin
2020-03-25 10:32:47 +01:00
parent ad5af8664c
commit 9118e7a74c

View File

@@ -140,6 +140,20 @@ public class CreateBranchIT extends AbstractDaemonTest {
}
}
@Test
public void conflictingBranchAlreadyExists_Conflict() throws Exception {
assertCreateSucceeds(testBranch);
BranchNameKey testBranch2 = BranchNameKey.create(project, testBranch.branch() + "/foo/bar");
assertCreateFails(
testBranch2,
ResourceConflictException.class,
"Cannot create branch \""
+ testBranch2.branch()
+ "\" since it conflicts with branch \""
+ testBranch.branch()
+ "\"");
}
@Test
public void createBranchByProjectOwner() throws Exception {
grantOwner();