Skip to content

Commit

Permalink
#69 - Extra tests for regression introduced by the prior commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed Jul 25, 2019
1 parent 85d9708 commit 3c3b6ee
Show file tree
Hide file tree
Showing 6 changed files with 11,269 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
*.autofetch
*create-all.sql
*drop-all.sql
*.orig
.classpath
.project
Expand Down
50 changes: 50 additions & 0 deletions src/test/java/io/ebean/migration/ddl/DdlParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,56 @@ public void parse_sqlserver_create_procs() throws FileNotFoundException {
"END");
}


@Test
public void parse_postgres_procs() throws FileNotFoundException {

FileReader fr = new FileReader("src/test/resources/dbmig_postgres/ex1.sql");
final List<String> statements = parser.parse(fr);

assertThat(statements).hasSize(3);
assertThat(statements.get(0)).isEqualTo("create or replace function hx_link_history_version() returns trigger as $$\n" +
"begin\n" +
"\n" +
"end;\n" +
"$$ LANGUAGE plpgsql;");

assertThat(statements.get(1)).isEqualTo("create trigger hx_link_history_upd\n" +
" before update or delete on hx_link\n" +
" for each row execute procedure hx_link_history_version();");

assertThat(statements.get(2)).isEqualTo("create or replace function hi_link_history_version() returns trigger as $$\n" +
"begin\n" +
"end;\n" +
"$$ LANGUAGE plpgsql;");
}


@Test
public void parse_postgres_createAll() throws FileNotFoundException {

FileReader fr = new FileReader("src/test/resources/dbmig_postgres/pg-create-all.sql");
final List<String> statements = parser.parse(fr);

assertThat(statements).hasSize(1013);
}

@Test
public void parse_mysql_createAll() throws FileNotFoundException {

FileReader fr = new FileReader("src/test/resources/dbmig_mysql/mysql-create-all.sql");
final List<String> statements = parser.parse(fr);
assertThat(statements).hasSize(1010);
}

@Test
public void parse_mysql_dropAll() throws FileNotFoundException {

FileReader fr = new FileReader("src/test/resources/dbmig_mysql/mysql-drop-all.sql");
final List<String> statements = parser.parse(fr);
assertThat(statements).hasSize(997);
}

@Test
public void parse_ignoresEmptyLines() {

Expand Down
Loading

0 comments on commit 3c3b6ee

Please sign in to comment.