From d30fb5ab6240e94ce3cd27a8c20e693b883979cd Mon Sep 17 00:00:00 2001 From: Joseph Little Date: Tue, 9 Jul 2024 15:14:19 +0100 Subject: [PATCH] temporarily renamed some test files to improve package readability for squashing --- response/error.go | 3 +-- response/status.go | 9 --------- response/{parse_test.go => t_parse_test.go} | 0 response/{success_test.go => t_success_test.go} | 4 ---- 4 files changed, 1 insertion(+), 15 deletions(-) rename response/{parse_test.go => t_parse_test.go} (100%) rename response/{success_test.go => t_success_test.go} (78%) diff --git a/response/error.go b/response/error.go index d16dcb4..98fa24c 100644 --- a/response/error.go +++ b/response/error.go @@ -177,13 +177,12 @@ func parseHTMLResponse(bodyBytes []byte, apiError *APIError) { } } - parse(doc) // Start parsing the document. + parse(doc) // Concatenate all accumulated messages and links with a separator. if len(messages) > 0 { apiError.Message = strings.Join(messages, "; ") } else { - // Fallback error message if no specific content was extracted. apiError.Message = "HTML Error: See 'Raw' field for details." } diff --git a/response/status.go b/response/status.go index f6bc058..a34236c 100644 --- a/response/status.go +++ b/response/status.go @@ -7,15 +7,6 @@ import ( ) // IsRedirectStatusCode checks if the provided HTTP status code is one of the redirect codes. -// Redirect status codes instruct the client to make a new request to a different URI, as defined in the response's Location header. -// -// - 301 Moved Permanently: The requested resource has been assigned a new permanent URI and any future references to this resource should use one of the returned URIs. -// - 302 Found: The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client should continue to use the Request-URI for future requests. -// - 303 See Other: The response to the request can be found under a different URI and should be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. -// - 307 Temporary Redirect: The requested resource resides temporarily under a different URI. The client should not change the request method if it performs an automatic redirection to that URI. -// - 308 Permanent Redirect: The request and all future requests should be repeated using another URI. 308 parallel the behavior of 301 but do not allow the HTTP method to change. So, for example, submitting a form to a permanently redirected resource may continue smoothly. -// -// The function returns true if the statusCode is one of the above redirect statuses, indicating that the client should follow the redirection as specified in the Location header of the response. func IsRedirectStatusCode(statusCode int) bool { switch statusCode { case http.StatusMovedPermanently, diff --git a/response/parse_test.go b/response/t_parse_test.go similarity index 100% rename from response/parse_test.go rename to response/t_parse_test.go diff --git a/response/success_test.go b/response/t_success_test.go similarity index 78% rename from response/success_test.go rename to response/t_success_test.go index 06ad2c8..4df7d1c 100644 --- a/response/success_test.go +++ b/response/t_success_test.go @@ -22,10 +22,8 @@ func TestHandleDeleteRequest_Success(t *testing.T) { }, } - // Call handleDeleteRequest with a nil logger since logging is ignored in this test err := handleDeleteRequest(resp, nil) - // No error is expected for a successful DELETE request assert.NoError(t, err, "handleDeleteRequest should not return an error for successful DELETE requests") } @@ -42,9 +40,7 @@ func TestHandleDeleteRequest_Failure(t *testing.T) { }, } - // Call handleDeleteRequest with a nil logger since logging is ignored in this test err := handleDeleteRequest(resp, nil) - // An error is expected for a failed DELETE request assert.Error(t, err, "handleDeleteRequest should return an error for failed DELETE requests") }