(t *testing.T)
| 886 | func (r errorReader) Close() error { return nil } |
| 887 | |
| 888 | func 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 | }, |
nothing calls this directly
no test coverage detected