AbstractSubmit: Add more assertions in submitWholeTopic

Add an additional check that the remote log has the expected commits
after the submit.

Bug: Issue 4887
Change-Id: Ia39fd771d9e019f97670d6131022fcd3d8d2965d
This commit is contained in:
David Pursehouse 2016-11-04 22:10:01 +09:00
parent a61b6eed53
commit 1ef6e50b0a

@ -22,6 +22,7 @@ import static com.google.common.truth.TruthJUnit.assume;
import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION;
import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS;
import com.google.common.base.Function;
import com.google.common.base.Strings;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Iterables;
@ -163,6 +164,27 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
// Also check submitters for changes submitted via the topic relationship.
assertSubmitter(change1);
assertSubmitter(change2);
// Check that the repo has the expected commits
List<RevCommit> log = getRemoteLog();
List<String> commitsInRepo = Lists.transform(log,
new Function<RevCommit, String>() {
@Override
public String apply(RevCommit input) {
return input.getShortMessage();
}
});
int expectedCommitCount = getSubmitType() == SubmitType.MERGE_ALWAYS
? 5 // initial commit + 3 commits + merge commit
: 4; // initial commit + 3 commits
assertThat(log).hasSize(expectedCommitCount);
assertThat(commitsInRepo).containsAllOf(
"Initial empty repository", "Change 1", "Change 2", "Change 3");
if (getSubmitType() == SubmitType.MERGE_ALWAYS) {
assertThat(commitsInRepo).contains(
"Merge changes from topic 'test-topic'");
}
}
@Test