nastra commented on code in PR #10369:
URL: https://github.com/apache/iceberg/pull/10369#discussion_r1624504977


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2655,6 +2656,68 @@ public void testCleanupCleanableExceptionsReplace() {
         .isInstanceOf(NotFoundException.class);
   }
 
+  @ParameterizedTest
+  @ValueSource(strings = {"1", "2"})
+  public void testCreateTableTransaction(String formatVersion) {
+    RESTCatalogAdapter adapter = Mockito.spy(new 
RESTCatalogAdapter(backendCatalog));
+    RESTCatalog catalog = catalog(adapter);
+
+    if (requiresNamespaceCreate()) {
+      catalog.createNamespace(NS);
+    }
+
+    // Test create table transaction with no data file
+    Transaction createTableTransaction1 =
+        catalog.newCreateTableTransaction(
+            TableIdentifier.of(NS, "table1"),
+            SCHEMA,
+            PartitionSpec.unpartitioned(),
+            ImmutableMap.of("format-version", formatVersion));
+    assertThatNoException().isThrownBy(() -> 
createTableTransaction1.commitTransaction());

Review Comment:
   rather than checking that no exception was thrown it would be better to just 
load the table and ensure it exists.
   
   Something like this short piece should be enough:
   
   ```
   @ParameterizedTest
     @ValueSource(ints = {1, 2})
     public void createTableTransaction(int formatVersion) {
       RESTCatalogAdapter adapter = Mockito.spy(new 
RESTCatalogAdapter(backendCatalog));
       RESTCatalog catalog = catalog(adapter);
   
       if (requiresNamespaceCreate()) {
         catalog.createNamespace(NS);
       }
   
       catalog
           .newCreateTableTransaction(
               TABLE,
               SCHEMA,
               PartitionSpec.unpartitioned(),
               ImmutableMap.of("format-version", String.valueOf(formatVersion)))
           .commitTransaction();
   
       BaseTable table = (BaseTable) catalog.loadTable(TABLE);
       
assertThat(table.operations().current().formatVersion()).isEqualTo(formatVersion);
     }
   ```
   Can you please also update the other test accordingly?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to