diff --git a/go.mod b/go.mod index a9f6fe94..4588ea4e 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/pkg/client/quay/client.go b/pkg/client/quay/client.go index f638e974..2e26eb40 100644 --- a/pkg/client/quay/client.go +++ b/pkg/client/quay/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" ) @@ -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 } diff --git a/pkg/client/quay/client_test.go b/pkg/client/quay/client_test.go new file mode 100644 index 00000000..0387550b --- /dev/null +++ b/pkg/client/quay/client_test.go @@ -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) +}