CodeOwnersOnPostReviewIT: Add test for downgrading a code owner approval
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I5f0e0dc081059d12a733f2a6d58291acb6a389d1
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersOnPostReviewIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersOnPostReviewIT.java
index 34c20bb..62064ea 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersOnPostReviewIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnersOnPostReviewIT.java
@@ -243,7 +243,7 @@
}
@Test
- public void changeMessageListsPathsThatAreStillApproved() throws Exception {
+ public void changeMessageListsPathsThatAreStillApproved_approvalUpgraded() throws Exception {
codeOwnerConfigOperations
.newCodeOwnerConfig()
.project(project)
@@ -272,6 +272,35 @@
}
@Test
+ public void changeMessageListsPathsThatAreStillApproved_approvalDowngraded() throws Exception {
+ codeOwnerConfigOperations
+ .newCodeOwnerConfig()
+ .project(project)
+ .branch("master")
+ .folderPath("/foo/")
+ .addCodeOwnerEmail(admin.email())
+ .create();
+
+ String path = "foo/bar.baz";
+ String changeId = createChange("Test Change", path, "file content").getChangeId();
+
+ approve(changeId);
+
+ // Downgrade the approval from Code-Review+2 to Code-Review+1
+ recommend(changeId);
+
+ Collection<ChangeMessageInfo> messages = gApi.changes().id(changeId).get().messages;
+ assertThat(Iterables.getLast(messages).message)
+ .isEqualTo(
+ String.format(
+ "Patch Set 1: Code-Review+1\n\n"
+ + "By voting Code-Review+1 the following files are still code-owner approved by"
+ + " %s:\n"
+ + "* %s\n",
+ admin.fullName(), path));
+ }
+
+ @Test
public void changeMessageListsPathsThatAreNoLongerApproved_voteRemoved() throws Exception {
codeOwnerConfigOperations
.newCodeOwnerConfig()