zeroshade commented on code in PR #290:
URL: https://github.com/apache/iceberg-go/pull/290#discussion_r1953483382


##########
catalog/rest/rest_test.go:
##########
@@ -1330,6 +1331,252 @@ func (r *RestCatalogSuite) TestRegisterTable409() {
        r.ErrorContains(err, "The given table already exists")
 }
 
+func (r *RestCatalogSuite) TestListViews200() {
+       customPageSize := 100
+       namespace := "accounting"
+       r.mux.HandleFunc("/v1/namespaces/"+namespace+"/views", func(w 
http.ResponseWriter, req *http.Request) {
+               r.Require().Equal(http.MethodGet, req.Method)
+
+               for k, v := range TestHeaders {
+                       r.Equal(v, req.Header.Values(k))
+               }
+
+               pageToken := req.URL.Query().Get("page-token")
+               pageSize := req.URL.Query().Get("page-size")
+               r.Equal("", pageToken)
+               r.Equal(strconv.Itoa(customPageSize), pageSize)
+
+               json.NewEncoder(w).Encode(map[string]any{
+                       "identifiers": []any{
+                               map[string]any{
+                                       "namespace": []string{"accounting", 
"tax"},
+                                       "name":      "paid",
+                               },
+                               map[string]any{
+                                       "namespace": []string{"accounting", 
"tax"},
+                                       "name":      "owed",
+                               },
+                       },
+               })
+       })
+
+       // Passing in a custom page size through context
+       ctx := context.WithValue(context.Background(), "page_size", 
customPageSize)
+       cat, err := rest.NewCatalog(ctx, "rest", r.srv.URL, 
rest.WithOAuthToken(TestToken))
+       r.Require().NoError(err)
+
+       var lastErr error
+       views := make([]table.Identifier, 0)
+       iter := cat.ListViews(ctx, catalog.ToIdentifier(namespace))
+
+       for view, err := range iter {
+               views = append(views, view)
+               if err != nil {
+                       lastErr = err
+                       r.FailNow("unexpected error:", err)
+               }
+       }
+
+       r.Equal([]table.Identifier{
+               {"accounting", "tax", "paid"},
+               {"accounting", "tax", "owed"},
+       }, views)
+       r.Require().NoError(lastErr)
+}
+
+func (r *RestCatalogSuite) TestListViewsPagination() {

Review Comment:
   needs one more test case that errors on one of the pages so that you get a 
few views and then eventually get an error (ensure that errors on subsequent 
pages are caught)



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