diff --git a/modules/api/src/test/ModTimelineTest.scala b/modules/api/src/test/ModTimelineTest.scala index 866e62a8372c7..71175c6622993 100644 --- a/modules/api/src/test/ModTimelineTest.scala +++ b/modules/api/src/test/ModTimelineTest.scala @@ -7,6 +7,7 @@ import lila.playban.TempBan class ModTimelineTest extends munit.FunSuite: import ModTimeline.* + import PublicLine.merge.sep val now = nowInstant @@ -24,18 +25,21 @@ class ModTimelineTest extends munit.FunSuite: assertEquals(aggregateEvents(Nil), Nil) test("public line merge"): - assertEquals(PublicLine.merge(l1, l1), l1.copy(text = "linguine|linguine").some) - assertEquals(PublicLine.merge(l1, l2), l1.copy(text = "linguine|fusilli").some) + assertEquals(PublicLine.merge(l1, l1), l1.some) + assertEquals(PublicLine.merge(l1, l2), l1.copy(text = s"linguine${sep}fusilli").some) assertEquals(PublicLine.merge(l2, l3), none) test("merge same line"): assertEquals(aggregateEvents(List(l1)), List(l1)) - assertEquals(aggregateEvents(List(l1, l1)), List(l1.copy(text = "linguine|linguine"))) + assertEquals(aggregateEvents(List(l1, l1)), List(l1)) test("merge same source lines"): - assertEquals(aggregateEvents(List(l1, l2)), List(l1.copy(text = "linguine|fusilli"))) - assertEquals(aggregateEvents(List(l2, l1)), List(l1.copy(text = "fusilli|linguine"))) - assertEquals(aggregateEvents(List(l1, l2, l1)), List(l1.copy(text = "linguine|fusilli|linguine"))) + assertEquals(aggregateEvents(List(l1, l2)), List(l1.copy(text = s"linguine${sep}fusilli"))) + assertEquals(aggregateEvents(List(l2, l1)), List(l1.copy(text = s"fusilli${sep}linguine"))) + assertEquals( + aggregateEvents(List(l1, l2, l1)), + List(l1.copy(text = s"linguine${sep}fusilli")) + ) test("merge different source lines"): assertEquals(aggregateEvents(List(l1, l3)), List(l1, l3)) @@ -44,21 +48,21 @@ class ModTimelineTest extends munit.FunSuite: test("merge consecutive lines"): assertEquals( aggregateEvents(List(l4, l1, l1, l2, l3)), - List(l4, l1.copy(text = "linguine|linguine|fusilli"), l3) + List(l4, l1.copy(text = s"linguine${sep}fusilli"), l3) ) assertEquals( aggregateEvents(List(l4, l5, l1, l2, l1, l3)), - List(l4.copy(text = "bucatini|rigatoni"), l1.copy(text = "linguine|fusilli|linguine"), l3) + List(l4.copy(text = s"bucatini${sep}rigatoni"), l1.copy(text = s"linguine${sep}fusilli"), l3) ) test("merge mixed lines"): assertEquals( aggregateEvents(List(l1, l4, l1)), - List(l1.copy(text = "linguine|linguine"), l4) + List(l1, l4) ) assertEquals( aggregateEvents(List(l1, l4, l2, l3, l5)), - List(l1.copy(text = "linguine|fusilli"), l4.copy(text = "bucatini|rigatoni"), l3) + List(l1.copy(text = s"linguine${sep}fusilli"), l4.copy(text = s"bucatini${sep}rigatoni"), l3) ) test("merge mixed events"): @@ -72,22 +76,22 @@ class ModTimelineTest extends munit.FunSuite: ) assertEquals( aggregateEvents(List(ban1, l1, l1)), - List(ban1, l1.copy(text = "linguine|linguine")) + List(ban1, l1) ) assertEquals( aggregateEvents(List(ban1, l1, l1, ban2)), - List(ban1, l1.copy(text = "linguine|linguine"), ban2) + List(ban1, l1, ban2) ) assertEquals( aggregateEvents(List(ban1, l1, l4, l1, ban2)), - List(ban1, l1.copy(text = "linguine|linguine"), l4, ban2) + List(ban1, l1, l4, ban2) ) assertEquals( aggregateEvents(List(l1, ban1, l4, ban2, l2, l3, l5, ban3, ban3)), List( - l1.copy(text = "linguine|fusilli"), + l1.copy(text = s"linguine${sep}fusilli"), ban1, - l4.copy(text = "bucatini|rigatoni"), + l4.copy(text = s"bucatini${sep}rigatoni"), ban2, l3, ban3, diff --git a/modules/shutup/src/main/PublicLine.scala b/modules/shutup/src/main/PublicLine.scala index c2a5bfd802c86..f983274ecf690 100644 --- a/modules/shutup/src/main/PublicLine.scala +++ b/modules/shutup/src/main/PublicLine.scala @@ -14,7 +14,7 @@ object PublicLine: given BSONHandler[PublicLine] = Macros.handler object merge: - private val sep = "_@_" + val sep = "_@_" def apply(prev: PublicLine, next: PublicLine): Option[PublicLine] = if prev.from != next.from then none else if split(prev.text).contains(next.text) then prev.some