CreateBranch: Test that refs/meta/config branch can be created
Usually the refs/meta/config branch is always present and cannot be deleted. However if it is missing it should be possible to create it via the CreateBranch REST endpoint. This increases the test coverage of the CreateBranch REST endpoint. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I181742e862b4088f7bff6465309d649c5d8ef956
This commit is contained in:
@@ -50,6 +50,7 @@ import com.google.gerrit.server.validators.ValidationException;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@@ -188,6 +189,23 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
assertCreateSucceeds(BranchNameKey.create(project, metaRef));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createMetaConfigBranch() throws Exception {
|
||||
// Since the refs/meta/config branch exists by default, we must delete it before we can test
|
||||
// creating it. Since deleting the refs/meta/config branch is not allowed through the API, we
|
||||
// delete it directly in the remote repository.
|
||||
try (TestRepository<Repository> repo =
|
||||
new TestRepository<>(repoManager.openRepository(project))) {
|
||||
repo.delete(RefNames.REFS_CONFIG);
|
||||
}
|
||||
|
||||
// Create refs/meta/config branch.
|
||||
BranchInfo created =
|
||||
branch(BranchNameKey.create(project, RefNames.REFS_CONFIG)).create(new BranchInput()).get();
|
||||
assertThat(created.ref).isEqualTo(RefNames.REFS_CONFIG);
|
||||
assertThat(created.canDelete).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createUserBranch_Conflict() throws Exception {
|
||||
projectOperations
|
||||
|
||||
Reference in New Issue
Block a user