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

Function TestFakeHandlerPath

util/testing/fake_handler_test.go:26–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestFakeHandlerPath(t *testing.T) {
27 handler := FakeHandler{StatusCode: http.StatusOK}
28 server := httptest.NewServer(&handler)
29 defer server.Close()
30 method := "GET"
31 path := "/foo/bar"
32 body := "somebody"
33
34 req, err := http.NewRequest(method, server.URL+path, bytes.NewBufferString(body))
35 if err != nil {
36 t.Errorf("unexpected error: %v", err)
37 }
38
39 client := http.Client{}
40 _, err = client.Do(req)
41 if err != nil {
42 t.Errorf("unexpected error: %v", err)
43 }
44
45 handler.ValidateRequest(t, path, method, &body)
46}
47
48func TestFakeHandlerPathNoBody(t *testing.T) {
49 handler := FakeHandler{StatusCode: http.StatusOK}

Callers

nothing calls this directly

Calls 4

ValidateRequestMethod · 0.95
CloseMethod · 0.65
ErrorfMethod · 0.65
DoMethod · 0.65

Tested by

no test coverage detected