From f55d658c1c8b4c59dcb33bd07285e62344ef0186 Mon Sep 17 00:00:00 2001 From: HaoJie Liu Date: Mon, 29 Aug 2022 15:45:20 +0800 Subject: [PATCH] test: use bytes.Buffer.String Signed-off-by: HaoJie Liu --- .../pkg/endpoints/handlers/responsewriters/errors_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go index 33231bd5e6bd6..034d2413942d9 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go @@ -48,7 +48,7 @@ func TestErrors(t *testing.T) { for _, test := range cases { observer := httptest.NewRecorder() fns[test.fn](observer, &http.Request{RequestURI: test.uri}) - result := string(observer.Body.Bytes()) + result := observer.Body.String() if result != test.expected { t.Errorf("%s(..., %q) != %q, got %q", test.fn, test.uri, test.expected, result) } @@ -79,7 +79,7 @@ func TestForbidden(t *testing.T) { scheme := runtime.NewScheme() negotiatedSerializer := serializer.NewCodecFactory(scheme).WithoutConversion() Forbidden(request.NewDefaultContext(), test.attributes, observer, &http.Request{URL: &url.URL{Path: "/path"}}, test.reason, negotiatedSerializer) - result := string(observer.Body.Bytes()) + result := observer.Body.String() if result != test.expected { t.Errorf("Forbidden response body(%#v...)\n expected: %v\ngot: %v", test.attributes, test.expected, result) }