Minor refacto in tests

This commit is contained in:
Alexandre Archambault 2017-06-15 15:42:33 +02:00
parent ab9341ac9b
commit 615c9821b3
5 changed files with 34 additions and 34 deletions

View File

@ -28,7 +28,7 @@ object DirectoryListingTests extends TestSuite {
module,
version,
"jar",
extraRepo = Some(withListingRepo)
extraRepos = Seq(withListingRepo)
) {
artifacts =>
assert(artifacts.length == 1)
@ -38,7 +38,7 @@ object DirectoryListingTests extends TestSuite {
module,
version,
"jar-foo",
extraRepo = Some(withListingRepo)
extraRepos = Seq(withListingRepo)
) {
artifacts =>
assert(artifacts.length == 1)
@ -50,7 +50,7 @@ object DirectoryListingTests extends TestSuite {
module,
version,
"jar",
extraRepo = Some(withoutListingRepo)
extraRepos = Seq(withoutListingRepo)
) {
artifacts =>
assert(artifacts.length == 1)
@ -60,7 +60,7 @@ object DirectoryListingTests extends TestSuite {
module,
version,
"jar-foo",
extraRepo = Some(withoutListingRepo)
extraRepos = Seq(withoutListingRepo)
) {
artifacts =>
assert(artifacts.length == 0)

View File

@ -14,19 +14,19 @@ object IvyLocalTests extends TestSuite {
val module = Module("io.get-coursier", "coursier_2.11")
val version = coursier.util.Properties.version
val extraRepo = Some(Cache.ivy2Local)
val extraRepos = Seq(Cache.ivy2Local)
// Assuming this module (and the sub-projects it depends on) is published locally
'resolution - CentralTests.resolutionCheck(
module, version,
extraRepo
extraRepos
)
'uniqueArtifacts - async {
val res = await(CentralTests.resolve(
Set(Dependency(Module("io.get-coursier", "coursier-cli_2.11"), version, transitive = false)),
extraRepo = extraRepo
extraRepos = extraRepos
))
val artifacts = res.dependencyClassifiersArtifacts(Seq("standalone"))
@ -43,7 +43,7 @@ object IvyLocalTests extends TestSuite {
'javadocSources - async {
val res = await(CentralTests.resolve(
Set(Dependency(module, version)),
extraRepo = extraRepo
extraRepos = extraRepos
))
val artifacts = res.dependencyArtifacts.filter(_._2.`type` == "jar").map(_._2.url)

View File

@ -25,7 +25,7 @@ object IvyTests extends TestSuite {
"org.scala-js", "sbt-scalajs", Map("sbtVersion" -> "0.13", "scalaVersion" -> "2.10")
),
version = "0.6.6",
extraRepo = Some(sbtRepo),
extraRepos = Seq(sbtRepo),
configuration = "default(compile)"
)
}
@ -43,10 +43,10 @@ object IvyTests extends TestSuite {
* - CentralTests.resolutionCheck(
module = mod,
version = ver,
extraRepo = Some(sbtRepo)
extraRepos = Seq(sbtRepo)
)
* - CentralTests.withArtifact(mod, ver, "jar", extraRepo = Some(sbtRepo)) { artifact =>
* - CentralTests.withArtifact(mod, ver, "jar", extraRepos = Seq(sbtRepo)) { artifact =>
assert(artifact.url == expectedArtifactUrl)
}
}
@ -73,7 +73,7 @@ object IvyTests extends TestSuite {
* - CentralTests.withArtifacts(
dep = dep,
artifactType = "jar",
extraRepo = Some(repo),
extraRepos = Seq(repo),
classifierOpt = None
) {
case Seq(artifact) =>
@ -85,7 +85,7 @@ object IvyTests extends TestSuite {
* - CentralTests.withArtifacts(
dep = dep.copy(configuration = "test"),
artifactType = "jar",
extraRepo = Some(repo),
extraRepos = Seq(repo),
classifierOpt = None
) {
case Seq(artifact1, artifact2) =>

View File

@ -28,7 +28,7 @@ object MavenTests extends TestSuite {
* - CentralTests.withArtifacts(
dep = dep,
artifactType = "jar",
extraRepo = Some(repo),
extraRepos = Seq(repo),
classifierOpt = None
) {
case Seq(artifact) =>
@ -40,7 +40,7 @@ object MavenTests extends TestSuite {
* - CentralTests.withArtifacts(
dep = dep,
artifactType = "src",
extraRepo = Some(repo),
extraRepos = Seq(repo),
classifierOpt = Some("sources")
) {
case Seq(artifact) =>

View File

@ -28,10 +28,10 @@ abstract class CentralTests extends TestSuite {
def resolve(
deps: Set[Dependency],
filter: Option[Dependency => Boolean] = None,
extraRepo: Option[Repository] = None,
extraRepos: Seq[Repository] = Nil,
profiles: Option[Set[String]] = None
) = {
val repositories0 = extraRepo.toSeq ++ repositories
val repositories0 = extraRepos ++ repositories
val fetch0 = fetch(repositories0)
@ -56,7 +56,7 @@ abstract class CentralTests extends TestSuite {
def resolutionCheck(
module: Module,
version: String,
extraRepo: Option[Repository] = None,
extraRepos: Seq[Repository] = Nil,
configuration: String = "",
profiles: Option[Set[String]] = None
) =
@ -85,7 +85,7 @@ abstract class CentralTests extends TestSuite {
def tryRead = textResource(path)
val dep = Dependency(module, version, configuration = configuration)
val res = await(resolve(Set(dep), extraRepo = extraRepo, profiles = profiles))
val res = await(resolve(Set(dep), extraRepos = extraRepos, profiles = profiles))
// making that lazy makes scalac crash in 2.10 with scalajs
val result = res
@ -127,11 +127,11 @@ abstract class CentralTests extends TestSuite {
version: String,
artifactType: String,
attributes: Attributes = Attributes(),
extraRepo: Option[Repository] = None
extraRepos: Seq[Repository] = Nil
)(
f: Artifact => T
): Future[T] =
withArtifacts(module, version, artifactType, attributes, extraRepo) {
withArtifacts(module, version, artifactType, attributes, extraRepos) {
case Seq(artifact) =>
f(artifact)
case other =>
@ -146,35 +146,35 @@ abstract class CentralTests extends TestSuite {
version: String,
artifactType: String,
attributes: Attributes = Attributes(),
extraRepo: Option[Repository] = None,
extraRepos: Seq[Repository] = Nil,
classifierOpt: Option[String] = None,
transitive: Boolean = false
)(
f: Seq[Artifact] => T
): Future[T] = {
val dep = Dependency(module, version, transitive = transitive, attributes = attributes)
withArtifacts(dep, artifactType, extraRepo, classifierOpt)(f)
withArtifacts(dep, artifactType, extraRepos, classifierOpt)(f)
}
def withArtifacts[T](
dep: Dependency,
artifactType: String,
extraRepo: Option[Repository],
extraRepos: Seq[Repository],
classifierOpt: Option[String]
)(
f: Seq[Artifact] => T
): Future[T] =
withArtifacts(Set(dep), artifactType, extraRepo, classifierOpt)(f)
withArtifacts(Set(dep), artifactType, extraRepos, classifierOpt)(f)
def withArtifacts[T](
deps: Set[Dependency],
artifactType: String,
extraRepo: Option[Repository],
extraRepos: Seq[Repository],
classifierOpt: Option[String]
)(
f: Seq[Artifact] => T
): Future[T] = async {
val res = await(resolve(deps, extraRepo = extraRepo))
val res = await(resolve(deps, extraRepos = extraRepos))
assert(res.metadataErrors.isEmpty)
assert(res.conflicts.isEmpty)
@ -198,9 +198,9 @@ abstract class CentralTests extends TestSuite {
artifactType: String,
extension: String,
attributes: Attributes = Attributes(),
extraRepo: Option[Repository] = None
extraRepos: Seq[Repository] = Nil
): Future[Unit] =
withArtifact(module, version, artifactType, attributes = attributes, extraRepo = extraRepo) { artifact =>
withArtifact(module, version, artifactType, attributes = attributes, extraRepos = extraRepos) { artifact =>
assert(artifact.url.endsWith("." + extension))
}
@ -282,7 +282,7 @@ abstract class CentralTests extends TestSuite {
mod,
version,
configuration = "runtime",
extraRepo = Some(extraRepo)
extraRepos = Seq(extraRepo)
)
* - ensureHasArtifactWithExtension(
@ -290,7 +290,7 @@ abstract class CentralTests extends TestSuite {
version,
"jar",
"jar",
extraRepo = Some(extraRepo)
extraRepos = Seq(extraRepo)
)
}
@ -406,8 +406,8 @@ abstract class CentralTests extends TestSuite {
intransitiveCompiler("optional")
),
"jar",
None,
None
extraRepos = Nil,
classifierOpt = None
) {
case Seq() =>
throw new Exception("Expected one JAR")
@ -690,7 +690,7 @@ abstract class CentralTests extends TestSuite {
* - resolutionCheck(
Module("org.kie", "kie-api"),
"6.5.0.Final",
extraRepo = Some(MavenRepository("https://repository.jboss.org/nexus/content/repositories/public"))
extraRepos = Seq(MavenRepository("https://repository.jboss.org/nexus/content/repositories/public"))
)
}