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:
Dave Borowitz
2014-07-25 11:37:35 -07:00
parent 5236477f04
commit 8925f3e287
2 changed files with 20 additions and 3 deletions

View File

@@ -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();