rdblue commented on code in PR #7569:
URL: https://github.com/apache/iceberg/pull/7569#discussion_r1199833435


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -1742,4 +1753,129 @@ public void 
testCatalogTokenRefreshDisabledWithCredential() {
             eq(catalogHeaders),
             any());
   }
+
+  @Test
+  public void multipleDiffsAgainstSingleTable() {
+    Namespace namespace = Namespace.of("namespace");
+    TableIdentifier identifier = TableIdentifier.of(namespace, 
"multipleDiffsAgainstSingleTable");
+
+    Transaction transaction = catalog().buildTable(identifier, 
SCHEMA).create().newTransaction();
+
+    UpdateSchema updateSchema =
+        transaction.updateSchema().addColumn("new_col", Types.LongType.get());
+    Schema expectedSchema = updateSchema.apply();
+    updateSchema.commit();
+
+    UpdatePartitionSpec updateSpec =
+        transaction.updateSpec().addField("shard", Expressions.bucket("id", 
16));
+    PartitionSpec expectedSpec = updateSpec.apply();
+    updateSpec.commit();
+
+    TableCommit tableCommit =
+        ImmutableTableCommit.builder()
+            .identifier(identifier)
+            .base(((BaseTransaction) transaction).startMetadata())
+            .changes(((BaseTransaction) 
transaction).currentMetadata().changes())
+            .build();
+
+    restCatalog.commitTransaction(ImmutableList.of(tableCommit));
+
+    Table loaded = catalog().loadTable(identifier);
+    
assertThat(loaded.schema().asStruct()).isEqualTo(expectedSchema.asStruct());
+    assertThat(loaded.spec().fields()).isEqualTo(expectedSpec.fields());
+  }
+
+  @Test
+  public void multipleDiffsAgainstMultipleTables() {
+    Namespace namespace = Namespace.of("multiDiffNamespace");
+    TableIdentifier identifier1 = TableIdentifier.of(namespace, 
"multiDiffTable1");
+    TableIdentifier identifier2 = TableIdentifier.of(namespace, 
"multiDiffTable2");
+
+    Transaction transaction1 = catalog().buildTable(identifier1, 
SCHEMA).create().newTransaction();
+    Transaction transaction2 = catalog().buildTable(identifier2, 
SCHEMA).create().newTransaction();
+
+    UpdateSchema updateSchema =
+        transaction1.updateSchema().addColumn("new_col", Types.LongType.get());
+    Schema expectedSchema = updateSchema.apply();
+    updateSchema.commit();
+
+    UpdateSchema updateSchema2 =
+        transaction2.updateSchema().addColumn("new_col2", 
Types.LongType.get());
+    Schema expectedSchema2 = updateSchema2.apply();
+    updateSchema2.commit();
+
+    TableCommit tableCommit1 =
+        ImmutableTableCommit.builder()
+            .identifier(identifier1)
+            .base(((BaseTransaction) transaction1).startMetadata())
+            .changes(((BaseTransaction) 
transaction1).currentMetadata().changes())
+            .build();
+
+    TableCommit tableCommit2 =
+        ImmutableTableCommit.builder()
+            .identifier(identifier2)
+            .base(((BaseTransaction) transaction2).startMetadata())
+            .changes(((BaseTransaction) 
transaction2).currentMetadata().changes())
+            .build();
+
+    restCatalog.commitTransaction(ImmutableList.of(tableCommit1, 
tableCommit2));

Review Comment:
   To make things like this easier, we tend to add convenience methods, like 
`commitTransaction(TableCommit... commits)` with a default that creates the 
`ImmutableList`. That makes tests a bit easier to read and write.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to