AbstractQueryChangesTest: Add test coverage for the tr: and bug: queries

Bug: Issue 8604
Change-Id: I42a85e06a1d83ab61fbcf8e4f3a7edb8f7a55517
This commit is contained in:
David Pursehouse
2018-04-12 22:32:01 +09:00
parent d552864bb6
commit ad4bc4991c

View File

@@ -137,6 +137,12 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
public static Config defaultConfig() {
Config cfg = new Config();
cfg.setInt("index", null, "maxPages", 10);
cfg.setString("trackingid", "query-bug", "footer", "Bug:");
cfg.setString("trackingid", "query-bug", "match", "QUERY\\d{2,8}");
cfg.setString("trackingid", "query-bug", "system", "querytests");
cfg.setString("trackingid", "query-feature", "footer", "Feature");
cfg.setString("trackingid", "query-feature", "match", "QUERY\\d{2,8}");
cfg.setString("trackingid", "query-feature", "system", "querytests");
return cfg;
}
@@ -1976,6 +1982,28 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
assertQuery("watchedby:self", change1);
}
@Test
public void trackingid() throws Exception {
TestRepository<Repo> repo = createProject("repo");
RevCommit commit1 =
repo.parseBody(repo.commit().message("Change one\n\nBug:QUERY123").create());
Change change1 = insert(repo, newChangeForCommit(repo, commit1));
RevCommit commit2 =
repo.parseBody(repo.commit().message("Change two\n\nFeature:QUERY456").create());
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
assertQuery("tr:QUERY123", change1);
assertQuery("bug:QUERY123", change1);
assertQuery("tr:QUERY456", change2);
assertQuery("bug:QUERY456", change2);
assertQuery("tr:QUERY-123");
assertQuery("bug:QUERY-123");
assertQuery("tr:QUERY12");
assertQuery("bug:QUERY12");
assertQuery("tr:QUERY789");
assertQuery("bug:QUERY789");
}
protected ChangeInserter newChange(TestRepository<Repo> repo) throws Exception {
return newChange(repo, null, null, null, null);
}