ChangeBundle: Ignore null originalSubject in ReviewDb changes
Original subject is a nullable field added relatively recently, so there are many changes that don't have it set. In NoteDb we reconstruct this by looking at the patch set commit, so it is always present. Don't consider this a difference between ReviewDb and NoteDb. Change-Id: I143430fed2da531806f2b8dcc17465f827df80d7
This commit is contained in:
@@ -181,6 +181,51 @@ public class ChangeBundleTest {
|
||||
assertDiffs(b3, b1, msg);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffChangesIgnoresNullOriginalSubjectInReviewDb()
|
||||
throws Exception {
|
||||
Change c1 = TestChanges.newChange(
|
||||
new Project.NameKey("project"), new Account.Id(100));
|
||||
c1.setCurrentPatchSet(c1.currentPatchSetId(), "Subject", null);
|
||||
Change c2 = clone(c1);
|
||||
c2.setCurrentPatchSet(
|
||||
c2.currentPatchSetId(), c1.getSubject(), "Original subject");
|
||||
|
||||
// Both ReviewDb, exact match required.
|
||||
ChangeBundle b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(),
|
||||
comments(), REVIEW_DB);
|
||||
ChangeBundle b2 = new ChangeBundle(c2, messages(), patchSets(), approvals(),
|
||||
comments(), REVIEW_DB);
|
||||
assertDiffs(b1, b2,
|
||||
"originalSubject differs for Change.Id " + c1.getId() + ":"
|
||||
+ " {null} != {Original subject}");
|
||||
|
||||
// Both NoteDb, exact match required.
|
||||
b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(), comments(),
|
||||
NOTE_DB);
|
||||
b2 = new ChangeBundle(c2, messages(), patchSets(), approvals(), comments(),
|
||||
NOTE_DB);
|
||||
assertDiffs(b1, b2,
|
||||
"originalSubject differs for Change.Id " + c1.getId() + ":"
|
||||
+ " {null} != {Original subject}");
|
||||
|
||||
// Original subject ignored if ReviewDb has null value.
|
||||
b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(), comments(),
|
||||
REVIEW_DB);
|
||||
b2 = new ChangeBundle(c2, messages(), patchSets(), approvals(), comments(),
|
||||
NOTE_DB);
|
||||
assertNoDiffs(b1, b2);
|
||||
|
||||
// Exact match still required if NoteDb has null value (not realistic).
|
||||
b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(), comments(),
|
||||
NOTE_DB);
|
||||
b2 = new ChangeBundle(c2, messages(), patchSets(), approvals(), comments(),
|
||||
REVIEW_DB);
|
||||
assertDiffs(b1, b2,
|
||||
"originalSubject differs for Change.Id " + c1.getId() + ":"
|
||||
+ " {null} != {Original subject}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffChangeMessageKeySets() throws Exception {
|
||||
Change c = TestChanges.newChange(project, accountId);
|
||||
|
Reference in New Issue
Block a user