Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[integration] Use literals for fromSchemaFile integration test #5334

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -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://github.com/spotify/scio/master/integration/src/test/avro/avro-type-provider.avsc"
class TypeProviderIT extends AnyFlatSpec with Matchers {

@AvroType.fromSchemaFile(SchemaFile)
@AvroType.fromSchemaFile(
"https://github.com/spotify/scio/master/integration/src/test/avro/avro-type-provider.avsc"
)
class FromResourceMultiLine
@AvroType.fromSchemaFile(SchemaFile)
@AvroType.fromSchemaFile(
"https://github.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
Expand All @@ -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://github.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://github.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
Expand Down