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

Function TestRequestWatch

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

Source from the content-addressed store, hash-verified

886func (r errorReader) Close() error { return nil }
887
888func TestRequestWatch(t *testing.T) {
889 testCases := []struct {
890 Request *Request
891 Expect []watch.Event
892 Err bool
893 ErrFn func(error) bool
894 Empty bool
895 }{
896 {
897 Request: &Request{err: errors.New("bail")},
898 Err: true,
899 },
900 {
901 Request: &Request{baseURL: &url.URL{}, pathPrefix: "%"},
902 Err: true,
903 },
904 {
905 Request: &Request{
906 client: clientFunc(func(req *http.Request) (*http.Response, error) {
907 return nil, errors.New("err")
908 }),
909 baseURL: &url.URL{},
910 },
911 Err: true,
912 },
913 {
914 Request: &Request{
915 content: defaultContentConfig(),
916 serializers: defaultSerializers(t),
917 client: clientFunc(func(req *http.Request) (*http.Response, error) {
918 resp := &http.Response{StatusCode: http.StatusOK, Body: errorReader{err: errors.New("test error")}}
919 return resp, nil
920 }),
921 baseURL: &url.URL{},
922 },
923 Expect: []watch.Event{
924 {
925 Type: watch.Error,
926 Object: &metav1.Status{
927 Status: "Failure",
928 Code: 500,
929 Reason: "InternalError",
930 Message: `an error on the server ("unable to decode an event from the watch stream: test error") has prevented the request from succeeding`,
931 Details: &metav1.StatusDetails{
932 Causes: []metav1.StatusCause{
933 {
934 Type: "UnexpectedServerResponse",
935 Message: "unable to decode an event from the watch stream: test error",
936 },
937 {
938 Type: "ClientWatchDecoding",
939 Message: "unable to decode an event from the watch stream: test error",
940 },
941 },
942 },
943 },
944 },
945 },

Callers

nothing calls this directly

Calls 7

clientFuncFuncType · 0.85
defaultContentConfigFunction · 0.85
defaultSerializersFunction · 0.85
RunMethod · 0.65
WatchMethod · 0.65
ErrorfMethod · 0.65
ResultChanMethod · 0.45

Tested by

no test coverage detected