This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 830ea81bc5bf3879d9c2e7247b39220fb9224343
Author: Quan Tran <hqt...@linagora.com>
AuthorDate: Thu Dec 7 13:04:34 2023 +0700

    JAMES-2586 Add a unit test for recreate RLS column should not fail
    
    Fixed by JAMES-2586 Small codestyle refactorings.
---
 .../backends/postgres/PostgresTableManagerTest.java | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git 
a/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresTableManagerTest.java
 
b/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresTableManagerTest.java
index e0150d79db..9b9563d642 100644
--- 
a/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresTableManagerTest.java
+++ 
b/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresTableManagerTest.java
@@ -27,7 +27,6 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 
 import org.apache.commons.lang3.tuple.Pair;
-import org.apache.james.backends.postgres.utils.PostgresExecutor;
 import org.jooq.impl.DSL;
 import org.jooq.impl.SQLDataType;
 import org.junit.jupiter.api.Test;
@@ -39,7 +38,7 @@ import reactor.core.publisher.Mono;
 class PostgresTableManagerTest {
 
     @RegisterExtension
-    static PostgresExtension postgresExtension = PostgresExtension.empty();
+    static PostgresExtension postgresExtension = 
PostgresExtension.withRowLevelSecurity(PostgresModule.EMPTY_MODULE);
 
     Function<PostgresModule, PostgresTableManager> tableManagerFactory =
         module -> new 
PostgresTableManager(postgresExtension.getPostgresExecutor(), module, true);
@@ -342,6 +341,24 @@ class PostgresTableManagerTest {
             .doesNotContain(rlsColumn);
     }
 
+    @Test
+    void recreateRLSColumnWhenExistedShouldNotFail() {
+        String tableName = "tablename1";
+
+        PostgresTable rlsTable = PostgresTable.name(tableName)
+            .createTableStep((dsl, tbn) -> dsl.createTable(tbn)
+                .column("colum1", SQLDataType.UUID.notNull()))
+            .supportsRowLevelSecurity();
+
+        PostgresModule module = PostgresModule.table(rlsTable);
+
+        PostgresTableManager testee = tableManagerFactory.apply(module);
+        testee.initializeTables().block();
+
+        assertThatCode(() -> testee.initializeTables().block())
+            .doesNotThrowAnyException();
+    }
+
     private List<Pair<String, String>> getColumnNameAndDataType(String 
tableName) {
         return postgresExtension.getConnection()
             .flatMapMany(connection -> 
Flux.from(Mono.from(connection.createStatement("SELECT table_name, column_name, 
data_type FROM information_schema.columns WHERE table_name = $1;")


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to