-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
23 deletions.
There are no files selected for viewing
62 changes: 39 additions & 23 deletions
62
modules/core/src/test/scala/org/scalasteward/core/buildtool/maven/MavenAlgTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,54 @@ | ||
package org.scalasteward.core.buildtool.maven | ||
|
||
import cats.effect.unsafe.implicits.global | ||
import munit.FunSuite | ||
import munit.CatsEffectSuite | ||
import org.scalasteward.core.TestSyntax._ | ||
import org.scalasteward.core.buildtool.BuildRoot | ||
import org.scalasteward.core.data.Repo | ||
import org.scalasteward.core.data.Resolver.MavenRepository | ||
import org.scalasteward.core.data.{Repo, Scope} | ||
import org.scalasteward.core.mock.MockContext.context._ | ||
import org.scalasteward.core.mock.MockState | ||
import org.scalasteward.core.mock.MockState.TraceEntry.Cmd | ||
|
||
class MavenAlgTest extends FunSuite { | ||
class MavenAlgTest extends CatsEffectSuite { | ||
test("getDependencies") { | ||
val repo = Repo("namespace", "repo-name") | ||
val repo = Repo("maven-alg", "test-1") | ||
val buildRoot = BuildRoot(repo, ".") | ||
val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync() | ||
|
||
val state = mavenAlg.getDependencies(buildRoot).runS(MockState.empty).unsafeRunSync() | ||
val expected = MockState.empty.copy( | ||
trace = Vector( | ||
Cmd.execSandboxed( | ||
repoDir, | ||
"mvn", | ||
args.batchMode, | ||
command.listDependencies, | ||
args.excludeTransitive | ||
), | ||
Cmd.execSandboxed( | ||
repoDir, | ||
"mvn", | ||
args.batchMode, | ||
command.listRepositories | ||
) | ||
val obtained = MockState.empty | ||
.copy(execCommands = true) | ||
.addFiles( | ||
repoDir / "pom.xml" -> | ||
"""|<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <groupId>com.mycompany.app</groupId> | ||
| <artifactId>my-app</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.typelevel</groupId> | ||
| <artifactId>cats-effect_2.13</artifactId> | ||
| <version>3.5.2</version> | ||
| </dependency> | ||
| </dependencies> | ||
| <repositories> | ||
| <repository> | ||
| <id>central</id> | ||
| <url>https://repo1.maven.org/maven2/</url> | ||
| </repository> | ||
| </repositories> | ||
|</project> | ||
|""".stripMargin | ||
) | ||
.flatMap(mavenAlg.getDependencies(buildRoot).runA) | ||
|
||
val expected = List( | ||
Scope( | ||
List("org.typelevel".g % ("cats-effect", "cats-effect_2.13").a % "3.5.2"), | ||
List(MavenRepository("central", "https://repo1.maven.org/maven2/", None, Nil)) | ||
) | ||
) | ||
|
||
assertEquals(state, expected) | ||
assertIO(obtained, expected) | ||
} | ||
} |