]> source.dussan.org Git - sonarqube.git/commitdiff
[SONAR-18502] add test for index drop change
authorSteve Marion <unknown>
Thu, 23 Feb 2023 10:46:40 +0000 (11:46 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 23 Feb 2023 20:03:01 +0000 (20:03 +0000)
explicitely test the case where actual index is different and longer than authorized

server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java

index 663b1ba237f62f266b3316ff9a6e23cd82941ab7..9824d61eeb5cd72dd22126ba0450ab21bbabf7ad 100644 (file)
@@ -41,6 +41,16 @@ public class DropIndexProjectsModuleUuidInComponentsTest {
     db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
   }
 
+  @Test
+  public void execute_whenIndexNameWithPrefix_shouldStillDelete() throws SQLException {
+    String alteredIndexName = "idx_1234567891345678916456789_" + INDEX_NAME;
+    db.executeUpdateSql(String.format("ALTER INDEX %s RENAME TO %s;", INDEX_NAME, alteredIndexName));
+    db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
+    db.assertIndex(TABLE_NAME, alteredIndexName, COLUMN_NAME);
+    underTest.execute();
+    db.assertIndexDoesNotExist(TABLE_NAME, alteredIndexName);
+  }
+
   @Test
   public void migration_is_reentrant() throws SQLException {
     db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);