Skip to content

Commit

Permalink
More granular tests, so we can see when serialisers are working a bas…
Browse files Browse the repository at this point in the history
…ic level
  • Loading branch information
rtyley committed Feb 7, 2023
1 parent 2be2321 commit f1970a3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/src/test/scala/com/gu/marley/AvroFileSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import com.twitter.scrooge.ThriftStruct

import java.io.File
import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.Gen._
import org.scalacheck._
import org.scalacheck.Gen.*
import org.scalacheck.*
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.Checkers

class AvroFileSpec extends AnyFlatSpec with Checkers with Matchers {
val union = ExampleUnion.Subunion1(SubUnion1("id"))

def checkRoundTrip[T](v: T)(implicit as: AvroSerialisable[T]): Unit = {
def checkRoundTrip[T](v: T)(as: AvroSerialisable[T]): Unit = {
as.read(as.writableValue(v)) shouldEqual v
}

it should "handle an enum" in {
implicit val enumSer: AvroSerialisable[ExampleEnum] = AvroSerialisable.`enum`[ExampleEnum]

checkRoundTrip[ExampleEnum](ExampleEnum.A1)
checkRoundTrip[ExampleEnum](ExampleEnum.B2)
checkRoundTrip[ExampleEnum](ExampleEnum.C3)
checkRoundTrip(ExampleEnum.A1)
checkRoundTrip(ExampleEnum.B2)
checkRoundTrip(ExampleEnum.C3)
}

it should "handle a union" in {
Expand Down

0 comments on commit f1970a3

Please sign in to comment.