AbstractQueryGroupsTest: Add byDeletedGroup to achieve higher coverage

Previously, the getDeleteActions method in ElasticGroupIndex was not
covered by the tests. This change adds the coverage for that method.

Bug: Issue 9040
Change-Id: I7cc117082aff57ab67408559800ecaf2c4678044
This commit is contained in:
Borui Tao
2018-06-05 14:34:23 -04:00
committed by David Pursehouse
parent 23f956dac7
commit 2a727f8b79

View File

@@ -36,6 +36,8 @@ import com.google.gerrit.server.account.AccountManager;
import com.google.gerrit.server.account.AuthRequest;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.index.group.GroupIndex;
import com.google.gerrit.server.index.group.GroupIndexCollection;
import com.google.gerrit.server.query.account.InternalAccountQuery;
import com.google.gerrit.server.schema.SchemaCreator;
import com.google.gerrit.server.util.ManualRequestContext;
@@ -93,6 +95,8 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
@Inject protected GroupCache groupCache;
@Inject private GroupIndexCollection groupIndexes;
protected Injector injector;
protected LifecycleManager lifecycle;
protected ReviewDb db;
@@ -309,6 +313,19 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
assertQuery("description:" + newDescription, group1);
}
@Test
public void byDeletedGroup() throws Exception {
GroupInfo group = createGroup(name("group"));
String query = "uuid:" + group.id;
assertQuery(query, group);
AccountGroup account = db.accountGroups().get(new AccountGroup.Id(group.groupId));
for (GroupIndex index : groupIndexes.getWriteIndexes()) {
index.delete(account.getGroupUUID());
}
assertQuery(query);
}
private Account.Id createAccount(String username, String fullName, String email, boolean active)
throws Exception {
try (ManualRequestContext ctx = oneOffRequestContext.open()) {