init schema test

This commit is contained in:
Ken Stevens 2019-11-01 21:40:24 -04:00
parent 3dc2770962
commit 6049ee6f1c
2 changed files with 30 additions and 1 deletions

View File

@ -33,7 +33,6 @@ public class AddTableTest extends BaseTest {
task.setTableName("SOMETABLE");
task.addSql(DriverTypeEnum.H2_EMBEDDED, "create table SOMETABLE (PID bigint not null, TEXTCOL varchar(255))");
getMigrator().addTask(task);
getMigrator().migrate();
assertThat(JdbcUtils.getTableNames(getConnectionProperties()), containsInAnyOrder("SOMETABLE"));

View File

@ -0,0 +1,30 @@
package ca.uhn.fhir.jpa.migrate.taskdef;
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
import ca.uhn.fhir.jpa.migrate.JdbcUtils;
import org.junit.Test;
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.*;
public class InitializeSchemaTaskTest extends BaseTest {
@Test
public void testInitializeTwice() throws SQLException {
InitializeSchemaTask task = new InitializeSchemaTask("1", "1", t -> getSql());
getMigrator().addTask(task);
getMigrator().migrate();
assertThat(JdbcUtils.getTableNames(getConnectionProperties()), containsInAnyOrder("SOMETABLE"));
// Second migrate runs without issue
getMigrator().migrate();
}
private List<String> getSql() {
return Collections.singletonList("create table SOMETABLE (PID bigint not null, TEXTCOL varchar(255))");
}
}