use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeIT method checkLabelsForAutoClosedChange.
@Test
public void checkLabelsForAutoClosedChange() throws Exception {
PushOneCommit.Result r = createChange();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result result = push.to("refs/heads/master");
result.assertOkStatus();
ChangeInfo change = gApi.changes().id(r.getChangeId()).get();
assertThat(change.status).isEqualTo(ChangeStatus.MERGED);
assertThat(change.labels.keySet()).containsExactly("Code-Review");
assertPermitted(change, "Code-Review", 0, 1, 2);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickConflict.
@Test
public void cherryPickConflict() throws Exception {
PushOneCommit.Result r = createChange();
CherryPickInput in = new CherryPickInput();
in.destination = "foo";
in.message = "it goes to stable branch";
gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, PushOneCommit.FILE_NAME, "another content");
push.to("refs/heads/foo");
String triplet = project.get() + "~master~" + r.getChangeId();
ChangeApi orig = gApi.changes().id(triplet);
assertThat(orig.get().messages).hasSize(1);
exception.expect(ResourceConflictException.class);
exception.expectMessage("Cherry pick failed: merge conflict");
orig.revision(r.getCommit().name()).cherryPick(in);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class RevisionIT method canRebase.
@Test
public void canRebase() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
merge(r1);
push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r2 = push.to("refs/for/master");
boolean canRebase = gApi.changes().id(r2.getChangeId()).revision(r2.getCommit().name()).canRebase();
assertThat(canRebase).isFalse();
merge(r2);
testRepo.reset(r1.getCommit());
push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r3 = push.to("refs/for/master");
canRebase = gApi.changes().id(r3.getChangeId()).revision(r3.getCommit().name()).canRebase();
assertThat(canRebase).isTrue();
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class RevisionIT method mergeable.
@Test
public void mergeable() throws Exception {
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, PushOneCommit.FILE_NAME, "push 1 content");
PushOneCommit.Result r1 = push1.to("refs/for/master");
assertMergeable(r1.getChangeId(), true);
merge(r1);
// Reset HEAD to initial so the new change is a merge conflict.
RefUpdate ru = repo().updateRef(HEAD);
ru.setNewObjectId(initial);
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, PushOneCommit.FILE_NAME, "push 2 content");
PushOneCommit.Result r2 = push2.to("refs/for/master");
assertMergeable(r2.getChangeId(), false);
// TODO(dborowitz): Test for other-branches.
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class RevisionIT method setUnsetReviewedFlag.
@Test
public void setUnsetReviewedFlag() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/for/master");
gApi.changes().id(r.getChangeId()).current().setReviewed(PushOneCommit.FILE_NAME, true);
assertThat(Iterables.getOnlyElement(gApi.changes().id(r.getChangeId()).current().reviewed())).isEqualTo(PushOneCommit.FILE_NAME);
gApi.changes().id(r.getChangeId()).current().setReviewed(PushOneCommit.FILE_NAME, false);
assertThat(gApi.changes().id(r.getChangeId()).current().reviewed()).isEmpty();
}
Aggregations