(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func TestForwardResponseStream(t *testing.T) { |
| 31 | type msg struct { |
| 32 | pb proto.Message |
| 33 | err error |
| 34 | } |
| 35 | tests := []struct { |
| 36 | name string |
| 37 | msgs []msg |
| 38 | statusCode int |
| 39 | responseBody bool |
| 40 | disableChunkedEncoding bool |
| 41 | }{{ |
| 42 | name: "encoding", |
| 43 | msgs: []msg{ |
| 44 | {&pb.SimpleMessage{Id: "One"}, nil}, |
| 45 | {&pb.SimpleMessage{Id: "Two"}, nil}, |
| 46 | }, |
| 47 | statusCode: http.StatusOK, |
| 48 | }, { |
| 49 | name: "empty", |
| 50 | statusCode: http.StatusOK, |
| 51 | }, { |
| 52 | name: "error", |
| 53 | msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}}, |
| 54 | statusCode: http.StatusBadRequest, |
| 55 | }, { |
| 56 | name: "stream_error", |
| 57 | msgs: []msg{ |
| 58 | {&pb.SimpleMessage{Id: "One"}, nil}, |
| 59 | {nil, status.Errorf(codes.OutOfRange, "400")}, |
| 60 | }, |
| 61 | statusCode: http.StatusOK, |
| 62 | }, { |
| 63 | name: "response body stream case", |
| 64 | msgs: []msg{ |
| 65 | {fakeResponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil}, |
| 66 | {fakeResponseBodyWrapper{&pb.SimpleMessage{Id: "Two"}}, nil}, |
| 67 | }, |
| 68 | responseBody: true, |
| 69 | statusCode: http.StatusOK, |
| 70 | }, { |
| 71 | name: "response body stream error case", |
| 72 | msgs: []msg{ |
| 73 | {fakeResponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil}, |
| 74 | {nil, status.Errorf(codes.OutOfRange, "400")}, |
| 75 | }, |
| 76 | responseBody: true, |
| 77 | statusCode: http.StatusOK, |
| 78 | }, { |
| 79 | name: "disable chunked encoding", |
| 80 | msgs: []msg{ |
| 81 | {&pb.SimpleMessage{Id: "One"}, nil}, |
| 82 | }, |
| 83 | statusCode: http.StatusOK, |
| 84 | disableChunkedEncoding: true, |
| 85 | }} |
| 86 | |
| 87 | newTestRecv := func(t *testing.T, msgs []msg) func() (proto.Message, error) { |
nothing calls this directly
no test coverage detected