Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ object BuildHelper {
val Scala213: String = versions("2.13")
val ScalaDotty: String = "3.1.0" //versions.getOrElse("3.0", versions("3.1"))

val zioVersion = "2.0.0-RC5"
val zioJsonVersion = "0.3.0-RC7"
val zioPreludeVersion = "1.0.0-RC13"
val zioOpticsVersion = "2.0.0-RC4"
val zioVersion = "2.0.0-RC6"
val zioJsonVersion = "0.3.0-RC8"
val zioPreludeVersion = "1.0.0-RC14"
val zioOpticsVersion = "0.2.0-RC4"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside, the previous release version for zio-optics probably got messed up, it was 2.0.0-RC4.

val silencerVersion = "1.7.8"

private val testDeps = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ object DeriveSchemaSpec extends ZIOSpecDefault {

}

override def spec: ZSpec[Environment, Any] = suite("DeriveSchemaSpec")(
override def spec: Spec[Environment, Any] = suite("DeriveSchemaSpec")(
suite("Derivation")(
test("correctly derives case class") {
assert(Schema[User].toString)(not(containsString("null")) && not(equalTo("$Lazy$")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object JsonCodec extends Codec {
)

override def decoder[A](schema: Schema[A]): ZPipeline[Any, String, Byte, A] =
ZPipeline.utfDecode >>> ZPipeline.mapZIO(
ZPipeline.fromChannel(ZPipeline.utfDecode.channel.mapError(_.toString)) >>> ZPipeline.mapZIO(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamgfraser I tried that, but it doesn't seem to work. I get Unexpected end of input in the JsonCodecSpec tests. Any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utfDecode tries to determine the encoding by reading a BOM from the beginning of the stream, and defaults to UTF-8 if it could not find any.

I will check if there is something wrong with this logic but here you should be able to just use utf8Decode as JSON should always be in UTF-8.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..but that does not solve the issue, so I'm looking into it more

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you ran into this issue: #182 because the new utfDecode rechunks the stream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vigoo Thanks for your suggestions and thanks for adding ZPipeline.mapError. I still have the same error (Unexpected end of input) using utf8Decode. Will check #182

(s: String) => ZIO.fromEither(Decoder.decode(schema, s))
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.Assertion._
import zio.test._

object DeriveGenSpec extends ZIOSpecDefault {
override def spec: ZSpec[Environment, Any] = suite("DeriveGenSpec")(
override def spec: Spec[Environment, Any] = suite("DeriveGenSpec")(
test("correctly derives Primitives") {
for {
unit <- generateValue(DeriveGen.gen(unitSchema))
Expand Down Expand Up @@ -75,5 +75,5 @@ object DeriveGenSpec extends ZIOSpecDefault {
)

private def generateValue[R, A](gen: Gen[R, A]): ZIO[R, Nothing, TestResult] =
assertM(gen.runCollect)(isNonEmpty)
assertZIO(gen.runCollect)(isNonEmpty)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package zio.schema
import zio.Chunk
import zio.schema.syntax._
import zio.test.Assertion
import zio.test.AssertionM.Render.param

object SchemaAssertions {

def migratesTo[A: Schema, B: Schema](expected: B): Assertion[A] =
Assertion.assertion("migratesTo")(param(expected)) { value =>
Assertion.assertion("migratesTo") { value =>
value.migrate[B] match {
case Left(_) => false
case Right(m) if m != expected => false
Expand All @@ -18,22 +17,22 @@ object SchemaAssertions {
}

def cannotMigrateValue[A: Schema, B: Schema]: Assertion[A] =
Assertion.assertion("cannotMigrateTo")() { value =>
Assertion.assertion("cannotMigrateTo") { value =>
value.migrate[B].isLeft
}

def hasSameSchema(expected: Schema[_]): Assertion[Schema[_]] =
Assertion.assertion("hasSameSchema")(param(expected))(
Assertion.assertion("hasSameSchema")(
actual => Schema.strictEquality.equal(expected, actual)
)

def hasSameSchemaStructure(expected: Schema[_]): Assertion[Schema[_]] =
Assertion.assertion("hasSameSchemaStructure")(param(expected))(
Assertion.assertion("hasSameSchemaStructure")(
actual => Schema.structureEquality.equal(expected, actual)
)

def hasSameAst(expected: Schema[_]): Assertion[Schema[_]] =
Assertion.assertion("hasSameAst")(param(expected))(actual => equalsAst(expected, actual))
Assertion.assertion("hasSameAst")(actual => equalsAst(expected, actual))

private def equalsAst(expected: Schema[_], actual: Schema[_], depth: Int = 0): Boolean = (expected, actual) match {
case (Schema.Primitive(StandardType.DurationType, _), Schema.Primitive(StandardType.DurationType, _)) => true
Expand Down