Merge "TestProjectCreation: Add permissionsOnly setting" into stable-3.2

This commit is contained in:
Edwin Kempin
2020-10-06 12:54:58 +00:00
committed by Gerrit Code Review
3 changed files with 13 additions and 0 deletions

View File

@@ -91,6 +91,7 @@ public class ProjectOperationsImpl implements ProjectOperations {
CreateProjectArgs args = new CreateProjectArgs();
args.setProjectName(name);
args.permissionsOnly = projectCreation.permissionOnly().orElse(false);
args.branch = Collections.singletonList(Constants.R_HEADS + Constants.MASTER);
args.createEmptyCommit = projectCreation.createEmptyCommit().orElse(true);
projectCreation.parent().ifPresent(p -> args.newParent = p);

View File

@@ -29,6 +29,8 @@ public abstract class TestProjectCreation {
public abstract Optional<Boolean> createEmptyCommit();
public abstract Optional<Boolean> permissionOnly();
public abstract Optional<SubmitType> submitType();
abstract ThrowingFunction<TestProjectCreation, Project.NameKey> projectCreator();
@@ -48,6 +50,8 @@ public abstract class TestProjectCreation {
public abstract TestProjectCreation.Builder createEmptyCommit(boolean value);
public abstract TestProjectCreation.Builder permissionOnly(boolean value);
/** Skips the empty commit on creation. This means that project's branches will not exist. */
public TestProjectCreation.Builder noEmptyCommit() {
return createEmptyCommit(false);

View File

@@ -41,6 +41,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.TestPermission;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.entities.Project;
import com.google.gerrit.entities.RefNames;
import com.google.gerrit.extensions.api.projects.BranchInfo;
import com.google.gerrit.extensions.api.projects.ConfigInput;
import com.google.gerrit.server.project.ProjectConfig;
@@ -83,6 +84,13 @@ public class ProjectOperationsImplTest extends AbstractDaemonTest {
.isEqualTo(ImmutableList.of("HEAD", "refs/meta/config", "refs/heads/master"));
}
@Test
public void permissionOnly() throws Exception {
Project.NameKey key = projectOperations.newProject().permissionOnly(true).create();
String head = gApi.projects().name(key.get()).head();
assertThat(head).isEqualTo(RefNames.REFS_CONFIG);
}
@Test
public void getProjectConfig() throws Exception {
Project.NameKey key = projectOperations.newProject().create();