Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bli committed Sep 27, 2024
1 parent a433653 commit c171397
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.snowflake.code_verification

import com.snowflake.snowpark.{CodeVerification, DataFrame}
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

// verify API Java and Scala API contain same functions
@CodeVerification
class JavaScalaAPISuite extends FunSuite {
class JavaScalaAPISuite extends AnyFunSuite {
private val scalaCaseClassFunctions = Set(
"apply",
"copy",
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/com/snowflake/code_verification/PomSuite.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.snowflake.code_verification

import com.snowflake.snowpark.CodeVerification
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

import scala.collection.mutable

@CodeVerification
class PomSuite extends FunSuite {
class PomSuite extends AnyFunSuite {

private val pomFileName = "pom.xml"
private val fipsPomFileName = "fips-pom.xml"
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import com.snowflake.snowpark.internal.ParameterUtils.{
MIN_REQUEST_TIMEOUT_IN_SECONDS,
SnowparkRequestTimeoutInSeconds
}
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class ErrorMessageSuite extends FunSuite {
class ErrorMessageSuite extends AnyFunSuite {

test("INTERNAL_TEST_MESSAGE") {
val ex = ErrorMessage.INTERNAL_TEST_MESSAGE("my message: '%d $'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package com.snowflake.snowpark
import java.io.{File, FileOutputStream}
import java.util.jar.{JarFile, JarOutputStream}
import java.util.zip.ZipException

import com.snowflake.snowpark.internal.{FatJarBuilder, JavaCodeCompiler}
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

import scala.collection.mutable.ArrayBuffer
import scala.util.Random

class FatJarBuilderSuite extends FunSuite with FileUtils {
class FatJarBuilderSuite extends AnyFunSuite with FileUtils {

test("Check that fat jar is built correctly") {
val className = "HelloWorld"
Expand Down
5 changes: 3 additions & 2 deletions src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.snowflake.snowpark

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

import java.io.ByteArrayOutputStream

@JavaAPITest
class JavaAPISuite extends FunSuite {
class JavaAPISuite extends AnyFunSuite {
// some tests can't be implemented in Java are listed below

// console redirect doesn't work in Java since run JUnit from Scala
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.snowflake.snowpark

import com.snowflake.snowpark.internal.{InMemoryClassObject, JavaCodeCompiler, UDFClassPath}
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class JavaCodeCompilerSuite extends FunSuite {
class JavaCodeCompilerSuite extends AnyFunSuite {

test("Compile a class that requires scala in classpath") {
val className = "HelloWorld"
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/com/snowflake/snowpark/LoggingSuite.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.snowflake.snowpark

import com.snowflake.snowpark.internal.Logging
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class LoggingSuite extends FunSuite {
class LoggingSuite extends AnyFunSuite {

test("log name") {
val a = new LoggingTestA
Expand Down
5 changes: 3 additions & 2 deletions src/test/scala/com/snowflake/snowpark/SNTestBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import com.snowflake.snowpark.internal.{ParameterUtils, ServerConnection, UDFCla
import com.snowflake.snowpark.types._
import com.snowflake.snowpark_test.TestFiles
import org.mockito.Mockito.{doReturn, spy, when}
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funsuite.AnyFunSuite

import scala.collection.mutable.ArrayBuffer
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global

trait SNTestBase extends FunSuite with BeforeAndAfterAll with SFTestUtils with SnowTestFiles {
trait SNTestBase extends AnyFunSuite with BeforeAndAfterAll with SFTestUtils with SnowTestFiles {

protected val defaultProfile: String = TestUtils.defaultProfile

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.snowflake.snowpark

import org.scalatest.FunSuite
import com.snowflake.snowpark.internal.SnowparkSFConnectionHandler
import org.scalatest.funsuite.AnyFunSuite

class SnowparkSFConnectionHandlerSuite extends FunSuite {
class SnowparkSFConnectionHandlerSuite extends AnyFunSuite {

test("version") {
assert(SnowparkSFConnectionHandler.extractValidVersionNumber("0.1.0-snapshot").equals("0.1.0"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.snowflake.snowpark_test
import com.snowflake.snowpark.functions._
import com.snowflake.snowpark._
import net.snowflake.client.jdbc.SnowflakeSQLException
import org.scalatest.Matchers.the

import java.sql.ResultSet

Expand Down Expand Up @@ -306,9 +305,7 @@ class DataFrameAggregateSuite extends TestData {
// Used temporary VIEW which is not supported by owner's mode stored proc yet
test("Window functions inside aggregate functions", JavaStoredProcExcludeOwner) {
def checkWindowError(df: => DataFrame): Unit = {
the[SnowflakeSQLException] thrownBy {
df.collect()
}
assertThrows[SnowparkClientException](df.collect())
}
checkWindowError(testData2.select(min(avg($"b").over(Window.partitionBy($"a")))))
checkWindowError(testData2.agg(sum($"b"), max(rank().over(Window.orderBy($"a")))))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.snowflake.snowpark_test

import org.scalatest.FunSuite
import org.scalatest.exceptions.TestFailedException
import com.snowflake.snowpark.internal.Utils
import org.scalatest.funsuite.AnyFunSuite

import scala.language.postfixOps
import sys.process._

// verify those classes do not depend on Snowpark package
class IndependentClassSuite extends FunSuite {
class IndependentClassSuite extends AnyFunSuite {
lazy val pathPrefix = s"target/scala-${Utils.ScalaCompatVersion}/"
private def generatePath(path: String): String = pathPrefix + path
test("scala variant") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.snowflake.snowpark_test

import org.scalatest.FunSuite
import com.snowflake.snowpark.internal.JavaUtils._
import com.snowflake.snowpark.types.Variant
import com.snowflake.snowpark_java.types.{Variant => JavaVariant}
import org.scalatest.funsuite.AnyFunSuite

import scala.collection.JavaConverters._
import java.util

// test UDF utils functions
// those functions work on server side.
// can't be detected by test coverage report.
class JavaUtilsSuite extends FunSuite {
class JavaUtilsSuite extends AnyFunSuite {

test("geography to string") {
val data = "{\"type\":\"Point\",\"coordinates\":[125.6, 10.1]}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.snowflake.snowpark_test

import com.snowflake.snowpark.types.{Geography, Variant}
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

import java.io.UncheckedIOException
import java.sql.{Date, Time, Timestamp}

class ScalaVariantSuite extends FunSuite {
class ScalaVariantSuite extends AnyFunSuite {
test("scala constructor and extension functions") {
assert(new Variant(1.1).asDouble() == 1.1)
assert(new Variant(1.2f).asFloat() == 1.2f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.snowflake.snowpark_test
import com.snowflake.snowpark.functions._
import com.snowflake.snowpark.{DataFrame, Row, TestData, Window}
import net.snowflake.client.jdbc.SnowflakeSQLException
import org.scalatest.Matchers.the

import scala.reflect.ClassTag

Expand Down Expand Up @@ -56,7 +55,7 @@ class WindowSpecSuite extends TestData {

test("Window functions inside WHERE and HAVING clauses") {
def checkAnalysisError[T: ClassTag](df: => DataFrame): Unit = {
the[T] thrownBy {
assertThrows[ClassTag[T]] {
df.collect()
}
}
Expand Down

0 comments on commit c171397

Please sign in to comment.