优化
This commit is contained in:
+20
-1
@@ -18,7 +18,26 @@ class Phase3ChannelContainerMigrationContractTest {
|
||||
|
||||
@Test
|
||||
void unifiedMigrationRestoresGuardsBeforeSurfacingFailures() throws Exception {
|
||||
assertSafeWindow(unifiedMigration(), true);
|
||||
String sql = unifiedMigration();
|
||||
assertSafeWindow(sql, true);
|
||||
assertNoDuplicateInboundColumns(sql);
|
||||
}
|
||||
|
||||
private static void assertNoDuplicateInboundColumns(String sql) {
|
||||
int tableStart = sql.indexOf("CREATE TABLE IF NOT EXISTS fl_inbound_order (");
|
||||
int tableEnd = sql.indexOf(") ENGINE=InnoDB", tableStart);
|
||||
String tableDefinition = sql.substring(tableStart, tableEnd);
|
||||
|
||||
assertThat(tableStart).isGreaterThan(0);
|
||||
assertThat(tableEnd).isGreaterThan(tableStart);
|
||||
assertThat(countOccurrences(tableDefinition, " warehouse_id BIGINT UNSIGNED")).isEqualTo(1);
|
||||
assertThat(countOccurrences(tableDefinition, " warehouse_name VARCHAR(128)")).isEqualTo(1);
|
||||
assertThat(countOccurrences(tableDefinition, " channel_code VARCHAR(64)")).isEqualTo(1);
|
||||
assertThat(countOccurrences(tableDefinition, " channel_name VARCHAR(128)")).isEqualTo(1);
|
||||
}
|
||||
|
||||
private static int countOccurrences(String text, String token) {
|
||||
return (text.length() - text.replace(token, "").length()) / token.length();
|
||||
}
|
||||
|
||||
private static void assertSafeWindow(String sql, boolean qualified) {
|
||||
|
||||
Reference in New Issue
Block a user