Skip to content

Commit

Permalink
SNOW-1308317 SNOW-3124578 Update tests to work with adding account_us…
Browse files Browse the repository at this point in the history
…age_snowhouse_local_setup_import.sql to make setup (#1721)
  • Loading branch information
sfc-gh-ntrinh authored Apr 15, 2024
1 parent 9a7c6d6 commit 4184f23
Showing 1 changed file with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ public void testGetColumn() throws SQLException {
statement = connection.createStatement();
databaseMetaData = connection.getMetaData();

// Exclude SNOWFLAKE system database from DatabaseMetadata
ResultSet snowflakeResultSet = databaseMetaData.getColumns("SNOWFLAKE", null, null, null);
int numSnowflakeColumns = getSizeOfResultSet(snowflakeResultSet);

resultSet = databaseMetaData.getColumns(null, null, null, null);
assertEquals(
getAllObjectCountInDBViaInforSchema(getAllColumnsCount), getSizeOfResultSet(resultSet));
getAllObjectCountInDBViaInforSchema(getAllColumnsCount),
getSizeOfResultSet(resultSet) - numSnowflakeColumns);

resultSet = databaseMetaData.getColumns(null, "JDBC_SCHEMA11", null, null);
assertEquals(3, getSizeOfResultSet(resultSet));
Expand Down Expand Up @@ -242,13 +247,19 @@ public void testGetSchema() throws SQLException {
databaseMetaData = connection.getMetaData();
assertEquals("schema", databaseMetaData.getSchemaTerm());

// Exclude SNOWFLAKE system database from DatabaseMetadata
ResultSet snowflakeResultSet = databaseMetaData.getSchemas("SNOWFLAKE", null);
int numSnowflakeSchemas = getSizeOfResultSet(snowflakeResultSet);

resultSet = databaseMetaData.getSchemas();
assertEquals(
getAllObjectCountInDBViaInforSchema(getSchemaCount), getSizeOfResultSet(resultSet));
getAllObjectCountInDBViaInforSchema(getSchemaCount),
getSizeOfResultSet(resultSet) - numSnowflakeSchemas);

resultSet = databaseMetaData.getSchemas(null, null);
assertEquals(
getAllObjectCountInDBViaInforSchema(getSchemaCount), getSizeOfResultSet(resultSet));
getAllObjectCountInDBViaInforSchema(getSchemaCount),
getSizeOfResultSet(resultSet) - numSnowflakeSchemas);

resultSet = databaseMetaData.getSchemas("JDBC_DB1", "%");
resultSet.next();
Expand Down Expand Up @@ -463,11 +474,19 @@ public void testGetTables() throws SQLException {
resultSet = databaseMetaData.getTables(null, null, null, new String[] {"SYSTEM_TABLE"});
assertEquals(0, getSizeOfResultSet(resultSet));

// Exclude SNOWFLAKE system database from DatabaseMetadata
ResultSet snowflakeResultSet = databaseMetaData.getTables("SNOWFLAKE", null, null, null);
int numSnowflakeTables = getSizeOfResultSet(snowflakeResultSet);

resultSet = databaseMetaData.getTables(null, null, null, null);
assertEquals(getAllObjectCountInDBViaInforSchema(getAllTable), getSizeOfResultSet(resultSet));
assertEquals(
getAllObjectCountInDBViaInforSchema(getAllTable),
getSizeOfResultSet(resultSet) - numSnowflakeTables);

resultSet = databaseMetaData.getTables(null, null, null, new String[] {"VIEW", "SYSTEM_TABLE"});
assertEquals(getAllObjectCountInDBViaInforSchema(getAllView), getSizeOfResultSet(resultSet));
assertEquals(
getAllObjectCountInDBViaInforSchema(getAllView),
getSizeOfResultSet(resultSet) - numSnowflakeTables);

resultSet =
databaseMetaData.getTables(null, null, null, new String[] {"TABLE", "SYSTEM_TABLE"});
Expand All @@ -477,17 +496,23 @@ public void testGetTables() throws SQLException {
resultSet =
databaseMetaData.getTables(
null, null, null, new String[] {"TABLE", "VIEW", "SYSTEM_TABLE"});
assertEquals(getAllObjectCountInDBViaInforSchema(getAllTable), getSizeOfResultSet(resultSet));
assertEquals(
getAllObjectCountInDBViaInforSchema(getAllTable),
getSizeOfResultSet(resultSet) - numSnowflakeTables);

resultSet = databaseMetaData.getTables(null, null, null, new String[] {"TABLE", "VIEW"});
assertEquals(getAllObjectCountInDBViaInforSchema(getAllTable), getSizeOfResultSet(resultSet));
assertEquals(
getAllObjectCountInDBViaInforSchema(getAllTable),
getSizeOfResultSet(resultSet) - numSnowflakeTables);

resultSet = databaseMetaData.getTables(null, null, null, new String[] {"TABLE"});
assertEquals(
getAllObjectCountInDBViaInforSchema(getAllBaseTable), getSizeOfResultSet(resultSet));

resultSet = databaseMetaData.getTables(null, null, null, new String[] {"VIEW"});
assertEquals(getAllObjectCountInDBViaInforSchema(getAllView), getSizeOfResultSet(resultSet));
assertEquals(
getAllObjectCountInDBViaInforSchema(getAllView),
getSizeOfResultSet(resultSet) - numSnowflakeTables);

resultSet =
databaseMetaData.getTables("JDBC_DB1", "JDBC_SCHEMA11", null, new String[] {"TABLE"});
Expand Down

0 comments on commit 4184f23

Please sign in to comment.