~jan0sch/smederee

Showing details for patch 021e84fa938d5adfd49aff91a133487c3a9b445e.
2023-06-17 (Sat), 4:45 PM - Jens Grassel - 021e84fa938d5adfd49aff91a133487c3a9b445e

Generators: Reduce unable to generate data samples issues.

Summary of changes
2 files modified with 12 lines added and 2 lines removed
  • modules/hub/src/test/scala/de/smederee/hub/Generators.scala with 6 added and 1 removed lines
  • modules/tickets/src/test/scala/de/smederee/tickets/Generators.scala with 6 added and 1 removed lines
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala	2025-01-16 02:46:07.773676091 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala	2025-01-16 02:46:07.777676101 +0000
@@ -121,7 +121,12 @@
 
   val genValidAccounts: Gen[List[Account]] = Gen
     .nonEmptyListOf(genValidAccount)
-    .suchThat(accounts => accounts.size === accounts.map(_.name).distinct.size) // Ensure unique names.
+    .map(_.foldLeft(List.empty[Account]) { (acc, a) =>
+      if (acc.exists(_.name === a.name))
+        acc
+      else
+        a :: acc
+    }) // Ensure distinct user names.
 
   val genValidSession: Gen[Session] =
     for {
diff -rN -u old-smederee/modules/tickets/src/test/scala/de/smederee/tickets/Generators.scala new-smederee/modules/tickets/src/test/scala/de/smederee/tickets/Generators.scala
--- old-smederee/modules/tickets/src/test/scala/de/smederee/tickets/Generators.scala	2025-01-16 02:46:07.773676091 +0000
+++ new-smederee/modules/tickets/src/test/scala/de/smederee/tickets/Generators.scala	2025-01-16 02:46:07.777676101 +0000
@@ -165,7 +165,12 @@
 
   val genProjectOwners: Gen[List[ProjectOwner]] = Gen
     .nonEmptyListOf(genProjectOwner)
-    .suchThat(owners => owners.size === owners.map(_.name).distinct.size) // Ensure unique names.
+    .map(_.foldLeft(List.empty[ProjectOwner]) { (acc, a) =>
+      if (acc.exists(_.name === a.name))
+        acc
+      else
+        a :: acc
+    }) // Ensure distinct user names.
 
   val genLabelName: Gen[LabelName] =
     Gen.nonEmptyListOf(Gen.alphaNumChar).map(_.take(LabelName.MaxLength).mkString).map(LabelName.apply)