test(sql): align contracts with clean initialization
This commit is contained in:
+12
-4
@@ -28,11 +28,19 @@ class LocalLooseboardSchemaContractTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void unifiedIncrementalContainsHistoryIdempotencyAndOperationLedger() throws Exception {
|
||||
void unifiedInitializationContainsHistoryIdempotencyAndOperationLedger() throws Exception {
|
||||
String sql = Files.readString(Path.of("..", "deploy", "sql", "海外区域统一增量-MySQL8.sql"),
|
||||
StandardCharsets.UTF_8);
|
||||
assertTrue(sql.contains("CREATE TABLE IF NOT EXISTS ll_local_looseboard_operation"));
|
||||
assertTrue(sql.contains("uk_ll_local_looseboard_operation_key(customer_id,order_id,idempotency_key)"));
|
||||
assertTrue(sql.contains("table_name='ll_local_looseboard_history' AND column_name='idempotency_key'"));
|
||||
String normalized = sql.replaceAll("\\s+", "");
|
||||
assertTrue(sql.contains("CREATE TABLE ll_local_looseboard_operation"));
|
||||
assertTrue(normalized.contains("uk_ll_local_looseboard_operation_key(customer_id,order_id,idempotency_key)"));
|
||||
assertTrue(tableBlock(sql, "ll_local_looseboard_history").contains("idempotency_key varchar(255)"));
|
||||
org.junit.jupiter.api.Assertions.assertFalse(sql.contains("ALTER TABLE ll_local_looseboard_history"));
|
||||
}
|
||||
|
||||
private static String tableBlock(String sql, String table) {
|
||||
int start = sql.indexOf("CREATE TABLE " + table + " (");
|
||||
int end = sql.indexOf(";", start);
|
||||
return start < 0 || end < 0 ? "" : sql.substring(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user