Skip to content

Commit

Permalink
Try to compile and run scio-test tests on Scala 3
Browse files Browse the repository at this point in the history
* Since the module depends on scio-avro (not yet being compiled for
Scala 3), some test suites that depend on it were moved to a scala-2
only module.
* Some individual tests that were failing to compile were commented out
for now - most of them test magnolia-based Coder derivation, which is
only implemented for case classes for now
  • Loading branch information
jchyb committed Dec 16, 2022
1 parent 65dd387 commit 91cc877
Show file tree
Hide file tree
Showing 26 changed files with 181 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import scala.util.control.NonFatal
object JobTest {
case class BeamOptions(opts: List[String])

private case class BuilderState(
private[JobTest] case class BuilderState(
className: String,
cmdlineArgs: Array[String] = Array(),
input: Map[String, JobInputSource[_]] = Map.empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,15 @@ trait SCollectionMatchers extends EqInstances {

import ScioMatchers.makeFn

sealed trait MatcherBuilder[T] {
_: Matcher[T] =>
sealed trait MatcherBuilder[T] { self: Matcher[T] =>

type From
type To >: From
type AssertBuilder = From => To

def matcher(builder: AssertBuilder): Matcher[T]

def matcher: Matcher[T] = matcher(identity)
def matcher: Matcher[T] = (t: T) => matcher(t)
}

sealed trait IterableMatcher[T, B] extends MatcherBuilder[T] with Matcher[T] {
Expand Down Expand Up @@ -278,7 +277,7 @@ trait SCollectionMatchers extends EqInstances {
* SCollection assertion only applied to the specified window, running the checker only on the
* final pane for each key.
*/
def inFinalPane[T: ClassTag, B: ClassTag](
def inFinalPane[T](
window: BoundedWindow
)(matcher: MatcherBuilder[T]): Matcher[T] =
matcher match {
Expand All @@ -292,7 +291,7 @@ trait SCollectionMatchers extends EqInstances {
* SCollection assertion only applied to the specified window, running the checker only on the
* late pane for each key.
*/
def inLatePane[T: ClassTag, B: ClassTag](
def inLatePane[T](
window: BoundedWindow
)(matcher: MatcherBuilder[T]): Matcher[T] =
matcher match {
Expand Down Expand Up @@ -439,6 +438,7 @@ trait SCollectionMatchers extends EqInstances {
override def matcher(builder: AssertBuilder): Matcher[SCollection[(K, V)]] =
new Matcher[SCollection[(K, V)]] {
override def apply(left: SCollection[(K, V)]): MatchResult = {
import com.spotify.scio.values.SCollection.makePairSCollectionFunctions
val assertion = builder(PAssert.thatMap(serDeCycle(left).toKV.internal))
m(
() => assertion.isEqualTo(value.asJava),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ object TransformOverride {
* with a transform mapping elements via `fn`.
*/
def of[T: ClassTag, U](name: String, fn: T => U): PTransformOverride = {
val wrappedFn: T => U = fn.compose { t: T =>
val wrappedFn: T => U = fn.compose { (t: T) =>
typeValidation(
s"Input for override transform $name does not match pipeline transform.",
t.getClass,
Expand All @@ -130,7 +130,7 @@ object TransformOverride {
*/
def ofIter[T: ClassTag, U](name: String, fn: T => Iterable[U]): PTransformOverride = {
val wrappedFn: T => JIterable[U] = fn
.compose { t: T =>
.compose { (t: T) =>
typeValidation(
s"Input for override transform $name does not match pipeline transform.",
t.getClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ object TransformOverrideIterJob {
.map(_.toInt)
// #JobTestTest_example_iter
.withName("myTransform")
.transform { c: SCollection[Int] =>
.transform { (c: SCollection[Int]) =>
c.applyTransform(ParDo.of(new GuavaLookupDoFn))
.flatMap(_.getValue.get())
.map(_.toString)
Expand Down
Loading

0 comments on commit 91cc877

Please sign in to comment.