mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #112093 from HecarimV/fix-2282915
test: use bytes.Buffer.String
This commit is contained in:
commit
1ab40212a4
@ -48,7 +48,7 @@ func TestErrors(t *testing.T) {
|
|||||||
for _, test := range cases {
|
for _, test := range cases {
|
||||||
observer := httptest.NewRecorder()
|
observer := httptest.NewRecorder()
|
||||||
fns[test.fn](observer, &http.Request{RequestURI: test.uri})
|
fns[test.fn](observer, &http.Request{RequestURI: test.uri})
|
||||||
result := string(observer.Body.Bytes())
|
result := observer.Body.String()
|
||||||
if result != test.expected {
|
if result != test.expected {
|
||||||
t.Errorf("%s(..., %q) != %q, got %q", test.fn, test.uri, test.expected, result)
|
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()
|
scheme := runtime.NewScheme()
|
||||||
negotiatedSerializer := serializer.NewCodecFactory(scheme).WithoutConversion()
|
negotiatedSerializer := serializer.NewCodecFactory(scheme).WithoutConversion()
|
||||||
Forbidden(request.NewDefaultContext(), test.attributes, observer, &http.Request{URL: &url.URL{Path: "/path"}}, test.reason, negotiatedSerializer)
|
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 {
|
if result != test.expected {
|
||||||
t.Errorf("Forbidden response body(%#v...)\n expected: %v\ngot: %v", test.attributes, test.expected, result)
|
t.Errorf("Forbidden response body(%#v...)\n expected: %v\ngot: %v", test.attributes, test.expected, result)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user