chore: fix the gci lint issue in testutil (#21695)

This commit is contained in:
cool-developer 2024-09-13 02:53:47 -04:00 committed by GitHub
parent 4c7cc8643f
commit f611150a30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,15 +42,15 @@ func GetRequestWithHeaders(url string, headers map[string]string) ([]byte, error
// GetRequest defines a wrapper around an HTTP GET request with a provided URL.
// An error is returned if the request or reading the body fails.
func GetRequest(url string) ([]byte, error) {
res, err := http.Get(url)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer func() {
_ = res.Body.Close()
_ = resp.Body.Close()
}()
body, err := io.ReadAll(res.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
@ -61,15 +61,15 @@ func GetRequest(url string) ([]byte, error) {
// PostRequest defines a wrapper around an HTTP POST request with a provided URL and data.
// An error is returned if the request or reading the body fails.
func PostRequest(url, contentType string, data []byte) ([]byte, error) {
res, err := http.Post(url, contentType, bytes.NewBuffer(data))
resp, err := http.Post(url, contentType, bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("error while sending post request: %w", err)
}
defer func() {
_ = res.Body.Close()
_ = resp.Body.Close()
}()
bz, err := io.ReadAll(res.Body)
bz, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("error reading response body: %w", err)
}