mirror of https://github.com/sbt/sbt.git
[2.x] test: Migrate FileInfoSpec.scala to verify.BasicTestSuite (#8544)
* test: Migrate FileInfoSpec.scala to verify.BasicTestSuite (#8542) Migrate FileInfoSpec.scala from ScalaTest's AnyFlatSpec to verify.BasicTestSuite, following the pattern established by other test files in the util-cache module. Changes: - Replace AnyFlatSpec class with BasicTestSuite object - Convert 'it should ... in' syntax to 'test(...)' syntax - Use Scala 3 syntax with colon indentation - Change === to == for assertions (BasicTestSuite style) - Add explicit Unit return types for consistency - Add 'end FileInfoSpec' marker Fixes #8542
This commit is contained in:
parent
b107fb6c5c
commit
f4bd7689a3
|
|
@ -10,24 +10,23 @@ package sbt.util
|
||||||
|
|
||||||
import sjsonnew.shaded.scalajson.ast.unsafe.*
|
import sjsonnew.shaded.scalajson.ast.unsafe.*
|
||||||
import sjsonnew.*, support.scalajson.unsafe.*
|
import sjsonnew.*, support.scalajson.unsafe.*
|
||||||
import org.scalatest.flatspec.AnyFlatSpec
|
import verify.BasicTestSuite
|
||||||
import sbt.io.IO
|
import sbt.io.IO
|
||||||
|
|
||||||
class FileInfoSpec extends AnyFlatSpec {
|
object FileInfoSpec extends BasicTestSuite:
|
||||||
val file = new java.io.File(".").getAbsoluteFile
|
val file = new java.io.File(".").getAbsoluteFile
|
||||||
val fileInfo: ModifiedFileInfo = FileModified(file, IO.getModifiedTimeOrZero(file))
|
val fileInfo: ModifiedFileInfo = FileModified(file, IO.getModifiedTimeOrZero(file))
|
||||||
val filesInfo = FilesInfo(Set(fileInfo))
|
val filesInfo = FilesInfo(Set(fileInfo))
|
||||||
|
|
||||||
it should "round trip" in assertRoundTrip(filesInfo)
|
test("round trip"):
|
||||||
|
assertRoundTrip(filesInfo)
|
||||||
|
|
||||||
def assertRoundTrip[A: JsonWriter: JsonReader](x: A) = {
|
def assertRoundTrip[A: JsonWriter: JsonReader](x: A): Unit =
|
||||||
val jsonString: String = toJsonString(x)
|
val jsonString: String = toJsonString(x)
|
||||||
val jValue: JValue = Parser.parseUnsafe(jsonString)
|
val jValue: JValue = Parser.parseUnsafe(jsonString)
|
||||||
val y: A = Converter.fromJson[A](jValue).get
|
val y: A = Converter.fromJson[A](jValue).get
|
||||||
assert(x === y)
|
assert(x == y)
|
||||||
}
|
|
||||||
|
|
||||||
def assertJsonString[A: JsonWriter](x: A, s: String) = assert(toJsonString(x) === s)
|
|
||||||
|
|
||||||
def toJsonString[A: JsonWriter](x: A): String = CompactPrinter(Converter.toJson(x).get)
|
def toJsonString[A: JsonWriter](x: A): String = CompactPrinter(Converter.toJson(x).get)
|
||||||
}
|
|
||||||
|
end FileInfoSpec
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue