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
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java index 213f62c..c565ad0 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java
@@ -22,6 +22,7 @@ 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 @@ // 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