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

Add simple test about DefaultSource class #773

Merged
merged 1 commit into from
Aug 11, 2023
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
24 changes: 24 additions & 0 deletions src/test/scala/cognite/spark/v1/DefaultSourceClassTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cognite.spark.v1

import org.scalatest.{FlatSpec, Matchers}


class DefaultSourceClassTest extends FlatSpec with Matchers {
it should "have default constructor" in {
// Data source should be constructable with no arguments and
// any parameters should be parsed within specific methods.
// Implicit parameters are also not allowed.
// Otherwise spark executors will fail to create it.
val res = new DefaultSource()
res shouldBe a[DefaultSource]
}

it should "really have a no-argument constructor" in {
// let's also check via reflection to rule out varargs option like A(String... s)
// getConstructor() will only pick up no-args version
// getConstructor(String[].class) can be used to select varargs version
// reflection also makes sure no scala implicits are needed
val res = classOf[DefaultSource].getConstructor().newInstance()
res shouldBe a[DefaultSource]
}
}
Loading