Skip to content

Commit

Permalink
Fix more
Browse files Browse the repository at this point in the history
  • Loading branch information
fthomas committed Jan 5, 2025
1 parent c961f01 commit 78386c5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 32 deletions.
34 changes: 17 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -199,28 +199,28 @@ lazy val core = myCrossProject("core")
BuildInfoKey("millPluginVersion" -> Dependencies.scalaStewardMillPlugin.revision)
),
buildInfoPackage := moduleRootPkg.value,
initialCommands += s"""
import ${moduleRootPkg.value}._
import ${moduleRootPkg.value}.data._
import ${moduleRootPkg.value}.util._
import better.files.File
import cats.effect.IO
import org.http4s.client.Client
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger

implicit val logger: Logger[IO] = Slf4jLogger.getLogger[IO]
""",
initialCommands +=
s"""|import ${moduleRootPkg.value}._
|import ${moduleRootPkg.value}.data._
|import ${moduleRootPkg.value}.util._
|import better.files.File
|import cats.effect.IO
|import org.http4s.client.Client
|import org.typelevel.log4cats.Logger
|import org.typelevel.log4cats.slf4j.Slf4jLogger
|
|implicit val logger: Logger[IO] = Slf4jLogger.getLogger[IO]
|""".stripMargin,
// Inspired by https://stackoverflow.com/a/41978937/460387
Test / sourceGenerators += Def.task {
val file = (Test / sourceManaged).value / "InitialCommandsTest.scala"
val content =
s"""object InitialCommandsTest {
| ${initialCommands.value}
| // prevent warnings
| intellijThisImportIsUsed(Client); intellijThisImportIsUsed(File);
| intellijThisImportIsUsed(Nel); intellijThisImportIsUsed(Repo);
| intellijThisImportIsUsed(Main);
|${initialCommands.value}
|// prevent warnings
|intellijThisImportIsUsed(Client); intellijThisImportIsUsed(File);
|intellijThisImportIsUsed(Nel); intellijThisImportIsUsed(Repo);
|intellijThisImportIsUsed(Main);
|}""".stripMargin
IO.write(file, content)
Seq(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.scalasteward.core.buildtool.maven.pomXmlName
import org.scalasteward.core.buildtool.mill.MillAlg
import org.scalasteward.core.buildtool.sbt.buildPropertiesName
import org.scalasteward.core.data.{GroupId, Update}
import org.scalasteward.core.repoconfig.UpdatesConfig.defaultLimit
import org.scalasteward.core.scalafmt.scalafmtConfName
import org.scalasteward.core.update.FilterAlg.{
FilterResult,
Expand All @@ -42,7 +41,7 @@ final case class UpdatesConfig(
private val allowPreReleases: Option[List[UpdatePattern]] = None,
private val ignore: Option[List[UpdatePattern]] = None,
private val retracted: Option[List[RetractedArtifact]] = None,
limit: Option[NonNegInt] = defaultLimit,
limit: Option[NonNegInt] = UpdatesConfig.defaultLimit,
private val fileExtensions: Option[List[String]] = None
) {
private[repoconfig] def pinOrDefault: List[UpdatePattern] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.scalasteward.core.mock.MockContext.context.{
scalafixMigrationsLoader
}
import org.scalasteward.core.mock.MockContext.mockState
import org.scalasteward.core.mock.MockEffOps
import org.scalasteward.core.repoconfig.RepoConfigLoader
import org.scalasteward.core.update.artifact.ArtifactMigrationsLoader
import scala.util.{Failure, Success, Try}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.scalasteward.core.client

import cats.effect._
import cats.implicits._
import eu.timepit.refined.auto._
import eu.timepit.refined.types.numeric.PosInt
import munit.CatsEffectSuite
import org.http4s.HttpRoutes
Expand Down Expand Up @@ -116,12 +115,12 @@ class ClientConfigurationTest extends CatsEffectSuite {
retryAfter(initialClient)
}

val notEnoughRetries = clientWithMaxAttempts(1)
val notEnoughRetries = clientWithMaxAttempts(PosInt.unsafeFrom(1))
.run(GET(uri"/retry-after"))
.use(r => r.status.code.pure[IO])
.assertEquals(403)

val exactlyEnoughRetries = clientWithMaxAttempts(2)
val exactlyEnoughRetries = clientWithMaxAttempts(PosInt.unsafeFrom(2))
.run(GET(uri"/retry-after"))
.use(r => r.status.code.pure[IO])
.assertEquals(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ class VersionTest extends DisciplineSuite {
}

test("Component: round-trip") {
forAll { str: String => assertEquals(Component.render(Component.parse(str)), str) }
forAll { (str: String) => assertEquals(Component.render(Component.parse(str)), str) }
}

test("Component: round-trip using Version") {
forAll { v: Version => assertEquals(Component.render(Component.parse(v.value)), v.value) }
forAll { (v: Version) => assertEquals(Component.render(Component.parse(v.value)), v.value) }
}

test("Component: round-trip example") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import org.scalasteward.core.update.show
class gitTest extends ScalaCheckSuite {
test("commitMsgFor should work with static message") {
val commitsConfig = CommitsConfig(Some("Static message"))
forAll { update: Update.Single =>
forAll { (update: Update.Single) =>
assertEquals(commitMsgFor(update, commitsConfig, None).title, "Static message")
}
}

test("commitMsgFor adds branch if provided") {
val commitsConfig = CommitsConfig(Some(s"$${default}"))
val branch = Branch("some-branch")
forAll { update: Update.Single =>
forAll { (update: Update.Single) =>
val expected = s"Update ${show.oneLiner(update)} to ${update.nextVersion} in ${branch.name}"
assertEquals(commitMsgFor(update, commitsConfig, Some(branch)).title, expected)
}
}

test("commitMsgFor should work with default message") {
val commitsConfig = CommitsConfig(Some(s"$${default}"))
forAll { update: Update.Single =>
forAll { (update: Update.Single) =>
val expected = s"Update ${show.oneLiner(update)} to ${update.nextVersion}"
assertEquals(commitMsgFor(update, commitsConfig, None).title, expected)
}
Expand All @@ -35,7 +35,7 @@ class gitTest extends ScalaCheckSuite {
test("commitMsgFor should work with templated message") {
val commitsConfig =
CommitsConfig(Some(s"Update $${artifactName} from $${currentVersion} to $${nextVersion}"))
forAll { update: Update.Single =>
forAll { (update: Update.Single) =>
val expected =
s"Update ${show.oneLiner(update)} from ${update.currentVersion} to ${update.nextVersion}"
assertEquals(commitMsgFor(update, commitsConfig, None).title, expected)
Expand All @@ -50,7 +50,7 @@ class gitTest extends ScalaCheckSuite {
)
)
val branch = Branch("some-branch")
forAll { update: Update.Single =>
forAll { (update: Update.Single) =>
val expected =
s"Update ${show.oneLiner(update)} from ${update.currentVersion} to ${update.nextVersion} in ${branch.name}"
assertEquals(commitMsgFor(update, commitsConfig, Some(branch)).title, expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class stringTest extends ScalaCheckSuite {
}

test("longestCommonPrefixGreater") {
assertEquals(string.longestCommonPrefixGreater[1](Nel.of("abcde", "abchk")).get.value, "abc")
assertEquals(string.longestCommonPrefixGreater[3](Nel.of("abcde", "abchk")).get.value, "abc")
assertEquals(string.longestCommonPrefixGreater[3](Nel.of("abcde", "abhk")), None)
assertEquals(string.longestCommonPrefixGreater(Nel.of("abcde", "abchk"), 0), Some("abc"))
assertEquals(string.longestCommonPrefixGreater(Nel.of("abcde", "abchk"), 2), Some("abc"))
assertEquals(string.longestCommonPrefixGreater(Nel.of("abcde", "abhk"), 2), None)
}

test("rightmostLabel") {
Expand Down

0 comments on commit 78386c5

Please sign in to comment.