-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: FIR-33601: use catalogs table instead of databases table if exi…
…sts (#424)
- Loading branch information
1 parent
07a4dc5
commit 21e5f3c
Showing
5 changed files
with
81 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...m/firebolt/jdbc/service/FireboltEngineInformationSchemaServiceUsingCatalogsTableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.firebolt.jdbc.service; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.mockito.Mockito; | ||
|
||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class FireboltEngineInformationSchemaServiceUsingCatalogsTableTest extends FireboltEngineInformationSchemaServiceTest{ | ||
FireboltEngineInformationSchemaServiceUsingCatalogsTableTest() { | ||
super(true); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource(value = {"mydb;'';false", "other_db;'database_name,other_db';true"}, delimiter = ';') | ||
void doesDatabaseExist(String db, String row, boolean expected) throws SQLException { | ||
PreparedStatement statement = mock(PreparedStatement.class); | ||
Map<String, String> rowData = row == null || row.isEmpty() ? Map.of() : Map.of(row.split(",")[0], row.split(",")[1]); | ||
ResultSet resultSet = mockedResultSet(rowData); | ||
when(fireboltConnection.prepareStatement("SELECT catalog_name FROM information_schema.catalogs WHERE catalog_name=?")).thenReturn(statement); | ||
when(statement.executeQuery()).thenReturn(resultSet); | ||
assertEquals(expected, fireboltEngineService.doesDatabaseExist(db)); | ||
Mockito.verify(statement, Mockito.times(1)).setString(1, db); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
.../firebolt/jdbc/service/FireboltEngineInformationSchemaServiceUsingDatabasesTableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.firebolt.jdbc.service; | ||
|
||
class FireboltEngineInformationSchemaServiceUsingDatabasesTableTest extends FireboltEngineInformationSchemaServiceTest{ | ||
FireboltEngineInformationSchemaServiceUsingDatabasesTableTest() { | ||
super(false); | ||
} | ||
} |