Add a test for setting the reviewed flag with multiple patch sets

The test hits the untested logic in
com.google.gerrit.server.restapi.change.Files.ListFiles when requesting
the list of reviewed files of a patch set where no files have been
reviewed by the given user.

Change-Id: I1b1f8593810384e503a9def44416b0ad9db79694
This commit is contained in:
Youssef Elghareeb
2020-03-25 22:40:30 +01:00
parent 889a376a1d
commit 4f71623342

View File

@@ -1084,6 +1084,24 @@ public class RevisionIT extends AbstractDaemonTest {
assertThat(gApi.changes().id(r.getChangeId()).current().reviewed()).isEmpty();
}
@Test
public void setReviewedFlagWithMultiplePatchSets() throws Exception {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
gApi.changes().id(r1.getChangeId()).current().setReviewed(PushOneCommit.FILE_NAME, true);
/** Amending the change will result in the file being un-reviewed in the latest patchset */
PushOneCommit.Result r2 = amendChange(r1.getChangeId());
assertThat(gApi.changes().id(r2.getChangeId()).current().reviewed()).isEmpty();
gApi.changes().id(r2.getChangeId()).current().setReviewed(PushOneCommit.FILE_NAME, true);
assertThat(Iterables.getOnlyElement(gApi.changes().id(r2.getChangeId()).current().reviewed()))
.isEqualTo(PushOneCommit.FILE_NAME);
}
@Test
public void setUnsetReviewedFlagByFileApi() throws Exception {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);