Set explicit project when creating test changes
AlreadyApprovedByCopyConditionIT created changes without binding them to
the project under test, so individual tests could accidentally operate
on an arbitrary project and become flaky or misleading.
Specify the current `project` for each `newChange()` to ensure changes
are always created in the expected repository.
Change-Id: I87b988aae60a6dae6be5fc1845e06257ff057578
diff --git a/owners/src/test/java/com/googlesource/gerrit/owners/AlreadyApprovedByCopyConditionIT.java b/owners/src/test/java/com/googlesource/gerrit/owners/AlreadyApprovedByCopyConditionIT.java
index 0e2ea6e..73d2d3c 100644
--- a/owners/src/test/java/com/googlesource/gerrit/owners/AlreadyApprovedByCopyConditionIT.java
+++ b/owners/src/test/java/com/googlesource/gerrit/owners/AlreadyApprovedByCopyConditionIT.java
@@ -88,6 +88,7 @@
Change.Id changeId =
changeOperations
.newChange()
+ .project(project)
.file(FRONTEND_OWNED_FILE)
.content("some frontend change")
.create();
@@ -112,6 +113,7 @@
Change.Id changeId =
changeOperations
.newChange()
+ .project(project)
.file(FILE_WITH_NO_OWNERS)
.content("file with no owners")
.create();
@@ -135,6 +137,7 @@
Change.Id changeId =
changeOperations
.newChange()
+ .project(project)
.file(FILE_WITH_NO_OWNERS)
.content("file with no owners")
.create();
@@ -156,7 +159,12 @@
@Test
public void shouldNotCopyApprovalWhenOwnedFileIsDeleted() throws Exception {
Change.Id changeId =
- changeOperations.newChange().file(BACKEND_OWNED_FILE).content("java content").create();
+ changeOperations
+ .newChange()
+ .project(project)
+ .file(BACKEND_OWNED_FILE)
+ .content("java content")
+ .create();
vote(BACKEND_FILES_OWNER, changeId.toString(), 2);
@@ -170,7 +178,12 @@
@Test
public void shouldNotCopyApprovalWhenOwnedFileIsRenamedToOwnedFile() throws Exception {
Change.Id changeId =
- changeOperations.newChange().file(BACKEND_OWNED_FILE).content("java content").create();
+ changeOperations
+ .newChange()
+ .project(project)
+ .file(BACKEND_OWNED_FILE)
+ .content("java content")
+ .create();
vote(BACKEND_FILES_OWNER, changeId.toString(), 2);
@@ -189,7 +202,12 @@
@Test
public void shouldNotCopyApprovalWhenOwnedFileIsRenamedToNonOwnedFile() throws Exception {
Change.Id changeId =
- changeOperations.newChange().file(BACKEND_OWNED_FILE).content("java content").create();
+ changeOperations
+ .newChange()
+ .project(project)
+ .file(BACKEND_OWNED_FILE)
+ .content("java content")
+ .create();
vote(BACKEND_FILES_OWNER, changeId.toString(), 2);