LogServletTest: cover author and committer log filters Gitiles already supports filtering the log by author and committer through query parameters. Add servlet coverage for this existing behavior before building more log search support on top of it. Issue: 376381593 Change-Id: I83aec3e5066c0591e49641228d69c285401382a4
diff --git a/javatests/com/google/gitiles/LogServletTest.java b/javatests/com/google/gitiles/LogServletTest.java index 7d75849..cc0d619 100644 --- a/javatests/com/google/gitiles/LogServletTest.java +++ b/javatests/com/google/gitiles/LogServletTest.java
@@ -26,6 +26,7 @@ import org.eclipse.jgit.internal.storage.dfs.DfsGarbageCollector; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.NullProgressMonitor; +import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; import org.junit.Test; @@ -125,6 +126,37 @@ verifyJsonCommit(response.log.get(1), c1); } + @Test + public void authorFilterLog() throws Exception { + PersonIdent matchingAuthor = new PersonIdent("Matching Author", "matching.author@example.com"); + PersonIdent otherAuthor = new PersonIdent("Other Author", "other.author@example.com"); + + RevCommit c1 = + repo.branch("master").commit().author(matchingAuthor).add("foo", "one").create(); + repo.branch("master").commit().author(otherAuthor).add("foo", "two").create(); + + Log response = + buildJson(LOG, "/repo/+log/master", "author=" + matchingAuthor.getEmailAddress()); + assertThat(response.log).hasSize(1); + verifyJsonCommit(response.log.get(0), c1); + } + + @Test + public void committerFilterLog() throws Exception { + PersonIdent matchingCommitter = + new PersonIdent("Matching Committer", "matching-committer@example.com"); + PersonIdent otherCommitter = new PersonIdent("Other Committer", "other-committer@example.com"); + + RevCommit c1 = + repo.branch("master").commit().committer(matchingCommitter).add("foo", "one").create(); + repo.branch("master").commit().committer(otherCommitter).add("foo", "two").create(); + + Log response = + buildJson(LOG, "/repo/+log/master", "committer=" + matchingCommitter.getEmailAddress()); + assertThat(response.log).hasSize(1); + verifyJsonCommit(response.log.get(0), c1); + } + private void verifyJsonCommit(Commit jsonCommit, RevCommit commit) throws Exception { repo.getRevWalk().parseBody(commit); GitilesAccess access = new TestGitilesAccess(repo.getRepository()).forRequest(null);