[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:
E.G 2026-01-16 14:19:30 +11:00 committed by GitHub
parent b107fb6c5c
commit f4bd7689a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 9 deletions

View File

@ -10,24 +10,23 @@ package sbt.util
import sjsonnew.shaded.scalajson.ast.unsafe.*
import sjsonnew.*, support.scalajson.unsafe.*
import org.scalatest.flatspec.AnyFlatSpec
import verify.BasicTestSuite
import sbt.io.IO
class FileInfoSpec extends AnyFlatSpec {
object FileInfoSpec extends BasicTestSuite:
val file = new java.io.File(".").getAbsoluteFile
val fileInfo: ModifiedFileInfo = FileModified(file, IO.getModifiedTimeOrZero(file))
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 jValue: JValue = Parser.parseUnsafe(jsonString)
val y: A = Converter.fromJson[A](jValue).get
assert(x === y)
}
def assertJsonString[A: JsonWriter](x: A, s: String) = assert(toJsonString(x) === s)
assert(x == y)
def toJsonString[A: JsonWriter](x: A): String = CompactPrinter(Converter.toJson(x).get)
}
end FileInfoSpec