Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ case class ArtifactSelection(
project.settings.defaultArtifact.contains(artifact.name),
// not deprecated
!project.settings.deprecatedArtifacts.contains(artifact.name),
// project repository (ex: shapeless)
project.repository.value == artifact.name.value,
// project repository (ex: shapeless) - case insensitive
project.repository.value.equalsIgnoreCase(artifact.name.value),
// alphabetically
artifact.name,
artifact.name.value.toLowerCase,
// stable version first
project.settings.preferStableVersion && !artifact.version.isStable,
artifact.version,
Expand All @@ -31,7 +31,7 @@ case class ArtifactSelection(
Ordering[Boolean],
Ordering[Boolean],
Ordering[Boolean],
Ordering[Artifact.Name].reverse,
Ordering[String].reverse,
Ordering[Boolean].reverse,
Ordering[Version],
Ordering[BinaryVersion]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package scaladex.core.model

import scaladex.core.model.Artifact.*

import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers

class ArtifactSelectionTests extends AnyFunSpec with Matchers:

describe("ArtifactSelection") {

it("selects the artifact matching the repository name ignoring case") {

val projectRef = Project.Reference.from("ScalaFX", "ScalaFX")
val project = Project.default(projectRef)

val oldArtifact =
Artifact.Reference(
GroupId("org.scalafx"),
ArtifactId("ScalaFX"),
Version("8.0.0")
)

val currentArtifact =
Artifact.Reference(
GroupId("org.scalafx"),
ArtifactId("scalafx"),
Version("14.0.0")
)

val result =
ArtifactSelection(None, None)
.filterArtifacts(Seq(oldArtifact, currentArtifact), project)

result.head.name.value shouldBe "scalafx"
result.head.version.toString shouldBe "14.0.0"
}
}

end ArtifactSelectionTests