AbstractPushForReview: Add test for message output

Change-Id: Ibca2d62d474a6cb638a879c24c28edb644d64959
This commit is contained in:
Dave Borowitz
2016-06-13 18:01:55 -04:00
committed by David Pursehouse
parent a0157917f2
commit e4f1396aba

View File

@@ -35,6 +35,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.testutil.TestTimeUtil;
import com.google.gerrit.server.git.ProjectConfig;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.PushResult;
import org.junit.AfterClass;
@@ -90,6 +91,39 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
r.assertChange(Change.Status.NEW, null);
}
@Test
public void testOutput() throws Exception {
String url = canonicalWebUrl.get();
ObjectId initialHead = testRepo.getRepository().resolve("HEAD");
PushOneCommit.Result r1 = pushTo("refs/for/master");
Change.Id id1 = r1.getChange().getId();
r1.assertOkStatus();
r1.assertChange(Change.Status.NEW, null);
r1.assertMessage(
"New changes:\n"
+ " " + url + id1 + " " + r1.getCommit().getShortMessage() + "\n");
testRepo.reset(initialHead);
String newMsg = r1.getCommit().getShortMessage() + " v2";
testRepo.branch("HEAD").commit()
.message(newMsg)
.insertChangeId(r1.getChangeId().substring(1))
.create();
PushOneCommit.Result r2 = pushFactory.create(
db, admin.getIdent(), testRepo, "another commit", "b.txt", "bbb")
.to("refs/for/master");
Change.Id id2 = r2.getChange().getId();
r2.assertOkStatus();
r2.assertChange(Change.Status.NEW, null);
r2.assertMessage(
"New changes:\n"
+ " " + url + id2 + " another commit\n"
+ "\n"
+ "\n"
+ "Updated changes:\n"
+ " " + url + id1 + " " + newMsg + "\n");
}
@Test
public void testPushForMasterWithTopic() throws Exception {
// specify topic in ref