From 61d674ce690c5742e87f4df0b879d7729fe0b14b Mon Sep 17 00:00:00 2001 From: Michel Davit Date: Thu, 11 Apr 2024 11:31:21 +0200 Subject: [PATCH] [integration] Use literals for fromSchemaFile integration test --- .../scio/avro/types/TypeProviderIT.scala | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/integration/src/test/scala/com/spotify/scio/avro/types/TypeProviderIT.scala b/integration/src/test/scala/com/spotify/scio/avro/types/TypeProviderIT.scala index 7f0245508f..5ee42e2da0 100644 --- a/integration/src/test/scala/com/spotify/scio/avro/types/TypeProviderIT.scala +++ b/integration/src/test/scala/com/spotify/scio/avro/types/TypeProviderIT.scala @@ -24,33 +24,17 @@ import org.scalatest.matchers.should.Matchers import scala.annotation.StaticAnnotation import scala.reflect.runtime.universe._ -object TypeProviderIT { - private val SchemaFile = - "https://raw.githubusercontent.com/spotify/scio/master/integration/src/test/avro/avro-type-provider.avsc" +class TypeProviderIT extends AnyFlatSpec with Matchers { - @AvroType.fromSchemaFile(SchemaFile) + @AvroType.fromSchemaFile( + "https://raw.githubusercontent.com/spotify/scio/master/integration/src/test/avro/avro-type-provider.avsc" + ) class FromResourceMultiLine - @AvroType.fromSchemaFile(SchemaFile) + @AvroType.fromSchemaFile( + "https://raw.githubusercontent.com/spotify/scio/master/integration/src/test/avro/avro-type-provider.avsc" + ) class FromResource - class Annotation1 extends StaticAnnotation - class Annotation2 extends StaticAnnotation - - @Annotation1 - @AvroType.fromSchemaFile(SchemaFile) - @Annotation2 - class FromResourceWithSurroundingAnnotations - - @AvroType.fromSchemaFile(SchemaFile) - @Annotation1 - @Annotation2 - class FromResourceWithSequentialAnnotations -} - -class TypeProviderIT extends AnyFlatSpec with Matchers { - - import TypeProviderIT._ - "AvroType.fromSchemaFile" should "support reading schema from multiline resource" in { val r = FromResourceMultiLine(1) r.test shouldBe 1 @@ -61,15 +45,31 @@ class TypeProviderIT extends AnyFlatSpec with Matchers { r.test shouldBe 2 } + class Annotation1 extends StaticAnnotation + class Annotation2 extends StaticAnnotation + + @Annotation1 + @AvroType.fromSchemaFile( + "https://raw.githubusercontent.com/spotify/scio/master/integration/src/test/avro/avro-type-provider.avsc" + ) + @Annotation2 + class FromResourceWithSurroundingAnnotations + it should "preserve surrounding user defined annotations" in { containsAllAnnotTypes[FromResourceWithSurroundingAnnotations] } + @AvroType.fromSchemaFile( + "https://raw.githubusercontent.com/spotify/scio/master/integration/src/test/avro/avro-type-provider.avsc" + ) + @Annotation1 + @Annotation2 + class FromResourceWithSequentialAnnotations it should "preserve sequential user defined annotations" in { containsAllAnnotTypes[FromResourceWithSequentialAnnotations] } - private def containsAllAnnotTypes[T: TypeTag]: Assertion = + def containsAllAnnotTypes[T: TypeTag]: Assertion = typeOf[T].typeSymbol.annotations .map(_.tree.tpe) .containsSlice(Seq(typeOf[Annotation1], typeOf[Annotation2])) shouldBe true