Skip to content

Commit

Permalink
Move init.sql to test/resources, don't check result for DDL
Browse files Browse the repository at this point in the history
  • Loading branch information
matriv committed Apr 20, 2023
1 parent b70d63d commit 169177d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testTcInitClasspathFile() throws SQLException, IOException {
*/
@Test
public void testTcInitArbitraryFile() throws SQLException, IOException {
String connectionUrl = "jdbc:tc:cratedb:5.2://localhost/doc?user=crate&TC_REUSABLE=true&TC_INITSCRIPT=file:src/main/resources/init.sql";
String connectionUrl = "jdbc:tc:cratedb:5.2://localhost/doc?user=crate&TC_REUSABLE=true&TC_INITSCRIPT=file:src/test/resources/init.sql";
System.out.printf("Connecting to %s%n", connectionUrl);

// Invoke `SHOW CREATE TABLE ...` query.
Expand All @@ -64,5 +64,4 @@ public void testTcInitFunction() throws SQLException, IOException {
assertThat(results.metaData().getColumnCount()).isEqualTo(1);
assertThat(results.rows()).hasSize(1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ public static void assertResults(Application.Results results) throws SQLExceptio
*/
public static void sqlInitFunction(Connection connection) throws SQLException, IOException, InterruptedException {
try (Statement stmt = connection.createStatement()) {
boolean checkResults = stmt.execute("CREATE TABLE IF NOT EXISTS foobar_init (id INTEGER)");
if (checkResults) {
System.out.println("Success.");
} else {
throw new SQLException("ERROR: SQL initialization failed");
}
stmt.execute("CREATE TABLE IF NOT EXISTS foobar_init (id INTEGER)");
}
}

}

0 comments on commit 169177d

Please sign in to comment.