Skip to content

Commit

Permalink
chore: upgrade go.mod to 1.20 (matches Dockerfile builder) + ioutil d…
Browse files Browse the repository at this point in the history
…eprecation

Topic: 1.20

Relative: rm-reflection
Signed-off-by: Ross Bryan <[email protected]>
  • Loading branch information
arborite-rh committed Feb 28, 2024
1 parent 4c07622 commit 851c120
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/quay/quay-bridge-operator

go 1.17
go 1.20

require (
github.com/go-logr/logr v1.2.4
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/quay/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
)
Expand Down Expand Up @@ -195,7 +194,7 @@ func (c *QuayClient) do(req *http.Request, v interface{}) (*http.Response, error

if v != nil {
if _, ok := v.(*StringValue); ok {
responseData, err := ioutil.ReadAll(resp.Body)
responseData, err := io.ReadAll(resp.Body)
if err != nil {
return resp, err
}
Expand Down
30 changes: 30 additions & 0 deletions pkg/client/quay/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package quay_test

import (
"net/http"
"testing"
)

func TestGetUser(t *testing.T) {
// Create a new instance of the mock controller
ctrl := quay.NewController(t)
defer ctrl.Finish()

// Create a mock instance of QuayClient
mockQuayClient := mock_quay.NewMockQuayClient(ctrl)

// Prepare expected user and response
expectedUser := quay.User{} // Define your expected User struct here
mockResponse := &http.Response{} // Mock HTTP response

// Set up expectations
mockQuayClient.EXPECT().GetUser().Return(expectedUser, mockResponse, nil)

// Call the method under test
user, resp, err := mockQuayClient.GetUser()

// Assert the results
assert.NoError(t, err)
assert.Equal(t, expectedUser, user)
assert.Equal(t, mockResponse, resp)
}

0 comments on commit 851c120

Please sign in to comment.