Support empty ChangeUpdates
To create a change in the notedb and ensure the meta ref exists, we need a root commit, but thus far we don't have anything else to put in the root commit, so it is effectively empty. Ensure this code path works. Change-Id: I3e5496c7019f083401ef24e430e2b9f89c9936b4
This commit is contained in:
@@ -473,12 +473,13 @@ public class ChangeUpdate extends AbstractChangeUpdate {
|
||||
|
||||
private boolean isEmpty() {
|
||||
return approvals.isEmpty()
|
||||
&& reviewers.isEmpty()
|
||||
&& changeMessage == null
|
||||
&& commentsForBase.isEmpty()
|
||||
&& commentsForPs.isEmpty()
|
||||
&& reviewers.isEmpty()
|
||||
&& status == null
|
||||
&& submitRecords == null
|
||||
&& changeMessage == null;
|
||||
&& subject == null
|
||||
&& submitRecords == null;
|
||||
}
|
||||
|
||||
private static StringBuilder addFooter(StringBuilder sb, FooterKey footer) {
|
||||
|
@@ -22,6 +22,8 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -618,6 +620,20 @@ public class ChangeNotesTest {
|
||||
Iterables.getOnlyElement(notes.getSubmitRecords()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyChangeUpdate() throws Exception {
|
||||
ChangeUpdate update = newUpdate(newChange(), changeOwner);
|
||||
update.commit();
|
||||
assertNull(update.getRevision());
|
||||
}
|
||||
|
||||
public void emptyExceptSubject() throws Exception {
|
||||
ChangeUpdate update = newUpdate(newChange(), changeOwner);
|
||||
update.setSubject("Create change");
|
||||
update.commit();
|
||||
assertNotNull(update.getRevision());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleUpdatesInBatch() throws Exception {
|
||||
Change c = newChange();
|
||||
|
Reference in New Issue
Block a user