MCPcopy
hub / github.com/kubernetes/client-go / TestRequestBody

Function TestRequestBody

rest/request_test.go:298–322  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

296}
297
298func TestRequestBody(t *testing.T) {
299 // test unknown type
300 r := (&Request{}).Body([]string{"test"})
301 if r.err == nil || r.body != nil {
302 t.Errorf("should have set err and left body nil: %#v", r)
303 }
304
305 // test error set when failing to read file
306 f, err := ioutil.TempFile("", "test")
307 if err != nil {
308 t.Fatalf("unable to create temp file")
309 }
310 defer f.Close()
311 os.Remove(f.Name())
312 r = (&Request{}).Body(f.Name())
313 if r.err == nil || r.body != nil {
314 t.Errorf("should have set err and left body nil: %#v", r)
315 }
316
317 // test unencodable api object
318 r = (&Request{content: defaultContentConfig()}).Body(&NotAnAPIObject{})
319 if r.err == nil || r.body != nil {
320 t.Errorf("should have set err and left body nil: %#v", r)
321 }
322}
323
324func TestResultIntoWithErrReturnsErr(t *testing.T) {
325 res := Result{err: errors.New("test")}

Callers

nothing calls this directly

Calls 5

defaultContentConfigFunction · 0.85
BodyMethod · 0.80
ErrorfMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected