This is an automated email from the ASF dual-hosted git repository.
laskoviymishka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new c1dad7f57 chore(rest): Avoid fatal assertions in test handlers (#2103)
c1dad7f57 is described below
commit c1dad7f57e427b8a1ce52c9ac85b3f3edd38366a
Author: Alessandro Nori <[email protected]>
AuthorDate: Mon Oct 5 23:03:34 2026 +0200
chore(rest): Avoid fatal assertions in test handlers (#2103)
* Avoid fatal assertions in handlers
* Expand raw-name request coverage
* Fix lint in request test
* Remove remaining fatal handler assertions
* Rename request payload decoder
* Remove remaining fatal handler calls
---
catalog/rest/rest_functions_test.go | 40 +++-
catalog/rest/rest_internal_test.go | 16 +-
catalog/rest/rest_test.go | 393 +++++++++++++++++++++++--------
catalog/rest/scan_planning_retry_test.go | 8 +-
catalog/rest/scan_planning_test.go | 268 +++++++++++++++------
catalog/rest/wait_for_plan_test.go | 68 ++++--
6 files changed, 594 insertions(+), 199 deletions(-)
diff --git a/catalog/rest/rest_functions_test.go
b/catalog/rest/rest_functions_test.go
index 4907443f9..9f94d8270 100644
--- a/catalog/rest/rest_functions_test.go
+++ b/catalog/rest/rest_functions_test.go
@@ -61,7 +61,9 @@ func (r *RestCatalogSuite) TestListFunctions200() {
customPageSize := 100
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/functions", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -102,7 +104,9 @@ func (r *RestCatalogSuite) TestListFunctions200() {
func (r *RestCatalogSuite) TestListFunctionsPagination() {
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/functions", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
switch req.URL.Query().Get("pageToken") {
case "":
@@ -115,7 +119,7 @@ func (r *RestCatalogSuite) TestListFunctionsPagination() {
"identifiers": []any{[]string{"accounting",
"add_two"}},
})
default:
- r.FailNow("unexpected page token")
+ r.Fail("unexpected page token")
}
})
@@ -145,7 +149,9 @@ func (r *RestCatalogSuite) TestListFunctionsPagination() {
func (r *RestCatalogSuite) TestListFunctionsZeroPageSizeNotSent() {
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/functions", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Equal("", req.URL.Query().Get("pageSize"), "pageSize must not
be sent when set to 0")
json.NewEncoder(w).Encode(map[string]any{"identifiers":
[]any{}})
})
@@ -162,7 +168,9 @@ func (r *RestCatalogSuite)
TestListFunctionsZeroPageSizeNotSent() {
func (r *RestCatalogSuite) TestListFunctionsPaginationErrorOnSubsequentPage() {
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/functions", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -197,7 +205,7 @@ func (r *RestCatalogSuite)
TestListFunctionsPaginationErrorOnSubsequentPage() {
return
}
- r.FailNow("unexpected page token:", pageToken)
+ r.Fail("unexpected page token:", pageToken)
})
cat, err := rest.NewCatalog(context.Background(), "rest", r.srv.URL,
rest.WithOAuthToken(TestToken))
@@ -228,7 +236,9 @@ func (r *RestCatalogSuite)
TestListFunctionsPaginationErrorOnSubsequentPage() {
func (r *RestCatalogSuite) TestListFunctions404() {
namespace := "nonexistent"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/functions", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -261,7 +271,9 @@ func (r *RestCatalogSuite) TestListFunctions404() {
func (r *RestCatalogSuite) TestLoadFunction200() {
r.mux.HandleFunc("/v1/namespaces/accounting/functions/add_one", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -291,7 +303,9 @@ func (r *RestCatalogSuite) TestLoadFunction200() {
func (r *RestCatalogSuite) TestLoadFunction404() {
r.mux.HandleFunc("/v1/namespaces/accounting/functions/missing_fn",
func(w http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
w.WriteHeader(http.StatusNotFound)
json.NewEncoder(w).Encode(map[string]any{
@@ -313,7 +327,9 @@ func (r *RestCatalogSuite) TestLoadFunction404() {
func (r *RestCatalogSuite) TestLoadFunction404Namespace() {
r.mux.HandleFunc("/v1/namespaces/ghost_ns/functions/some_fn", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
w.WriteHeader(http.StatusNotFound)
json.NewEncoder(w).Encode(map[string]any{
@@ -369,7 +385,9 @@ func (r *RestCatalogSuite)
TestLoadFunctionMalformedMetadata() {
func (r *RestCatalogSuite) TestCheckFunctionExists() {
r.mux.HandleFunc("/v1/namespaces/accounting/functions/add_one", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method, "existence must
be checked via GET: the spec has no HEAD endpoint")
+ if !r.Equal(http.MethodGet, req.Method, "existence must be
checked via GET: the spec has no HEAD endpoint") {
+ return
+ }
w.Write([]byte(`{"metadata": ` + testFunctionMetadataJSON +
`}`))
})
diff --git a/catalog/rest/rest_internal_test.go
b/catalog/rest/rest_internal_test.go
index c16ad2db5..c3eb75da9 100644
--- a/catalog/rest/rest_internal_test.go
+++ b/catalog/rest/rest_internal_test.go
@@ -232,7 +232,9 @@ func TestLoadRegisteredCatalogAcceptsValidAuthURL(t
*testing.T) {
oauthCalled.Store(true)
assert.Equal(t, http.MethodPost, req.Method)
- require.NoError(t, req.ParseForm())
+ if !assert.NoError(t, req.ParseForm()) {
+ return
+ }
assert.Equal(t, "client", req.PostForm.Get("client_id"))
assert.Equal(t, "secret", req.PostForm.Get("client_secret"))
@@ -592,7 +594,9 @@ func TestOAuthTokenRequestParams(t *testing.T) {
assert.Equal(t, http.MethodPost, req.Method)
assert.Equal(t,
"application/x-www-form-urlencoded", req.Header.Get("Content-Type"))
- require.NoError(t, req.ParseForm())
+ if !assert.NoError(t, req.ParseForm()) {
+ return
+ }
values := req.PostForm
assert.Equal(t, "client_credentials",
values.Get("grant_type"))
assert.Equal(t, "secret",
values.Get("client_secret"))
@@ -766,7 +770,9 @@ func TestAuthHeader(t *testing.T) {
assert.Equal(t, req.Header.Get("Content-Type"),
"application/x-www-form-urlencoded")
- require.NoError(t, req.ParseForm())
+ if !assert.NoError(t, req.ParseForm()) {
+ return
+ }
values := req.PostForm
assert.Equal(t, "client_credentials", values.Get("grant_type"))
assert.Equal(t, "client", values.Get("client_id"))
@@ -824,7 +830,9 @@ func TestAuthUriHeader(t *testing.T) {
assert.Equal(t, req.Header.Get("Content-Type"),
"application/x-www-form-urlencoded")
- require.NoError(t, req.ParseForm())
+ if !assert.NoError(t, req.ParseForm()) {
+ return
+ }
values := req.PostForm
assert.Equal(t, "client_credentials", values.Get("grant_type"))
assert.Equal(t, "client", values.Get("client_id"))
diff --git a/catalog/rest/rest_test.go b/catalog/rest/rest_test.go
index 75f86c13a..0655da244 100644
--- a/catalog/rest/rest_test.go
+++ b/catalog/rest/rest_test.go
@@ -71,7 +71,9 @@ func (r *RestCatalogSuite) SetupTest() {
r.mux = http.NewServeMux()
r.mux.HandleFunc("/v1/config", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.configVals = req.URL.Query()
json.NewEncoder(w).Encode(map[string]any{
@@ -95,7 +97,9 @@ func TestRESTRejectsTrailingJSONInGetResponse(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/v1/config", func(w http.ResponseWriter, _
*http.Request) {
_, err :=
w.Write([]byte(`{"defaults":{},"overrides":{},"endpoints":[]} {}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
srv := httptest.NewServer(mux)
defer srv.Close()
@@ -108,15 +112,19 @@ func TestRESTRejectsTrailingJSONInGetResponse(t
*testing.T) {
func TestRESTRejectsTrailingJSONInPostResponse(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/v1/config", func(w http.ResponseWriter, _
*http.Request) {
- require.NoError(t, json.NewEncoder(w).Encode(map[string]any{
+ if !assert.NoError(t, json.NewEncoder(w).Encode(map[string]any{
"defaults": map[string]any{},
"overrides": map[string]any{},
"endpoints": rest.AllEndpointStrings,
- }))
+ })) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/fokko/tables", func(w
http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte(createTableRestExample + `{}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
srv := httptest.NewServer(mux)
defer srv.Close()
@@ -135,7 +143,9 @@ func (r *RestCatalogSuite) TestToken200() {
r.Equal(req.Header.Get("Content-Type"),
"application/x-www-form-urlencoded")
- r.Require().NoError(req.ParseForm())
+ if !r.NoError(req.ParseForm()) {
+ return
+ }
values := req.PostForm
r.Equal(values.Get("grant_type"), "client_credentials")
r.Equal(values.Get("client_id"), "client")
@@ -168,7 +178,9 @@ func (r *RestCatalogSuite) TestLoadRegisteredCatalog() {
r.Equal(req.Header.Get("Content-Type"),
"application/x-www-form-urlencoded")
- r.Require().NoError(req.ParseForm())
+ if !r.NoError(req.ParseForm()) {
+ return
+ }
values := req.PostForm
r.Equal(values.Get("grant_type"), "client_credentials")
r.Equal(values.Get("client_id"), "client")
@@ -224,7 +236,9 @@ func (r *RestCatalogSuite) TestToken200AuthUrl() {
r.Equal(req.Header.Get("Content-Type"),
"application/x-www-form-urlencoded")
- r.Require().NoError(req.ParseForm())
+ if !r.NoError(req.ParseForm()) {
+ return
+ }
values := req.PostForm
r.Equal(values.Get("grant_type"), "client_credentials")
r.Equal(values.Get("client_id"), "client")
@@ -304,7 +318,9 @@ func (r *RestCatalogSuite) TestWithHeaders() {
}
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
// Check for standard headers
for k, v := range TestHeaders {
@@ -340,7 +356,9 @@ func (r *RestCatalogSuite)
TestAdditionalPropsHeaderPrefix() {
customHeaderValue := "my-project"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Equal(customHeaderValue,
req.Header.Get("x-goog-user-project"))
json.NewEncoder(w).Encode(map[string]any{"identifiers":
[]any{}})
})
@@ -428,7 +446,9 @@ func (r *RestCatalogSuite) TestListTables200() {
namespace := "examples"
customPageSize := 100
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -474,7 +494,9 @@ func (r *RestCatalogSuite) TestListTablesPrefixed200() {
r.Equal(req.Header.Get("Content-Type"),
"application/x-www-form-urlencoded")
- r.Require().NoError(req.ParseForm())
+ if !r.NoError(req.ParseForm()) {
+ return
+ }
values := req.PostForm
r.Equal(values.Get("grant_type"), "client_credentials")
r.Equal(values.Get("client_id"), "client")
@@ -492,7 +514,9 @@ func (r *RestCatalogSuite) TestListTablesPrefixed200() {
namespace := "examples"
r.mux.HandleFunc("/v1/prefix/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -541,7 +565,9 @@ func (r *RestCatalogSuite) TestListTablesPagination() {
defaultPageSize := 20
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -684,7 +710,9 @@ func (r *RestCatalogSuite) TestListTablesPaginationCycle() {
func (r *RestCatalogSuite) TestListTablesPaginationErrorOnSubsequentPage() {
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -725,7 +753,7 @@ func (r *RestCatalogSuite)
TestListTablesPaginationErrorOnSubsequentPage() {
return
}
- r.FailNow("unexpected page token:", pageToken)
+ r.Fail("unexpected page token:", pageToken)
})
cat, err := rest.NewCatalog(context.Background(), "rest", r.srv.URL,
rest.WithOAuthToken(TestToken))
@@ -757,7 +785,9 @@ func (r *RestCatalogSuite)
TestListTablesPaginationErrorOnSubsequentPage() {
func (r *RestCatalogSuite) TestListTables404() {
namespace := "examples"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -797,7 +827,9 @@ func (r *RestCatalogSuite) TestListTables404() {
func (r *RestCatalogSuite) TestListNamespaces200() {
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -821,8 +853,12 @@ func (r *RestCatalogSuite) TestListNamespaces200() {
func (r *RestCatalogSuite) TestListNamespaceWithParent200() {
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
- r.Require().Equal("accounting", req.URL.Query().Get("parent"))
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
+ if !r.Equal("accounting", req.URL.Query().Get("parent")) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -887,7 +923,9 @@ func (r *RestCatalogSuite)
TestNamespaceOperationsRejectInvalidComponents() {
func (r *RestCatalogSuite) TestListNamespaces400() {
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -916,7 +954,9 @@ func (r *RestCatalogSuite) TestListNamespacesPagination() {
requestCount := 0
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -965,8 +1005,12 @@ func (r *RestCatalogSuite) TestListNamespacesPagination()
{
func (r *RestCatalogSuite) TestCreateNamespace200() {
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
- r.Require().Equal("application/json",
req.Header.Get("Content-Type"))
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
+ if !r.Equal("application/json", req.Header.Get("Content-Type"))
{
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -979,7 +1023,9 @@ func (r *RestCatalogSuite) TestCreateNamespace200() {
Props iceberg.Properties `json:"properties"`
}{}
- r.Require().NoError(dec.Decode(&body))
+ if !r.NoError(dec.Decode(&body)) {
+ return
+ }
r.Equal(table.Identifier{"leden"}, body.Namespace)
r.Empty(body.Props)
@@ -996,7 +1042,9 @@ func (r *RestCatalogSuite) TestCreateNamespace200() {
func (r *RestCatalogSuite) TestCheckNamespaceExists204() {
r.mux.HandleFunc("/v1/namespaces/leden", func(w http.ResponseWriter,
req *http.Request) {
- r.Require().Equal(http.MethodHead, req.Method)
+ if !r.Equal(http.MethodHead, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1013,7 +1061,9 @@ func (r *RestCatalogSuite) TestCheckNamespaceExists204() {
func (r *RestCatalogSuite) TestCheckNamespaceExists404() {
r.mux.HandleFunc("/v1/namespaces/noneexistent", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodHead, req.Method)
+ if !r.Equal(http.MethodHead, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1042,8 +1092,12 @@ func (r *RestCatalogSuite) TestCheckNamespaceExists404()
{
func (r *RestCatalogSuite) TestCreateNamespaceWithProps200() {
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
- r.Require().Equal("application/json",
req.Header.Get("Content-Type"))
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
+ if !r.Equal("application/json", req.Header.Get("Content-Type"))
{
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1056,7 +1110,9 @@ func (r *RestCatalogSuite)
TestCreateNamespaceWithProps200() {
Props iceberg.Properties `json:"properties"`
}{}
- r.Require().NoError(dec.Decode(&body))
+ if !r.NoError(dec.Decode(&body)) {
+ return
+ }
r.Equal(table.Identifier{"leden"}, body.Namespace)
r.Equal(iceberg.Properties{"foo": "bar", "super": "duper"},
body.Props)
@@ -1073,8 +1129,12 @@ func (r *RestCatalogSuite)
TestCreateNamespaceWithProps200() {
func (r *RestCatalogSuite) TestCreateNamespace409() {
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
- r.Require().Equal("application/json",
req.Header.Get("Content-Type"))
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
+ if !r.Equal("application/json", req.Header.Get("Content-Type"))
{
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1087,7 +1147,9 @@ func (r *RestCatalogSuite) TestCreateNamespace409() {
Props iceberg.Properties `json:"properties"`
}{}
- r.Require().NoError(dec.Decode(&body))
+ if !r.NoError(dec.Decode(&body)) {
+ return
+ }
r.Equal(table.Identifier{"fokko"}, body.Namespace)
r.Empty(body.Props)
@@ -1111,7 +1173,9 @@ func (r *RestCatalogSuite) TestCreateNamespace409() {
func (r *RestCatalogSuite) TestDropNamespace204() {
r.mux.HandleFunc("/v1/namespaces/examples", func(w http.ResponseWriter,
req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1128,7 +1192,9 @@ func (r *RestCatalogSuite) TestDropNamespace204() {
func (r *RestCatalogSuite) TestDropNamespace404() {
r.mux.HandleFunc("/v1/namespaces/examples", func(w http.ResponseWriter,
req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1154,7 +1220,9 @@ func (r *RestCatalogSuite) TestDropNamespace404() {
func (r *RestCatalogSuite) TestDropNamespace409() {
r.mux.HandleFunc("/v1/namespaces/examples", func(w http.ResponseWriter,
req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1180,7 +1248,9 @@ func (r *RestCatalogSuite) TestDropNamespace409() {
func (r *RestCatalogSuite) TestLoadNamespaceProps200() {
r.mux.HandleFunc("/v1/namespaces/leden", func(w http.ResponseWriter,
req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1203,7 +1273,9 @@ func (r *RestCatalogSuite) TestLoadNamespaceProps200() {
func (r *RestCatalogSuite) TestLoadNamespaceProps404() {
r.mux.HandleFunc("/v1/namespaces/leden", func(w http.ResponseWriter,
req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1229,7 +1301,9 @@ func (r *RestCatalogSuite) TestLoadNamespaceProps404() {
func (r *RestCatalogSuite) TestUpdateNamespaceProps200() {
r.mux.HandleFunc("/v1/namespaces/fokko/properties", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1258,7 +1332,9 @@ func (r *RestCatalogSuite) TestUpdateNamespaceProps200() {
func (r *RestCatalogSuite) TestUpdateNamespaceProps404() {
r.mux.HandleFunc("/v1/namespaces/fokko/properties", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1349,7 +1425,9 @@ var (
func (r *RestCatalogSuite) TestCreateTable200() {
r.mux.HandleFunc("/v1/namespaces/fokko/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1385,7 +1463,9 @@ func (r *RestCatalogSuite) TestCreateTable200() {
func (r *RestCatalogSuite) TestCreateTable409() {
// Mock the create table endpoint with 409 response
r.mux.HandleFunc("/v1/namespaces/fokko/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1474,7 +1554,9 @@ func TestServerVendedReporterImplIgnored(t *testing.T) {
func (r *RestCatalogSuite) TestCheckTableExists204() {
r.mux.HandleFunc("/v1/namespaces/fokko/tables/fokko2", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodHead, req.Method)
+ if !r.Equal(http.MethodHead, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1492,7 +1574,9 @@ func (r *RestCatalogSuite) TestCheckTableExists204() {
func (r *RestCatalogSuite) TestCheckTableExists404() {
r.mux.HandleFunc("/v1/namespaces/fokko/tables/nonexistent", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodHead, req.Method)
+ if !r.Equal(http.MethodHead, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1517,7 +1601,9 @@ func (r *RestCatalogSuite) TestCheckTableExists404() {
func (r *RestCatalogSuite) TestLoadTable200() {
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Empty(req.URL.Query().Get("snapshots"), "LoadTable must not
send ?snapshots by default")
for k, v := range TestHeaders {
@@ -1639,7 +1725,9 @@ func (r *RestCatalogSuite) TestLoadTable200() {
func (r *RestCatalogSuite) TestLoadTableLabels() {
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
w.Write([]byte(`{
"metadata-location":
"s3://warehouse/database/table/metadata/00001.metadata.json",
"metadata": {
@@ -1687,7 +1775,9 @@ func (r *RestCatalogSuite) TestLoadTableLabels() {
func (r *RestCatalogSuite) TestCreateTableLabels() {
r.mux.HandleFunc("/v1/namespaces/fokko/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
w.Write([]byte(`{
"metadata-location":
"s3://warehouse/database/table/metadata/00001.metadata.json",
"metadata": {
@@ -1730,7 +1820,9 @@ func (r *RestCatalogSuite) TestCreateTableLabels() {
func (r *RestCatalogSuite) TestLoadTableWithSnapshotModeRefs() {
// Server returns only the snapshot referenced by the main branch (refs
behaviour).
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Equal("refs", req.URL.Query().Get("snapshots"))
w.Write([]byte(`{
"metadata-location":
"s3://warehouse/database/table/metadata/00002.gz.metadata.json",
@@ -1787,7 +1879,9 @@ func (r *RestCatalogSuite)
TestLoadTableWithSnapshotModeRefs() {
func (r *RestCatalogSuite) TestLoadTableWithSnapshotModeAll() {
// Server returns all snapshots including unreferenced historical ones
(all behaviour).
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Equal("all", req.URL.Query().Get("snapshots"))
w.Write([]byte(`{
"metadata-location":
"s3://warehouse/database/table/metadata/00002.gz.metadata.json",
@@ -1853,7 +1947,9 @@ func (r *RestCatalogSuite)
TestLoadTableWithSnapshotModeAll() {
func (r *RestCatalogSuite) TestRenameTable204() {
// Mock the rename table endpoint
r.mux.HandleFunc("/v1/tables/rename", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1880,7 +1976,9 @@ func (r *RestCatalogSuite) TestRenameTable204() {
// Mock the get table endpoint for loading the renamed table
r.mux.HandleFunc("/v1/namespaces/fokko/tables/destination", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1913,7 +2011,9 @@ func (r *RestCatalogSuite) TestRenameTable204() {
func (r *RestCatalogSuite) TestDropTable204() {
// Mock the drop table endpoint
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1936,7 +2036,9 @@ func (r *RestCatalogSuite) TestDropTable204() {
func (r *RestCatalogSuite) TestPurgeTable204() {
// Mock the purge table endpoint
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1959,7 +2061,9 @@ func (r *RestCatalogSuite) TestPurgeTable204() {
func (r *RestCatalogSuite) TestDropTable404() {
// Mock the drop table endpoint with 404 response
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -1987,7 +2091,9 @@ func (r *RestCatalogSuite) TestDropTable404() {
func (r *RestCatalogSuite) TestRegisterTable200() {
r.mux.HandleFunc("/v1/namespaces/fokko/register", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2135,7 +2241,9 @@ func (r *RestCatalogSuite) TestRegisterTable200() {
func (r *RestCatalogSuite) TestRegisterTableLabels() {
r.mux.HandleFunc("/v1/namespaces/fokko/register", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
w.Write([]byte(`{
"metadata-location":
"s3://warehouse/database/table/metadata/00001.metadata.json",
"metadata": {
@@ -2175,7 +2283,9 @@ func (r *RestCatalogSuite) TestRegisterTableLabels() {
func (r *RestCatalogSuite) TestRegisterTable404() {
r.mux.HandleFunc("/v1/namespaces/nonexistent/register", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2208,7 +2318,9 @@ func (r *RestCatalogSuite) TestRegisterTable404() {
func (r *RestCatalogSuite) TestRegisterTable409() {
r.mux.HandleFunc("/v1/namespaces/fokko/register", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2243,7 +2355,9 @@ 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)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2296,7 +2410,9 @@ func (r *RestCatalogSuite) TestListViewsPagination() {
defaultPageSize := 20
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/views", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2379,7 +2495,9 @@ func (r *RestCatalogSuite) TestListViewsPagination() {
func (r *RestCatalogSuite) TestListTablesZeroPageSizeNotSent() {
namespace := "examples"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Equal("", req.URL.Query().Get("pageSize"), "pageSize must not
be sent when set to 0")
json.NewEncoder(w).Encode(map[string]any{"identifiers":
[]any{}})
})
@@ -2395,7 +2513,9 @@ func (r *RestCatalogSuite)
TestListTablesZeroPageSizeNotSent() {
func (r *RestCatalogSuite) TestListNamespacesZeroPageSizeNotSent() {
r.mux.HandleFunc("/v1/namespaces", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Equal("", req.URL.Query().Get("pageSize"), "pageSize must not
be sent when set to 0")
json.NewEncoder(w).Encode(map[string]any{"namespaces": []any{}})
})
@@ -2411,7 +2531,9 @@ func (r *RestCatalogSuite)
TestListNamespacesZeroPageSizeNotSent() {
func (r *RestCatalogSuite) TestListViewsZeroPageSizeNotSent() {
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/views", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.Equal("", req.URL.Query().Get("pageSize"), "pageSize must not
be sent when set to 0")
json.NewEncoder(w).Encode(map[string]any{"identifiers":
[]any{}})
})
@@ -2428,7 +2550,9 @@ func (r *RestCatalogSuite)
TestListViewsZeroPageSizeNotSent() {
func (r *RestCatalogSuite) TestListViewsPaginationErrorOnSubsequentPage() {
namespace := "accounting"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/views", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2469,7 +2593,7 @@ func (r *RestCatalogSuite)
TestListViewsPaginationErrorOnSubsequentPage() {
return
}
- r.FailNow("unexpected page token:", pageToken)
+ r.Fail("unexpected page token:", pageToken)
})
cat, err := rest.NewCatalog(context.Background(), "rest", r.srv.URL,
rest.WithOAuthToken(TestToken))
@@ -2501,7 +2625,9 @@ func (r *RestCatalogSuite)
TestListViewsPaginationErrorOnSubsequentPage() {
func (r *RestCatalogSuite) TestListViews404() {
namespace := "nonexistent"
r.mux.HandleFunc("/v1/namespaces/"+namespace+"/views", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2535,7 +2661,9 @@ func (r *RestCatalogSuite) TestListViews404() {
func (r *RestCatalogSuite) TestDropView204() {
r.mux.HandleFunc("/v1/namespaces/fokko/views/fokko2", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2553,7 +2681,9 @@ func (r *RestCatalogSuite) TestDropView204() {
func (r *RestCatalogSuite) TestDropView404() {
r.mux.HandleFunc("/v1/namespaces/fokko/views/nonexistent", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodDelete, req.Method)
+ if !r.Equal(http.MethodDelete, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2581,7 +2711,9 @@ func (r *RestCatalogSuite) TestDropView404() {
func (r *RestCatalogSuite) TestCheckViewExists204() {
r.mux.HandleFunc("/v1/namespaces/fokko/views/fokko2", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodHead, req.Method)
+ if !r.Equal(http.MethodHead, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2598,7 +2730,9 @@ func (r *RestCatalogSuite) TestCheckViewExists204() {
func (r *RestCatalogSuite) TestCheckViewExists404() {
r.mux.HandleFunc("/v1/namespaces/fokko/views/nonexistent", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodHead, req.Method)
+ if !r.Equal(http.MethodHead, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2627,7 +2761,9 @@ func (r *RestCatalogSuite) TestCheckViewExists404() {
func (r *RestCatalogSuite) TestLoadView200() {
r.mux.HandleFunc("/v1/namespaces/fokko/views/myview", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2706,7 +2842,9 @@ func (r *RestCatalogSuite) TestLoadView200() {
func (r *RestCatalogSuite) TestLoadViewLabels() {
r.mux.HandleFunc("/v1/namespaces/fokko/views/myview", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
w.Write([]byte(`{
"metadata-location":
"s3://bucket/warehouse/default.db/event_agg/metadata/00001.metadata.json",
"metadata": {
@@ -2753,7 +2891,9 @@ func (r *RestCatalogSuite) TestLoadViewLabels() {
func (r *RestCatalogSuite) TestLoadView404() {
r.mux.HandleFunc("/v1/namespaces/fokko/views/nonexistent", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -2792,7 +2932,9 @@ func (r *RestTLSCatalogSuite) SetupTest() {
r.mux = http.NewServeMux()
r.mux.HandleFunc("/v1/config", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
r.configVals = req.URL.Query()
r.configAuthHeader = req.Header.Get("Authorization")
@@ -2954,44 +3096,85 @@ var (
}`, exampleViewMetadataJSON)
)
-func (r *RestCatalogSuite) TestUpdatePathsEncodeNamesAndBodiesRemainRaw() {
+func (r *RestCatalogSuite) TestRequestPathsEncodeNamesAndBodiesRemainRaw() {
const objectName = "a b+c"
+ type namedPayload struct {
+ Name string `json:"name"`
+ }
type updatePayload struct {
- Identifier struct {
- Name string `json:"name"`
- } `json:"identifier"`
+ Identifier namedPayload `json:"identifier"`
}
- r.mux.HandleFunc("/v1/namespaces/table-ns/tables/", func(w
http.ResponseWriter, req *http.Request) {
- r.Equal("/v1/namespaces/table-ns/tables/a%20b%2Bc",
req.URL.EscapedPath())
+ decodePayload := func(req *http.Request, payload any) bool {
+ return r.NoError(json.NewDecoder(req.Body).Decode(payload))
+ }
+ writeTableResponse := func(w http.ResponseWriter) {
+ _, err := w.Write([]byte(createTableRestExample))
+ r.NoError(err)
+ }
- var payload updatePayload
- r.Require().NoError(json.NewDecoder(req.Body).Decode(&payload))
- r.Equal(objectName, payload.Identifier.Name)
+ r.mux.HandleFunc("/v1/namespaces/create-ns/tables", func(w
http.ResponseWriter, req *http.Request) {
+ var payload namedPayload
+ if !decodePayload(req, &payload) {
+ return
+ }
+ r.Equal(objectName, payload.Name)
+ writeTableResponse(w)
+ })
- _, err := w.Write([]byte(createTableRestExample))
- r.Require().NoError(err)
+ r.mux.HandleFunc("/v1/namespaces/register-ns/register", func(w
http.ResponseWriter, req *http.Request) {
+ var payload namedPayload
+ if !decodePayload(req, &payload) {
+ return
+ }
+ r.Equal(objectName, payload.Name)
+ writeTableResponse(w)
})
+ for _, namespace := range []string{"commit-ns", "update-ns"} {
+ r.mux.HandleFunc("/v1/namespaces/"+namespace+"/tables/", func(w
http.ResponseWriter, req *http.Request) {
+
r.Equal("/v1/namespaces/"+namespace+"/tables/a%20b%2Bc", req.URL.EscapedPath())
+
+ var payload updatePayload
+ if !decodePayload(req, &payload) {
+ return
+ }
+ r.Equal(objectName, payload.Identifier.Name)
+ writeTableResponse(w)
+ })
+ }
+
r.mux.HandleFunc("/v1/namespaces/view-ns/views/", func(w
http.ResponseWriter, req *http.Request) {
r.Equal("/v1/namespaces/view-ns/views/a%20b%2Bc",
req.URL.EscapedPath())
var payload updatePayload
- r.Require().NoError(json.NewDecoder(req.Body).Decode(&payload))
+ if !decodePayload(req, &payload) {
+ return
+ }
r.Equal(objectName, payload.Identifier.Name)
_, err := w.Write([]byte(createViewRestExample))
- r.Require().NoError(err)
+ r.NoError(err)
})
cat, err := rest.NewCatalog(context.Background(), "rest", r.srv.URL)
r.Require().NoError(err)
+ ctx := context.Background()
+
+ _, err = cat.CreateTable(ctx, table.Identifier{"create-ns",
objectName}, tableSchemaSimple)
+ r.Require().NoError(err)
+
+ _, err = cat.RegisterTable(ctx, table.Identifier{"register-ns",
objectName}, "metadata.json")
+ r.Require().NoError(err)
+
+ _, _, err = cat.CommitTable(ctx, table.Identifier{"commit-ns",
objectName}, nil, nil)
+ r.Require().NoError(err)
- _, err = cat.UpdateTable(context.Background(),
table.Identifier{"table-ns", objectName}, nil, nil)
+ _, err = cat.UpdateTable(ctx, table.Identifier{"update-ns",
objectName}, nil, nil)
r.Require().NoError(err)
- _, err = cat.UpdateView(context.Background(),
table.Identifier{"view-ns", objectName}, nil, nil)
+ _, err = cat.UpdateView(ctx, table.Identifier{"view-ns", objectName},
nil, nil)
r.Require().NoError(err)
}
@@ -3142,7 +3325,9 @@ func (r *RestCatalogSuite) TestRegisterView200() {
identifier := table.Identifier{ns, viewName}
r.mux.HandleFunc("/v1/namespaces/"+ns+"/register-view", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -3183,7 +3368,9 @@ func (r *RestCatalogSuite) TestRegisterViewLabels() {
)
r.mux.HandleFunc("/v1/namespaces/"+ns+"/register-view", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `{"metadata-location": %q, "metadata": %s,
"config": {}, "labels": {"object-labels": {"owner": "analytics"}}}`,
metadataLoc, exampleViewMetadataJSON)
@@ -3264,7 +3451,9 @@ func (r *RestCatalogSuite) TestRegisterView404() {
)
r.mux.HandleFunc("/v1/namespaces/"+ns+"/register-view", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -3295,7 +3484,9 @@ func (r *RestCatalogSuite) TestRegisterView409() {
)
r.mux.HandleFunc("/v1/namespaces/"+ns+"/register-view", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -3322,7 +3513,9 @@ func (r *RestCatalogSuite) TestRenameView204() {
const metadataLoc =
"s3://bucket/warehouse/example.db/destination/metadata/00001.metadata.json"
r.mux.HandleFunc("/v1/views/rename", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -3349,7 +3542,9 @@ func (r *RestCatalogSuite) TestRenameView204() {
// Mock the load view endpoint for loading the renamed view.
r.mux.HandleFunc("/v1/namespaces/example/views/destination", func(w
http.ResponseWriter, req *http.Request) {
- r.Require().Equal(http.MethodGet, req.Method)
+ if !r.Equal(http.MethodGet, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -3377,7 +3572,9 @@ func (r *RestCatalogSuite) TestRenameView204() {
func (r *RestCatalogSuite) TestRenameView404() {
r.mux.HandleFunc("/v1/views/rename", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
@@ -3403,7 +3600,9 @@ func (r *RestCatalogSuite) TestRenameView404() {
func (r *RestCatalogSuite) TestRenameView409() {
r.mux.HandleFunc("/v1/views/rename", func(w http.ResponseWriter, req
*http.Request) {
- r.Require().Equal(http.MethodPost, req.Method)
+ if !r.Equal(http.MethodPost, req.Method) {
+ return
+ }
for k, v := range TestHeaders {
r.Equal(v, req.Header.Values(k))
diff --git a/catalog/rest/scan_planning_retry_test.go
b/catalog/rest/scan_planning_retry_test.go
index 68f9e7fdb..f43ead760 100644
--- a/catalog/rest/scan_planning_retry_test.go
+++ b/catalog/rest/scan_planning_retry_test.go
@@ -51,9 +51,13 @@ func TestScanPlanningPOSTRetriesPreserveIdempotency(t
*testing.T) {
defer mu.Unlock()
key :=
req.Header.Get(headerIdempotencyKey)
body, err :=
io.ReadAll(req.Body)
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
parsed, err := uuid.Parse(key)
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
assert.Equal(t,
uuid.Version(7), parsed.Version())
if attempts.Add(1) == 1 {
firstKey, firstBody =
key, string(body)
diff --git a/catalog/rest/scan_planning_test.go
b/catalog/rest/scan_planning_test.go
index bf049a8ff..30eb2bc49 100644
--- a/catalog/rest/scan_planning_test.go
+++ b/catalog/rest/scan_planning_test.go
@@ -365,15 +365,21 @@ func
TestPlanTableScanGeneratesIdempotencyKeyAndUsesDefaultAccessDelegation(t *t
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
got := req.Header.Get(headerIdempotencyKey)
- require.NotEmpty(t, got)
+ if !assert.NotEmpty(t, got) {
+ return
+ }
parsed, err := uuid.Parse(got)
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
// The spec pins the generated key to UUIDv7.
assert.Equal(t, 7, int(parsed.Version()))
assert.Equal(t, []string{defaultAccessDelegation},
req.Header.Values(headerIcebergAccessDelegation))
_, err =
w.Write([]byte(`{"status":"completed","plan-id":"plan-1"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -424,7 +430,9 @@ func
TestPlanTableScanAcceptsUppercaseCanonicalIdempotencyKey(t *testing.T) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
assert.Equal(t, key,
req.Header.Get(headerIdempotencyKey))
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -473,12 +481,16 @@ func TestPlanTableScanRequest(t *testing.T) {
snapshotID := int64(22)
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointPlanTableScan}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w http.ResponseWriter,
req *http.Request) {
- require.Equal(t, http.MethodPost,
req.Method)
+ if !assert.Equal(t, http.MethodPost,
req.Method) {
+ return
+ }
assert.Equal(t, idempotencyKey,
req.Header.Get(headerIdempotencyKey))
assert.Equal(t,
[]string{accessDelegation}, req.Header.Values(headerIcebergAccessDelegation))
body, err := io.ReadAll(req.Body)
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
assert.JSONEq(t, `{
"snapshot-id": 22,
"select": ["id", "data"],
@@ -486,7 +498,9 @@ func TestPlanTableScanRequest(t *testing.T) {
}`, string(body))
_, err = w.Write([]byte(tc.response))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -529,7 +543,9 @@ func TestPlanTableScanRejectsEmptyBody(t *testing.T) {
// success; assert it is rejected instead.
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodPost, req.Method)
+ if !assert.Equal(t, http.MethodPost, req.Method) {
+ return
+ }
w.Header().Set("Content-Length", "0")
w.WriteHeader(http.StatusOK)
})
@@ -550,7 +566,9 @@ func TestFetchScanTasksRejectsEmptyBody(t *testing.T) {
key := "0190b6c5-1c3d-7000-8000-000000000004"
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchScanTasks}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodPost, req.Method)
+ if !assert.Equal(t, http.MethodPost, req.Method) {
+ return
+ }
w.Header().Set("Content-Length", "0")
w.WriteHeader(http.StatusOK)
})
@@ -570,9 +588,13 @@ func TestFetchScanTasksRejectsNullBody(t *testing.T) {
key := "0190b6c5-1c3d-7000-8000-000000000005"
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchScanTasks}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodPost, req.Method)
+ if !assert.Equal(t, http.MethodPost, req.Method) {
+ return
+ }
_, err := w.Write([]byte("null"))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -590,11 +612,15 @@ func TestFetchPlanningResultRequest(t *testing.T) {
accessDelegation := "remote-signing"
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-123",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodGet, req.Method)
+ if !assert.Equal(t, http.MethodGet, req.Method) {
+ return
+ }
assert.Equal(t, []string{accessDelegation},
req.Header.Values(headerIcebergAccessDelegation))
_, err :=
w.Write([]byte(`{"status":"completed","plan-tasks":["task-1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -611,11 +637,15 @@ func TestFetchPlanningResultUsesDefaultAccessDelegation(t
*testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-123",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodGet, req.Method)
+ if !assert.Equal(t, http.MethodGet, req.Method) {
+ return
+ }
assert.Equal(t, []string{defaultAccessDelegation},
req.Header.Values(headerIcebergAccessDelegation))
_, err := w.Write([]byte(`{"status":"submitted"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -650,7 +680,9 @@ func TestFetchPlanningResultMapsNotFound(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-123", func(w
http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodGet,
req.Method)
+ if !assert.Equal(t, http.MethodGet,
req.Method) {
+ return
+ }
writeRESTNotFound(t, w, tc.errType)
})
})
@@ -690,7 +722,9 @@ func TestFetchScanTasksMapsNotFound(t *testing.T) {
idempotencyKey := "0190b6c5-1c3d-7000-8000-000000000003"
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchScanTasks}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodPost,
req.Method)
+ if !assert.Equal(t, http.MethodPost,
req.Method) {
+ return
+ }
writeRESTNotFound(t, w, tc.errType)
})
})
@@ -731,7 +765,9 @@ func TestPlanTableScanMapsNotFound(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointPlanTableScan}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w http.ResponseWriter,
req *http.Request) {
- require.Equal(t, http.MethodPost,
req.Method)
+ if !assert.Equal(t, http.MethodPost,
req.Method) {
+ return
+ }
writeRESTNotFound(t, w, tc.errType)
})
})
@@ -765,7 +801,9 @@ func TestFetchPlanningResultStatusArms(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-123", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"cancelled"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -779,7 +817,9 @@ func TestFetchPlanningResultStatusArms(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-123", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"failed","error":{"message":"boom","type":"ServerError","code":500}}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -801,7 +841,9 @@ func TestFetchPlanningResultStatusArms(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-123", func(w
http.ResponseWriter, req *http.Request) {
_, err := w.Write([]byte(payload))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -819,7 +861,9 @@ func TestCancelPlanningRequest(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointCancelPlanning}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-123",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodDelete, req.Method)
+ if !assert.Equal(t, http.MethodDelete, req.Method) {
+ return
+ }
assert.Empty(t, req.Header.Values(headerIdempotencyKey))
assert.Empty(t,
req.Header.Values(headerIcebergAccessDelegation))
w.WriteHeader(http.StatusNoContent)
@@ -835,12 +879,16 @@ func TestFetchScanTasksRequest(t *testing.T) {
idempotencyKey := "0190b6c5-1c3d-7000-8000-000000000002"
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchScanTasks}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodPost, req.Method)
+ if !assert.Equal(t, http.MethodPost, req.Method) {
+ return
+ }
assert.Equal(t, idempotencyKey,
req.Header.Get(headerIdempotencyKey))
assert.Empty(t,
req.Header.Values(headerIcebergAccessDelegation))
body, err := io.ReadAll(req.Body)
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
assert.JSONEq(t, `{"plan-task":"task-1"}`, string(body))
_, err = w.Write([]byte(`{
@@ -848,7 +896,9 @@ func TestFetchScanTasksRequest(t *testing.T) {
"file-scan-tasks": [{}],
"delete-files": [{}]
}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -907,13 +957,17 @@ func newScanPlanningTestCatalog(t *testing.T, endpoints
[]endpoint, register fun
mux := http.NewServeMux()
mux.HandleFunc("/v1/config", func(w http.ResponseWriter, req
*http.Request) {
- require.Equal(t, http.MethodGet, req.Method)
+ if !assert.Equal(t, http.MethodGet, req.Method) {
+ return
+ }
err := json.NewEncoder(w).Encode(map[string]any{
"defaults": map[string]any{},
"overrides": map[string]any{},
"endpoints": endpointStrings(endpoints),
})
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
if register != nil {
register(mux)
@@ -954,7 +1008,7 @@ func writeRESTNotFound(t *testing.T, w
http.ResponseWriter, errType string) {
}
_, err := fmt.Fprintf(w,
`{"error":{"message":%q,"type":%q,"code":404}}`, errType, errType)
- require.NoError(t, err)
+ assert.NoError(t, err)
}
// TestPlanTableScanRequestFromEncodesFilter checks the row filter serializes
to
@@ -1092,7 +1146,9 @@ func TestPlanFilesCompletedEmpty(t *testing.T) {
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -1109,11 +1165,13 @@ func
TestScanPlanningRemoteSupportsSynchronousPlanOnlyServer(t *testing.T) {
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
planID := "plan-1"
- require.NoError(t,
json.NewEncoder(w).Encode(PlanTableScanResponse{
+ if !assert.NoError(t,
json.NewEncoder(w).Encode(PlanTableScanResponse{
Status: PlanStatusCompleted,
PlanID: &planID,
ScanTasks: validScanTasksWire(),
- }))
+ })) {
+ return
+ }
})
})
@@ -1151,7 +1209,9 @@ func
TestPlanFilesRequiresAdvertisedResponseContinuation(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointPlanTableScan}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w http.ResponseWriter,
req *http.Request) {
_, err := w.Write([]byte(test.response))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -1169,14 +1229,20 @@ func TestPlanFilesEncodesFilter(t *testing.T) {
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
body, err := io.ReadAll(req.Body)
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
var got PlanTableScanRequest
- require.NoError(t, json.Unmarshal(body, &got))
+ if !assert.NoError(t, json.Unmarshal(body, &got)) {
+ return
+ }
assert.JSONEq(t, `{"type":"eq","term":"i","value":25}`,
string(got.Filter))
_, err =
w.Write([]byte(`{"status":"completed","plan-id":"plan-1"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -1194,7 +1260,9 @@ func TestPlanFilesRejectsMalformedScanTasks(t *testing.T)
{
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","file-scan-tasks":[{}]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -1210,12 +1278,18 @@ func TestPlanFilesPollsSubmittedPlan(t *testing.T) {
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan,
endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"submitted","plan-id":"plan-9"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-9",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodGet, req.Method)
+ if !assert.Equal(t, http.MethodGet, req.Method) {
+ return
+ }
_, err := w.Write([]byte(`{"status":"completed"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -1235,21 +1309,29 @@ func TestPlanFilesExpandsPlanTasks(t *testing.T) {
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan,
endpointFetchScanTasks}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","plan-tasks":["h1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
var body FetchScanTasksRequest
- require.NoError(t,
json.NewDecoder(req.Body).Decode(&body))
+ if !assert.NoError(t,
json.NewDecoder(req.Body).Decode(&body)) {
+ return
+ }
mu.Lock()
fetched = append(fetched, body.PlanTask)
mu.Unlock()
switch body.PlanTask {
case "h1":
_, err :=
w.Write([]byte(`{"plan-tasks":["h2"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
default:
_, err :=
w.Write([]byte(`{"file-scan-tasks":[]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
}
})
})
@@ -1472,12 +1554,16 @@ func TestPlanFilesFanoutCycleTerminates(t *testing.T) {
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan,
endpointFetchScanTasks}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","plan-tasks":["h1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
calls.Add(1)
_, err := w.Write([]byte(`{"plan-tasks":["h1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -1498,14 +1584,20 @@ func TestPlanFilesCancelsAfterFanoutFailure(t
*testing.T) {
}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","plan-tasks":["h1","h2"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
var body FetchScanTasksRequest
- require.NoError(t,
json.NewDecoder(req.Body).Decode(&body))
+ if !assert.NoError(t,
json.NewDecoder(req.Body).Decode(&body)) {
+ return
+ }
if body.PlanTask == "h1" {
_, err := w.Write([]byte(`{"plan-tasks":[]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
return
}
@@ -1513,7 +1605,9 @@ func TestPlanFilesCancelsAfterFanoutFailure(t *testing.T)
{
w.WriteHeader(http.StatusServiceUnavailable)
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodDelete, req.Method)
+ if !assert.Equal(t, http.MethodDelete, req.Method) {
+ return
+ }
cancels.Add(1)
w.WriteHeader(http.StatusNoContent)
})
@@ -1535,17 +1629,27 @@ func
TestPlanFilesCancelsAfterSuccessfulMaterialization(t *testing.T) {
}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","plan-tasks":["h1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
var body FetchScanTasksRequest
- require.NoError(t,
json.NewDecoder(req.Body).Decode(&body))
- require.Equal(t, "h1", body.PlanTask)
+ if !assert.NoError(t,
json.NewDecoder(req.Body).Decode(&body)) {
+ return
+ }
+ if !assert.Equal(t, "h1", body.PlanTask) {
+ return
+ }
_, err := w.Write([]byte(`{"file-scan-tasks":[]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodDelete, req.Method)
+ if !assert.Equal(t, http.MethodDelete, req.Method) {
+ return
+ }
cancels.Add(1)
w.WriteHeader(http.StatusNoContent)
})
@@ -1567,10 +1671,14 @@ func TestPlanFilesDefersCancelWithVendedCredentials(t
*testing.T) {
}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","storage-credentials":[{"prefix":"s3://bucket/","config":{"s3.access-key-id":"vended"}}]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodDelete, req.Method)
+ if !assert.Equal(t, http.MethodDelete, req.Method) {
+ return
+ }
cancels.Add(1)
w.WriteHeader(http.StatusNoContent)
})
@@ -1598,17 +1706,27 @@ func TestPlanFilesCancelsAfterTaskDecodeFailure(t
*testing.T) {
}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","plan-tasks":["h1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
var body FetchScanTasksRequest
- require.NoError(t,
json.NewDecoder(req.Body).Decode(&body))
- require.Equal(t, "h1", body.PlanTask)
+ if !assert.NoError(t,
json.NewDecoder(req.Body).Decode(&body)) {
+ return
+ }
+ if !assert.Equal(t, "h1", body.PlanTask) {
+ return
+ }
_, err := w.Write([]byte(`{"file-scan-tasks":[{}]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodDelete, req.Method)
+ if !assert.Equal(t, http.MethodDelete, req.Method) {
+ return
+ }
cancels.Add(1)
w.WriteHeader(http.StatusNoContent)
})
@@ -1630,7 +1748,9 @@ func TestPlanFilesCancelsAfterTerminalPollError(t
*testing.T) {
}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"submitted","plan-id":"plan-1"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
switch req.Method {
@@ -1709,13 +1829,21 @@ func TestPlanFilesDecodesFanoutTaskEnvelopes(t
*testing.T) {
PlanID: "plan-1",
ScanTasks: first,
}
- require.NoError(t, json.NewEncoder(w).Encode(response))
+ if !assert.NoError(t,
json.NewEncoder(w).Encode(response)) {
+ return
+ }
})
mux.HandleFunc("/v1/namespaces/db/tables/tbl/tasks", func(w
http.ResponseWriter, req *http.Request) {
var got FetchScanTasksRequest
- require.NoError(t,
json.NewDecoder(req.Body).Decode(&got))
- require.Equal(t, "h1", got.PlanTask)
- require.NoError(t,
json.NewEncoder(w).Encode(FetchScanTasksResponse{ScanTasks: second}))
+ if !assert.NoError(t,
json.NewDecoder(req.Body).Decode(&got)) {
+ return
+ }
+ if !assert.Equal(t, "h1", got.PlanTask) {
+ return
+ }
+ if !assert.NoError(t,
json.NewEncoder(w).Encode(FetchScanTasksResponse{ScanTasks: second})) {
+ return
+ }
})
})
@@ -1743,7 +1871,9 @@ func TestPlanFilesSurfacesVendedCredentials(t *testing.T)
{
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"completed","plan-id":"plan-1","storage-credentials":[{"prefix":"s3://bucket/","config":{"s3.access-key-id":"vended"}}]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
cat.props["s3.endpoint"] = "https://catalog.local"
@@ -1896,7 +2026,9 @@ func TestPlanFilesPropagatesFailure(t *testing.T) {
cat := newScanPlanningTestCatalog(t, []endpoint{endpointPlanTableScan},
func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan", func(w
http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"failed","error":{"message":"boom","type":"ServerError","code":500}}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
diff --git a/catalog/rest/wait_for_plan_test.go
b/catalog/rest/wait_for_plan_test.go
index aac1bc52f..82e179d04 100644
--- a/catalog/rest/wait_for_plan_test.go
+++ b/catalog/rest/wait_for_plan_test.go
@@ -42,19 +42,25 @@ func TestWaitForPlanCompletesAfterPolling(t *testing.T) {
var polls atomic.Int32
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
- require.Equal(t, http.MethodGet, req.Method)
+ if !assert.Equal(t, http.MethodGet, req.Method) {
+ return
+ }
// Two "submitted" responses, then a "completed" one
carrying tasks and
// vended credentials.
if polls.Add(1) <= 2 {
_, err :=
w.Write([]byte(`{"status":"submitted"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
return
}
_, err :=
w.Write([]byte(`{"status":"completed","plan-tasks":["t1","t2"],` +
`"file-scan-tasks":[{}],"delete-files":[{}],` +
`"storage-credentials":[{"prefix":"s3://bucket/","config":{"k":"v"}}]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -82,7 +88,9 @@ func TestWaitForPlanReturnsImmediatelyWhenCompleted(t
*testing.T) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
polls.Add(1)
_, err :=
w.Write([]byte(`{"status":"completed","plan-tasks":["t1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -103,7 +111,9 @@ func TestWaitForPlanPropagatesFailed(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
_, err :=
w.Write([]byte(`{"status":"failed","error":{"message":"boom","type":"ValidationException","code":400}}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -126,7 +136,9 @@ func TestWaitForPlanPropagatesFailedWithoutUsableError(t
*testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1", func(w
http.ResponseWriter, req *http.Request) {
_, err := w.Write([]byte(payload))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -144,7 +156,9 @@ func TestWaitForPlanPropagatesCancelled(t *testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
_, err := w.Write([]byte(`{"status":"cancelled"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -177,7 +191,9 @@ func TestWaitForPlanRetriesServiceUnavailable(t *testing.T)
{
return
}
_, err :=
w.Write([]byte(`{"status":"completed","plan-tasks":["t1"]}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -215,7 +231,9 @@ func TestWaitForPlanRetriesJavaIdempotentGETStatuses(t
*testing.T) {
return
}
_, err :=
w.Write([]byte(`{"status":"completed"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -238,12 +256,16 @@ func TestWaitForPlanRetriesStatusWithMalformedErrorBody(t
*testing.T) {
if polls.Add(1) == 1 {
w.WriteHeader(http.StatusInternalServerError)
_, err := w.Write([]byte("not json"))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
return
}
_, err := w.Write([]byte(`{"status":"completed"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -385,7 +407,9 @@ func TestWaitForPlanCancelsServerSideOnContextCancel(t
*testing.T) {
default:
}
_, err := w.Write([]byte(`{"status":"submitted"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("DELETE
/v1/namespaces/db/tables/tbl/plan/plan-1", func(w http.ResponseWriter, req
*http.Request) {
deleteHit.Store(true)
@@ -420,7 +444,9 @@ func TestWaitForPlanBoundsSlowServerSideCancel(t
*testing.T) {
default:
}
_, err := w.Write([]byte(`{"status":"submitted"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
// The cancel endpoint stalls: it never responds until the
client (bounded
// by the grace) gives up and drops the connection.
@@ -469,7 +495,9 @@ func TestWaitForPlanReturnsDeadlineWhileSubmitted(t
*testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
_, err := w.Write([]byte(`{"status":"submitted"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -492,7 +520,9 @@ func TestWaitForPlanExhaustsMaxRetries(t *testing.T) {
mux.HandleFunc("GET /v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
polls.Add(1)
_, err := w.Write([]byte(`{"status":"submitted"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
mux.HandleFunc("DELETE
/v1/namespaces/db/tables/tbl/plan/plan-1", func(w http.ResponseWriter, req
*http.Request) {
deleteHit.Store(true)
@@ -520,7 +550,9 @@ func TestWaitForPlanDeadlineDisablesDefaultRetryCap(t
*testing.T) {
cat := newScanPlanningTestCatalog(t,
[]endpoint{endpointFetchPlanResult}, func(mux *http.ServeMux) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
_, err := w.Write([]byte(`{"status":"submitted"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})
@@ -662,7 +694,9 @@ func TestWaitForPlanForwardsAccessDelegation(t *testing.T) {
mux.HandleFunc("/v1/namespaces/db/tables/tbl/plan/plan-1",
func(w http.ResponseWriter, req *http.Request) {
assert.Equal(t, "remote-signing",
req.Header.Get(headerIcebergAccessDelegation))
_, err := w.Write([]byte(`{"status":"completed"}`))
- require.NoError(t, err)
+ if !assert.NoError(t, err) {
+ return
+ }
})
})