Return proper error message if 'ext' operator is not supported by schema version
Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I4b6711feb9274664ef8ee1ed07858a29e60cbad2
This commit is contained in:
@@ -735,13 +735,16 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
}
|
||||
|
||||
@Operator
|
||||
public Predicate<ChangeData> ext(String ext) {
|
||||
public Predicate<ChangeData> ext(String ext) throws QueryParseException {
|
||||
return extension(ext);
|
||||
}
|
||||
|
||||
@Operator
|
||||
public Predicate<ChangeData> extension(String ext) {
|
||||
return new FileExtensionPredicate(ext);
|
||||
public Predicate<ChangeData> extension(String ext) throws QueryParseException {
|
||||
if (args.getSchema().hasField(ChangeField.EXTENSION)) {
|
||||
return new FileExtensionPredicate(ext);
|
||||
}
|
||||
throw new QueryParseException("'extension' operator is not supported by change index version");
|
||||
}
|
||||
|
||||
@Operator
|
||||
|
||||
@@ -1366,7 +1366,14 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
|
||||
@Test
|
||||
public void byExtension() throws Exception {
|
||||
assume().that(getSchema().hasField(ChangeField.EXTENSION)).isTrue();
|
||||
if (getSchemaVersion() < 52) {
|
||||
assertMissingField(ChangeField.EXTENSION);
|
||||
String unsupportedOperatorMsg =
|
||||
"'extension' operator is not supported by change index version";
|
||||
assertFailingQuery("extension:txt", unsupportedOperatorMsg);
|
||||
assertFailingQuery("ext:txt", unsupportedOperatorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
Change change1 = insert(repo, newChangeWithFiles(repo, "foo.h", "foo.cc"));
|
||||
|
||||
Reference in New Issue
Block a user