diff options
author | Dongjoon Hyun <dongjoon@apache.org> | 2016-08-09 09:45:46 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-08-09 09:45:46 +0100 |
commit | 2154345b6a1cb193b1380ab386912e478928c6b2 (patch) | |
tree | 273f8f6d485f61a38bc3cf81f9e34c2d3ba9d0a4 /sql | |
parent | af710e5bdda9da04dbba615e219e7e496ca82acc (diff) | |
download | spark-2154345b6a1cb193b1380ab386912e478928c6b2.tar.gz spark-2154345b6a1cb193b1380ab386912e478928c6b2.tar.bz2 spark-2154345b6a1cb193b1380ab386912e478928c6b2.zip |
[SPARK-16940][SQL] `checkAnswer` should raise `TestFailedException` for wrong results
## What changes were proposed in this pull request?
This PR fixes the following to make `checkAnswer` raise `TestFailedException` again instead of `java.util.NoSuchElementException: key not found: TZ` in the environments without `TZ` variable. Also, this PR adds `QueryTestSuite` class for testing `QueryTest` itself.
```scala
- |Timezone Env: ${sys.env("TZ")}
+ |Timezone Env: ${sys.env.getOrElse("TZ", "")}
```
## How was this patch tested?
Pass the Jenkins tests with a new test suite.
Author: Dongjoon Hyun <dongjoon@apache.org>
Closes #14528 from dongjoon-hyun/SPARK-16940.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala index 3437586746..304881d4a4 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala @@ -402,7 +402,7 @@ object QueryTest { s""" |Results do not match for query: |Timezone: ${TimeZone.getDefault} - |Timezone Env: ${sys.env("TZ")} + |Timezone Env: ${sys.env.getOrElse("TZ", "")} | |${df.queryExecution} |== Results == @@ -483,3 +483,11 @@ object QueryTest { } } } + +class QueryTestSuite extends QueryTest with test.SharedSQLContext { + test("SPARK-16940: checkAnswer should raise TestFailedException for wrong results") { + intercept[org.scalatest.exceptions.TestFailedException] { + checkAnswer(sql("SELECT 1"), Row(2) :: Nil) + } + } +} |