snazy commented on code in PR #8857:
URL: https://github.com/apache/iceberg/pull/8857#discussion_r1410786552


##########
nessie/src/test/java/org/apache/iceberg/nessie/TestMultipleClients.java:
##########
@@ -67,33 +71,84 @@ public void afterEach() throws Exception {
   }
 
   @Test
-  public void testListNamespaces() {
+  public void testListNamespaces() throws NessieConflictException, 
NessieNotFoundException {
+    Assertions.assertThat(catalog.listNamespaces()).isEmpty();
+    Assertions.assertThat(anotherCatalog.listNamespaces()).isEmpty();
+
+    // listing a non-existent namespace should return empty
+    
Assertions.assertThat(catalog.listNamespaces(Namespace.of("db1"))).isEmpty();
+    
Assertions.assertThat(anotherCatalog.listNamespaces(Namespace.of("db1"))).isEmpty();
+
     catalog.createNamespace(Namespace.of("db1"), Collections.emptyMap());
+
     
Assertions.assertThat(catalog.listNamespaces()).containsExactlyInAnyOrder(Namespace.of("db1"));
+    Assertions.assertThat(anotherCatalog.listNamespaces())
+        .containsExactlyInAnyOrder(Namespace.of("db1"));
 
     // another client creates a namespace with the same nessie server
     anotherCatalog.createNamespace(Namespace.of("db2"), 
Collections.emptyMap());
-    Assertions.assertThat(anotherCatalog.listNamespaces())
-        .containsExactlyInAnyOrder(Namespace.of("db1"), Namespace.of("db2"));
 
     Assertions.assertThat(catalog.listNamespaces())
         .containsExactlyInAnyOrder(Namespace.of("db1"), Namespace.of("db2"));
+    Assertions.assertThat(anotherCatalog.listNamespaces())
+        .containsExactlyInAnyOrder(Namespace.of("db1"), Namespace.of("db2"));
+
+    api.deleteBranch().branch((Branch) 
api.getReference().refName(branch).get()).delete();
+
+    Assertions.assertThatThrownBy(() -> catalog.listNamespaces())
+        .hasMessageContaining(
+            "Cannot list top-level namespaces: ref '%s' is no longer valid", 
branch);
+    Assertions.assertThatThrownBy(() -> 
anotherCatalog.listNamespaces(Namespace.of("db1")))
+        .hasMessageContaining(
+            "Cannot list child namespaces from 'db1': ref '%s' is no longer 
valid", branch);
   }
 
   @Test
-  public void testLoadNamespaceMetadata() {
+  public void testLoadNamespaceMetadata() throws NessieConflictException, 
NessieNotFoundException {
+
+    Assertions.assertThatThrownBy(() -> 
catalog.loadNamespaceMetadata(Namespace.of("namespace1")))

Review Comment:
   It's tricky - I think both kinds of operations should operate on the same 
ref+hash.
   For example, you read from a table (and get the "latest greatest", but 
cannot commit, because the last known hash points to an older commit that's 
different from HEAD.
   
   I'd favor to keep the existing behavior to not surprise users and revisit 
this later in a separate PR. WDYT?



-- 
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