From 079a0e434ebeaa6e47637142cb35aebfbaaac63f Mon Sep 17 00:00:00 2001 From: Renaud Hartert Date: Tue, 2 Jul 2024 19:24:46 +0200 Subject: [PATCH] Minor renaming --- apierr/errors.go | 11 +++++------ apierr/errors_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/apierr/errors.go b/apierr/errors.go index 3c65689b8..463b7bc0c 100644 --- a/apierr/errors.go +++ b/apierr/errors.go @@ -162,11 +162,10 @@ func parseErrorFromResponse(resp *http.Response, requestBody, responseBody []byt // Anonymous struct used to unmarshal JSON Databricks API error responses. var errorBody struct { - ErrorCode any `json:"error_code,omitempty"` // int or string - Message string `json:"message,omitempty"` - Details []ErrorDetail `json:"details,omitempty"` - - API12Error string `json:"error,omitempty"` + ErrorCode any `json:"error_code,omitempty"` // int or string + Message string `json:"message,omitempty"` + Details []ErrorDetail `json:"details,omitempty"` + API12Error string `json:"error,omitempty"` // The following fields are for scim api only. See RFC7644 section 3.7.3 // https://tools.ietf.org/html/rfc7644#section-3.7.3 @@ -209,7 +208,7 @@ func unknownAPIError(resp *http.Response, requestBody, responseBody []byte, err StatusCode: resp.StatusCode, } - // This is most likely HTML... since un-marshalling JSON failed + // this is most likely HTML... since un-marshalling JSON failed // Status parts first in case html message is not as expected statusParts := strings.SplitN(resp.Status, " ", 2) if len(statusParts) < 2 { diff --git a/apierr/errors_test.go b/apierr/errors_test.go index dcce7e014..da3142050 100644 --- a/apierr/errors_test.go +++ b/apierr/errors_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestGetAPIError_HandlesEmptyResponse(t *testing.T) { +func TestGetAPIError_handlesEmptyResponse(t *testing.T) { resp := common.ResponseWrapper{ Response: &http.Response{ Request: &http.Request{ @@ -32,7 +32,7 @@ func TestGetAPIError_HandlesEmptyResponse(t *testing.T) { assert.Equal(t, err.(*APIError).Message, "") } -func TestGetAPIError_AppliesOverrides(t *testing.T) { +func TestGetAPIError_appliesOverrides(t *testing.T) { resp := common.ResponseWrapper{ Response: &http.Response{ StatusCode: http.StatusBadRequest, @@ -52,7 +52,7 @@ func TestGetAPIError_AppliesOverrides(t *testing.T) { assert.ErrorIs(t, err, ErrResourceDoesNotExist) } -func TestGetAPIError_ParseIntErrorCode(t *testing.T) { +func TestGetAPIError_parseIntErrorCode(t *testing.T) { resp := common.ResponseWrapper{ Response: &http.Response{ StatusCode: http.StatusBadRequest, @@ -73,7 +73,7 @@ func TestGetAPIError_ParseIntErrorCode(t *testing.T) { assert.Equal(t, err.(*APIError).ErrorCode, "500") } -func TestGetAPIError_MapsPrivateLinkRedirect(t *testing.T) { +func TestGetAPIError_mapsPrivateLinkRedirect(t *testing.T) { resp := common.ResponseWrapper{ Response: &http.Response{ Request: &http.Request{ @@ -92,7 +92,7 @@ func TestGetAPIError_MapsPrivateLinkRedirect(t *testing.T) { assert.Equal(t, err.(*APIError).ErrorCode, "PRIVATE_LINK_VALIDATION_ERROR") } -func TestAPIError_TransientRegexMatches(t *testing.T) { +func TestAPIError_transientRegexMatches(t *testing.T) { err := APIError{ Message: "worker env WorkerEnvId(workerenv-XXXXX) not found", }