@@ -7,6 +7,7 @@ import org.scalasteward.core.TestSyntax._
7
7
import org .scalasteward .core .data .{RepoData , Update }
8
8
import org .scalasteward .core .mock .MockContext .context ._
9
9
import org .scalasteward .core .mock .MockState
10
+ import org .scalasteward .core .mock .MockState .TraceEntry
10
11
import org .scalasteward .core .repoconfig .RepoConfig
11
12
import org .scalasteward .core .scalafmt .scalafmtConfName
12
13
import org .scalasteward .core .util .Nel
@@ -911,6 +912,46 @@ class RewriteTest extends FunSuite {
911
912
runApplyUpdate(update, original, expected)
912
913
}
913
914
915
+ // Sketchy placeholder bI'm not sure how else to assert on the presence/absence of a log.
916
+ private val terribleMutableLogBufferDoNotMergeThis =
917
+ scala.collection.mutable.ListBuffer .empty[String ]
918
+
919
+ test(" issue ..." ) {
920
+ val update1 = (" com.foo" .g % " library-1" .a % " 1.2.3" %> " 1.3.0" ).single
921
+ val update2 = (" com.foo" .g % " library-2" .a % " 1.2.3" %> " 1.3.0" ).single
922
+ val original = Map (
923
+ " build.sbt" ->
924
+ """
925
+ |val FooLibraryVersion = "1.2.3"
926
+ |libraryDependencies ++= Seq(
927
+ | "com.foo" %% "library-1" % FooLibraryVersion,
928
+ | "com.foo" %% "library-2" % FooLibraryVersion
929
+ |)
930
+ |""" .stripMargin
931
+ )
932
+ val expected = Map (
933
+ " build.sbt" ->
934
+ """
935
+ |val FooLibraryVersion = "1.3.0"
936
+ |libraryDependencies ++= Seq(
937
+ | "com.foo" %% "library-1" % FooLibraryVersion,
938
+ | "com.foo" %% "library-2" % FooLibraryVersion
939
+ |)
940
+ |""" .stripMargin
941
+ )
942
+
943
+ runApplyUpdate(update1, original, expected)
944
+ require(
945
+ ! terribleMutableLogBufferDoNotMergeThis.exists(_.startsWith(" Unable to bump version" ))
946
+ )
947
+
948
+ // The second update prints a misleading warning.
949
+ runApplyUpdate(update2, expected, expected)
950
+ require(
951
+ terribleMutableLogBufferDoNotMergeThis.last == " Unable to bump version for update com.foo:library-2 : 1.2.3 -> 1.3.0"
952
+ )
953
+ }
954
+
914
955
private def runApplyUpdate (
915
956
update : Update .Single ,
916
957
files : Map [String , String ],
@@ -924,6 +965,12 @@ class RewriteTest extends FunSuite {
924
965
.addFiles(filesInRepoDir.toSeq: _* )
925
966
.flatMap(editAlg.applyUpdate(data, update).runS)
926
967
.unsafeRunSync()
968
+ terribleMutableLogBufferDoNotMergeThis.clear()
969
+ state.trace.foreach {
970
+ case l : TraceEntry .Log =>
971
+ terribleMutableLogBufferDoNotMergeThis += l.log._2
972
+ case _ => ()
973
+ }
927
974
val obtained = state.files
928
975
.map { case (file, content) => file.toString.replace(repoDir.toString + " /" , " " ) -> content }
929
976
assertEquals(obtained, expected)
0 commit comments