From 0c2e4b87e9ab0580490b08def68a66cf3d590f06 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 13 Jul 2017 10:28:37 +0900 Subject: [PATCH] Clarify limitations in project list filters Update the documentation to clarify: - Regex and prefix filters are case sensitive - Substring filter is case insensitive - Regex, prefix and substring may not be used together Add tests for case [in]sensitivity. Change-Id: I5de7f5f43b6ecc55dd15c4c009e2e11bd7e72567 --- Documentation/rest-api-projects.txt | 6 ++++++ .../gerrit/acceptance/rest/project/ListProjectsIT.java | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/rest-api-projects.txt b/Documentation/rest-api-projects.txt index d31d468dda..9badbc9b30 100644 --- a/Documentation/rest-api-projects.txt +++ b/Documentation/rest-api-projects.txt @@ -149,6 +149,8 @@ Prefix(p):: Limit the results to those projects that start with the specified prefix. + +The match is case sensitive. May not be used together with `m` or `r`. ++ List all projects that start with `platform/`: + .Request @@ -182,6 +184,8 @@ Boundary matchers '^' and '$' are implicit. For example: the regex 'test.*' will match any projects that start with 'test' and regex '.*test' will match any project that end with 'test'. + +The match is case sensitive. May not be used together with `m` or `p`. ++ List all projects that match regex `test.*project`: + .Request @@ -234,6 +238,8 @@ Query the second project in the project list: Substring(m):: Limit the results to those projects that match the specified substring. + +The match is case insensitive. May not be used together with `r` or `p`. ++ List all projects that match substring `test/`: + .Request diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ListProjectsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ListProjectsIT.java index e41d579f93..a31a34c1d5 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ListProjectsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ListProjectsIT.java @@ -112,6 +112,8 @@ public class ListProjectsIT extends AbstractDaemonTest { assertThatNameList(filter(gApi.projects().list().withPrefix(p).get())) .containsExactly(someOtherProject, someProject) .inOrder(); + p = name("SOME"); + assertThatNameList(filter(gApi.projects().list().withPrefix(p).get())).isEmpty(); } @Test @@ -161,6 +163,9 @@ public class ListProjectsIT extends AbstractDaemonTest { assertThatNameList(filter(gApi.projects().list().withSubstring("some").get())) .containsExactly(projectAwesome, someOtherProject, someProject) .inOrder(); + assertThatNameList(filter(gApi.projects().list().withSubstring("SOME").get())) + .containsExactly(projectAwesome, someOtherProject, someProject) + .inOrder(); } @Test