Skip to content

Commit

Permalink
Merge pull request #146 from dwijnand/UpdateReport.toString
Browse files Browse the repository at this point in the history
Make sure UpdateReport has a nice toString
  • Loading branch information
dwijnand authored Jul 28, 2017
2 parents 47e4dca + 5292385 commit c6e8bd7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ final class OrganizationArtifactReport private (
37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.OrganizationArtifactReport".##) + organization.##) + name.##) + modules.##)
}
override def toString: String = {
"OrganizationArtifactReport(" + organization + ", " + name + ", " + modules + ")"
val details = modules map { _.detailReport }
s"\t$organization:$name\n${details.mkString}\n"
}
protected[this] def copy(organization: String = organization, name: String = name, modules: Vector[sbt.librarymanagement.ModuleReport] = modules): OrganizationArtifactReport = {
new OrganizationArtifactReport(organization, name, modules)
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/contraband/librarymanagement.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@
{ "name": "organization", "type": "String" },
{ "name": "name", "type": "String" },
{ "name": "modules", "type": "sbt.librarymanagement.ModuleReport*" }
],
"toString": [
"val details = modules map { _.detailReport }",
"s\"\\t$organization:$name\\n${details.mkString}\\n\""
]
},
{
Expand Down
41 changes: 41 additions & 0 deletions core/src/test/scala/UpdateReportSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package sbt.librarymanagement

import java.io.File

import org.scalatest._

class UpdateReportSpec extends FlatSpec with Matchers {
"UpdateReport.toString" should "have a nice toString" in {
assert(updateReport.toString === s"""
|Update report:
| Resolve time: 0 ms, Download time: 0 ms, Download size: 0 bytes
| compile:
| org:name
| - 1.0
| evicted: false
|
|""".stripMargin.drop(1))
}

lazy val updateReport =
UpdateReport(
new File("cachedDescriptor.data"),
Vector(configurationReport),
UpdateStats(0, 0, 0, false),
Map.empty
)

lazy val configurationReport =
ConfigurationReport(
ConfigRef("compile"),
Vector(moduleReport),
Vector(organizationArtifactReport)
)

lazy val moduleReport =
ModuleReport(ModuleID("org", "name", "1.0"), Vector.empty, Vector.empty)

lazy val organizationArtifactReport =
OrganizationArtifactReport("org", "name", Vector(moduleReport))

}

0 comments on commit c6e8bd7

Please sign in to comment.