From 8e86e5f85fcb0a42d79d63bb3cfe643197de4224 Mon Sep 17 00:00:00 2001 From: Thiago Nunes Date: Tue, 18 May 2021 14:10:04 +1000 Subject: [PATCH] tests: fixes sql script test (#469) In version 6.4.4 of spanner we have change the verifyStatementsInFile method to wrap any SQLExceptions into SpannerExceptions. In the failing tests we were catching SQLExceptions and ignoring them, since they were expected. We have changed the tests to also ignore the respective SpannerExceptions. --- .../cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java index 8fc331bb..5133fc4d 100644 --- a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java +++ b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java @@ -23,6 +23,7 @@ import com.google.cloud.spanner.ErrorCode; import com.google.cloud.spanner.IntegrationTest; +import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.connection.SqlScriptVerifier; import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier; @@ -93,6 +94,11 @@ public void test02_InsertTestData() throws Exception { // Ignore, this is expected as errors during a read/write transaction are sticky on the // emulator. } + } catch (SpannerException e) { + if (env.getTestHelper().isEmulator() && e.getErrorCode() == ErrorCode.ALREADY_EXISTS) { + // Ignore, this is expected as errors during a read/write transaction are sticky on the + // emulator. + } } } @@ -114,6 +120,11 @@ public void test04_TestGetCommitTimestamp() throws Exception { && e.getErrorCode() == ErrorCode.INVALID_ARGUMENT.getGrpcStatusCode().value()) { // Ignore as errors during read/write transactions are sticky on the emulator. } + } catch (SpannerException e) { + if (env.getTestHelper().isEmulator() && e.getErrorCode() == ErrorCode.ALREADY_EXISTS) { + // Ignore, this is expected as errors during a read/write transaction are sticky on the + // emulator. + } } }