Merge pull request #146 from dwijnand/UpdateReport.toString

Make sure UpdateReport has a nice toString
This commit is contained in:
Dale Wijnand 2017-07-28 10:36:35 +01:00 committed by GitHub
commit c6e8bd72d2
3 changed files with 47 additions and 1 deletions

View File

@ -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)

View File

@ -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\""
]
},
{

View File

@ -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))
}