(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func (s) TestSetSendCompressorSuccess(t *testing.T) { |
| 62 | for _, tt := range []struct { |
| 63 | name string |
| 64 | desc string |
| 65 | payload *testpb.Payload |
| 66 | dialOpts []grpc.DialOption |
| 67 | resCompressor string |
| 68 | wantCompressInvokes int32 |
| 69 | }{ |
| 70 | { |
| 71 | name: "identity_request_and_gzip_response", |
| 72 | desc: "request is uncompressed and response is gzip compressed", |
| 73 | payload: &testpb.Payload{Body: []byte("payload")}, |
| 74 | resCompressor: "gzip", |
| 75 | wantCompressInvokes: 1, |
| 76 | }, |
| 77 | { |
| 78 | name: "identity_request_and_empty_response", |
| 79 | desc: "request is uncompressed and response is gzip compressed", |
| 80 | payload: nil, |
| 81 | resCompressor: "gzip", |
| 82 | wantCompressInvokes: 0, |
| 83 | }, |
| 84 | { |
| 85 | name: "gzip_request_and_identity_response", |
| 86 | desc: "request is gzip compressed and response is uncompressed with identity", |
| 87 | payload: &testpb.Payload{Body: []byte("payload")}, |
| 88 | resCompressor: "identity", |
| 89 | dialOpts: []grpc.DialOption{ |
| 90 | // Use WithCompressor instead of UseCompressor to avoid counting |
| 91 | // the client's compressor usage. |
| 92 | grpc.WithCompressor(grpc.NewGZIPCompressor()), |
| 93 | }, |
| 94 | wantCompressInvokes: 0, |
| 95 | }, |
| 96 | } { |
| 97 | t.Run(tt.name, func(t *testing.T) { |
| 98 | t.Run("unary", func(t *testing.T) { |
| 99 | testUnarySetSendCompressorSuccess(t, tt.payload, tt.resCompressor, tt.wantCompressInvokes, tt.dialOpts) |
| 100 | }) |
| 101 | |
| 102 | t.Run("stream", func(t *testing.T) { |
| 103 | testStreamSetSendCompressorSuccess(t, tt.payload, tt.resCompressor, tt.wantCompressInvokes, tt.dialOpts) |
| 104 | }) |
| 105 | }) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func testUnarySetSendCompressorSuccess(t *testing.T, payload *testpb.Payload, resCompressor string, wantCompressInvokes int32, dialOpts []grpc.DialOption) { |
| 110 | wc := setupGzipWrapCompressor(t) |
nothing calls this directly
no test coverage detected