From d3b912edd202d5b1646b91fae4cf4a94632259c4 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 10 Aug 2022 13:43:22 -0500 Subject: [PATCH] fixing unit tests --- api/client/builder/client_test.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/client/builder/client_test.go b/api/client/builder/client_test.go index 2b3576a4078d..542481a0d60f 100644 --- a/api/client/builder/client_test.go +++ b/api/client/builder/client_test.go @@ -3,6 +3,7 @@ package builder import ( "bytes" "context" + "encoding/json" "fmt" "io" "net/http" @@ -58,9 +59,15 @@ func TestClient_Status(t *testing.T) { require.NoError(t, r.Body.Close()) }() require.Equal(t, statusPath, r.URL.Path) + message := ErrorMessage{ + Code: 500, + Message: "Internal server error", + } + resp, err := json.Marshal(message) + require.NoError(t, err) return &http.Response{ StatusCode: http.StatusInternalServerError, - Body: io.NopCloser(bytes.NewBuffer(nil)), + Body: io.NopCloser(bytes.NewBuffer(resp)), Request: r.Clone(ctx), }, nil }), @@ -114,9 +121,15 @@ func TestClient_GetHeader(t *testing.T) { hc := &http.Client{ Transport: roundtrip(func(r *http.Request) (*http.Response, error) { require.Equal(t, expectedPath, r.URL.Path) + message := ErrorMessage{ + Code: 500, + Message: "Internal server error", + } + resp, err := json.Marshal(message) + require.NoError(t, err) return &http.Response{ StatusCode: http.StatusInternalServerError, - Body: io.NopCloser(bytes.NewBuffer(nil)), + Body: io.NopCloser(bytes.NewBuffer(resp)), Request: r.Clone(ctx), }, nil }),