Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
soujiro32167 committed Jun 10, 2024
1 parent 2de4f5a commit b8e69da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package vulcan.generic

import vulcan.{AvroError, Codec}


sealed trait Enum extends Product {
self =>
def value: String = self.productPrefix
Expand All @@ -23,8 +22,8 @@ object Enum {
symbols = List(A.value, B.value),
encode = _.value,
decode = {
case "A" => Right(A)
case "B" => Right(B)
case "A" => Right(A)
case "B" => Right(B)
case other => Left(AvroError(s"Invalid S: $other"))
}
)
Expand All @@ -42,7 +41,7 @@ object Union {

case class Foo(
a: Int = 1,
b: String = "foo",
b: String = "foo"
)

object Foo {
Expand Down Expand Up @@ -108,15 +107,15 @@ final class AvroFieldDefaultSpec extends CodecBase {
assert(HasSSecond.codec.schema.exists(_.getField("s").defaultVal() == "B"))
}

it("should succeed with the first member of a union"){
it("should succeed with the first member of a union") {
assertSchemaIs[HasUnion](
"""{"type":"record","name":"HasUnion","namespace":"vulcan.generic","fields":[{"name":"u","type":[{"type":"record","name":"A","namespace":"vulcan.generic.Union","fields":[{"name":"a","type":"int"}]},{"type":"record","name":"B","namespace":"vulcan.generic.Union","fields":[{"name":"b","type":"string"}]}],"default":{"a":1}}]}"""
)
val result = unsafeDecode[HasUnion](unsafeEncode[Empty](Empty()))
assert(result == HasUnion(Union.A(1)))
}

it("should fail with the second member of a union"){
it("should fail with the second member of a union") {
assertSchemaError[HasUnionSecond]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class CodecBase extends AnyFunSpec with ScalaCheckPropertyChecks with EitherValu
)(implicit codec: Codec[A]): Assertion =
assert(codec.schema.swap.value.message == expectedErrorMessage)


def assertSchemaError[A](implicit codec: Codec[A]): Assertion =
assert(codec.schema.isLeft, codec.schema)

Expand Down

0 comments on commit b8e69da

Please sign in to comment.