Skip to content

Commit

Permalink
Cross-build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Nov 15, 2022
1 parent 357970d commit c84f7b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
5 changes: 5 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
val clueVersion = "0.23.1"
val lucumaCoreVersion2 = "0.45.0"
val lucumaCoreVersion = "0.58.0"
val fs2Version = "3.3.0"
val munitVersion = "0.7.29"
val munitCatsEffectVersion = "1.0.7"
val kittensVersion = "3.0.0"
Expand Down Expand Up @@ -38,6 +39,7 @@ val lucumaSchemas =
"edu.gemini" %%% "clue-core" % clueVersion,
"edu.gemini" %%% "lucuma-core" % lucumaCoreVersion,
"org.typelevel" %%% "kittens" % kittensVersion,
"co.fs2" %%% "fs2-io" % fs2Version % Test,
"org.scalameta" %%% "munit" % munitVersion % Test,
"org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectVersion % Test
),
Expand All @@ -57,3 +59,6 @@ val lucumaSchemas =
// Include schema files from templates in jar.
Compile / unmanagedResourceDirectories += (templates / Compile / resourceDirectory).value
)
.jsSettings(
Test / scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package lucuma.schemas.decoders

import cats.effect._
import fs2.io.file._
import io.circe.Decoder
import io.circe.Json
import io.circe.parser._
Expand All @@ -14,22 +15,12 @@ import java.io.FileInputStream
import java.nio.file.Paths

trait InputStreamSuite extends CatsEffectSuite {
def inputStream(f: File): Resource[IO, FileInputStream] =
Resource.make {
IO.blocking(new FileInputStream(f)) // build
} { inStream =>
IO.blocking(inStream.close()).handleErrorWith(_ => IO.unit) // release
}

def jsonResult(jsonFile: String): IO[Json] = {
val url = getClass.getResource(jsonFile)
val file = Paths.get(url.toURI).toFile

inputStream(file).use { inStream =>
for {
str <- IO.blocking(scala.io.Source.fromInputStream(inStream).mkString)
json <- IO.fromEither(parse(str))
} yield json
val path = Path(s"lucuma-schemas/src/test/resources") / jsonFile

Files[IO].readUtf8(path).compile.string.flatMap { str =>
IO.fromEither(parse(str))
}
}

Expand Down

0 comments on commit c84f7b0

Please sign in to comment.