Skip to content

Commit

Permalink
Merge pull request #510 from OHDSI/cohort-service-test-fragile
Browse files Browse the repository at this point in the history
In CohortServiceTest, ignore whitespace to avoid os-specific false positives
  • Loading branch information
alex-odysseus authored Mar 14, 2022
2 parents 3ba1d42 + 000ed9f commit ab7ecbf
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,29 @@ public CohortServiceTest() throws IOException {
public void createPostgresSQLTest() {

final String sql = cohortService.translateSQL(MS_SQL_SQL_RESULT, null, POSTGRESQL, SESSION_ID, TEMP_SCHEMA, options);
Assert.assertEquals(POSTGRES_SQL_RESULT, sql);
assertSqlEquals(POSTGRES_SQL_RESULT, sql);
}

@Test
public void createRedshiftSQLTest(){

final String sql = cohortService.translateSQL(MS_SQL_SQL_RESULT, null, REDSHIFT, SESSION_ID, TEMP_SCHEMA,options);
Assert.assertEquals(REDSHIFT_SQL_RESULT, sql);
assertSqlEquals(REDSHIFT_SQL_RESULT, sql);
}

@Ignore("unexpected temp schema names")
@Test
public void createOracleSQLTest() {

final String sql = cohortService.translateSQL(MS_SQL_SQL_RESULT, null, ORACLE, SESSION_ID, TEMP_SCHEMA,options);
Assert.assertEquals(ORACLE_SQL_RESULT, sql);
assertSqlEquals(ORACLE_SQL_RESULT, sql);
}

@Test
public void createMSSQLTest(){

final String sql = cohortService.translateSQL(MS_SQL_SQL_RESULT, null, MS_SQL_SERVER, SESSION_ID, TEMP_SCHEMA,options);
Assert.assertEquals(MS_SQL_SQL_RESULT, sql);
assertSqlEquals(MS_SQL_SQL_RESULT, sql);
}

private static final String POSTGRES_SQL_RESULT = "CREATE TEMP TABLE Codesets (codeset_id int NOT NULL,\n" +
Expand Down Expand Up @@ -600,4 +600,12 @@ public void createMSSQLTest(){
"\n" +
"TRUNCATE TABLE #Codesets;\n" +
"DROP TABLE #Codesets";

private static void assertSqlEquals(String expected, String actual) {
Assert.assertEquals(removeEmptyLines(expected), removeEmptyLines(actual));
}

private static String removeEmptyLines(String sql) {
return sql.replaceAll("(?m)^[ \t]*\r?\n", "");
}
}

0 comments on commit ab7ecbf

Please sign in to comment.