@@ -4,20 +4,38 @@ import cats.data.NonEmptyList
44import cats .implicits .catsSyntaxOptionId
55import munit .FunSuite
66import org .scalasteward .core .TestSyntax .*
7+ import org .scalasteward .core .edit .update .data .Substring
8+ import org .scalasteward .core .edit .update .data .Substring .Position
9+ import org .scalasteward .core .nurture .UpdatesForGivenEdit
710import org .scalasteward .core .repoconfig .{PullRequestGroup , PullRequestUpdateFilter }
811
912class GroupedUpdateTest extends FunSuite {
10- val updateSingleSpecs2Core : Update .ForArtifactId =
13+ def stubReplacementFor (u : Update .ForArtifactId ): Substring .Replacement = Substring .Replacement (
14+ Position (" build.sbt" , u.artifactForUpdate.hashCode(), u.currentVersion.value),
15+ u.nextVersion.value
16+ )
17+
18+ private def stubEditFor (single : Update .ForArtifactId ) = UpdatesForGivenEdit (
19+ List (stubReplacementFor(single)),
20+ single.artifactsForUpdate,
21+ single.nextVersion
22+ )
23+
24+ def stubFoo (updates : UpdatesForGivenEdit * ): List [Update .ForArtifactId ] =
25+ updates.flatMap(_.asUpdatesForArtifactId.toList).toList
26+
27+ val updateSingleSpecs2Core = stubEditFor(
1128 (" org.specs2" .g % " specs2-core" .a % " 3.9.3" %> " 3.9.5" ).single
29+ )
1230
13- val updateSingleSpecs2Scalacheck : Update . ForArtifactId =
14- ( " org.specs2" .g % " specs2-scalacheck" .a % " 3.9.3" %> " 3.9.5" ).single
31+ val updateSingleSpecs2Scalacheck =
32+ stubEditFor(( " org.specs2" .g % " specs2-scalacheck" .a % " 3.9.3" %> " 3.9.5" ).single)
1533
16- val updateSingleTypelevelAlgebra : Update . ForArtifactId =
17- ( " org.typelevel" .g % " algebra" .a % " 2.1.1" %> " 2.2.0" ).single
34+ val updateSingleTypelevelAlgebra =
35+ stubEditFor(( " org.typelevel" .g % " algebra" .a % " 2.1.1" %> " 2.2.0" ).single)
1836
19- val updateSingleCirceCore : Update . ForArtifactId =
20- ( " circe" .g % " core" .a % " 1.4.2" %> " 1.5.0" ).single
37+ val updateSingleCirceCore =
38+ stubEditFor(( " circe" .g % " core" .a % " 1.4.2" %> " 1.5.0" ).single)
2139
2240 test(
2341 " GroupedUpdate.from: Do not group a Update.Single if the groupId does not match the filter"
@@ -76,7 +94,7 @@ class GroupedUpdateTest extends FunSuite {
7694 assertEquals(
7795 grouped,
7896 List (
79- Update .Grouped (" typelevel" , Some (" update typelevel" ), List (updateSingleTypelevelAlgebra))
97+ Update .Grouped (" typelevel" , Some (" update typelevel" ), stubFoo (updateSingleTypelevelAlgebra))
8098 )
8199 )
82100 assertEquals(notGrouped, List .empty)
@@ -103,7 +121,9 @@ class GroupedUpdateTest extends FunSuite {
103121 Update .Grouped (
104122 " specs2" ,
105123 Some (" update specs2" ),
106- List (updateSingleSpecs2Core, updateSingleSpecs2Scalacheck)
124+ List (updateSingleSpecs2Core, updateSingleSpecs2Scalacheck).flatMap(
125+ _.asUpdatesForArtifactId.toList
126+ )
107127 )
108128 )
109129 )
@@ -143,9 +163,15 @@ class GroupedUpdateTest extends FunSuite {
143163 Update .Grouped (
144164 " specs2" ,
145165 Some (" update specs2" ),
146- List (updateSingleSpecs2Core, updateSingleSpecs2Scalacheck)
166+ List (updateSingleSpecs2Core, updateSingleSpecs2Scalacheck).flatMap(
167+ _.asUpdatesForArtifactId.toList
168+ )
147169 ),
148- Update .Grouped (" typelevel" , Some (" update typelevel" ), List (updateSingleTypelevelAlgebra))
170+ Update .Grouped (
171+ " typelevel" ,
172+ Some (" update typelevel" ),
173+ List (updateSingleTypelevelAlgebra).flatMap(_.asUpdatesForArtifactId.toList)
174+ )
149175 )
150176 )
151177 assertEquals(notGrouped, List (updateSingleCirceCore))
@@ -174,7 +200,7 @@ class GroupedUpdateTest extends FunSuite {
174200 Update .Grouped (
175201 " org" ,
176202 Some (" update org" ),
177- List (updateSingleSpecs2Core, updateSingleSpecs2Scalacheck, updateSingleTypelevelAlgebra)
203+ stubFoo (updateSingleSpecs2Core, updateSingleSpecs2Scalacheck, updateSingleTypelevelAlgebra)
178204 )
179205 )
180206 )
@@ -203,7 +229,7 @@ class GroupedUpdateTest extends FunSuite {
203229 Update .Grouped (
204230 " all wildcard" ,
205231 Some (" update all wildcard" ),
206- List (
232+ stubFoo (
207233 updateSingleTypelevelAlgebra,
208234 updateSingleSpecs2Core,
209235 updateSingleSpecs2Scalacheck
@@ -233,7 +259,7 @@ class GroupedUpdateTest extends FunSuite {
233259 Update .Grouped (
234260 " specs2 core" ,
235261 Some (" update specs2 core" ),
236- List (updateSingleSpecs2Core)
262+ stubFoo (updateSingleSpecs2Core)
237263 )
238264 )
239265 )
@@ -262,7 +288,7 @@ class GroupedUpdateTest extends FunSuite {
262288 Update .Grouped (
263289 " specs2 core" ,
264290 Some (" update specs2 core" ),
265- List (updateSingleSpecs2Core)
291+ stubFoo (updateSingleSpecs2Core)
266292 )
267293 )
268294 )
@@ -315,7 +341,7 @@ class GroupedUpdateTest extends FunSuite {
315341 Update .Grouped (
316342 " specs2" ,
317343 Some (" update specs2" ),
318- List (updateSingleSpecs2Scalacheck, updateSingleSpecs2Core)
344+ stubFoo (updateSingleSpecs2Scalacheck, updateSingleSpecs2Core)
319345 )
320346 )
321347 )
@@ -345,7 +371,7 @@ class GroupedUpdateTest extends FunSuite {
345371 Update .Grouped (
346372 " specs2" ,
347373 Some (" update specs2" ),
348- List (updateSingleSpecs2Scalacheck, updateSingleSpecs2Core)
374+ stubFoo (updateSingleSpecs2Scalacheck, updateSingleSpecs2Core)
349375 )
350376 )
351377 )
0 commit comments