Enhance added JUnit test.
This commit is contained in:
parent
cc7ed1b036
commit
eb990e9a68
|
@ -39,12 +39,16 @@ public class DropColumnTest extends BaseTest {
|
|||
@Test
|
||||
public void testDropForeignKeyColumn() throws SQLException {
|
||||
executeSql("create table PARENT (PID bigint not null, TEXTCOL varchar(255), primary key (PID))");
|
||||
executeSql("create table CHILD (PID bigint not null, PARENTREF bigint)");
|
||||
executeSql("create table SIBLING (PID bigint not null, TEXTCOL varchar(255), primary key (PID))");
|
||||
executeSql("create table CHILD (PID bigint not null, PARENTREF bigint, SIBLINGREF bigint)");
|
||||
executeSql("alter table CHILD add constraint FK_MOM foreign key (PARENTREF) references PARENT(PID)");
|
||||
executeSql("alter table CHILD add constraint FK_BROTHER foreign key (SIBLINGREF) references SIBLING(PID)");
|
||||
|
||||
assertThat(JdbcUtils.getForeignKeys(getConnectionProperties(), "PARENT", "CHILD"), hasSize(1));
|
||||
assertThat(JdbcUtils.getForeignKeys(getConnectionProperties(), "SIBLING", "CHILD"), hasSize(1));
|
||||
|
||||
assertThat(JdbcUtils.getForeignKeysForColumn(getConnectionProperties(), "PARENTREF", "CHILD"), containsInAnyOrder("FK_MOM"));
|
||||
assertThat(JdbcUtils.getForeignKeysForColumn(getConnectionProperties(), "SIBLINGREF", "CHILD"), containsInAnyOrder("FK_BROTHER"));
|
||||
|
||||
DropColumnTask task = new DropColumnTask("1", "1");
|
||||
task.setTableName("CHILD");
|
||||
|
@ -53,9 +57,13 @@ public class DropColumnTest extends BaseTest {
|
|||
|
||||
getMigrator().migrate();
|
||||
|
||||
assertThat(JdbcUtils.getColumnNames(getConnectionProperties(), "CHILD"), containsInAnyOrder("PID"));
|
||||
assertThat(JdbcUtils.getColumnNames(getConnectionProperties(), "CHILD"), containsInAnyOrder("PID", "SIBLINGREF"));
|
||||
|
||||
assertThat(JdbcUtils.getForeignKeys(getConnectionProperties(), "PARENT", "CHILD"), empty());
|
||||
assertThat(JdbcUtils.getForeignKeys(getConnectionProperties(), "SIBLING", "CHILD"), hasSize(1));
|
||||
|
||||
assertThat(JdbcUtils.getForeignKeysForColumn(getConnectionProperties(), "PARENTREF", "CHILD"), empty());
|
||||
assertThat(JdbcUtils.getForeignKeysForColumn(getConnectionProperties(), "SIBLINGREF", "CHILD"), containsInAnyOrder("FK_BROTHER"));
|
||||
|
||||
// Do it again to make sure there is no error
|
||||
getMigrator().migrate();
|
||||
|
|
Loading…
Reference in New Issue