@@ -290,19 +290,29 @@ func (s) TestSetSendCompressorSuccess(t *testing.T) {
290290 for _ , tt := range []struct {
291291 name string
292292 desc string
293+ payload * testpb.Payload
293294 dialOpts []grpc.DialOption
294295 resCompressor string
295296 wantCompressInvokes int32
296297 }{
297298 {
298299 name : "identity_request_and_gzip_response" ,
299300 desc : "request is uncompressed and response is gzip compressed" ,
301+ payload : & testpb.Payload {Body : []byte ("payload" )},
300302 resCompressor : "gzip" ,
301303 wantCompressInvokes : 1 ,
302304 },
305+ {
306+ name : "identity_request_and_empty_response" ,
307+ desc : "request is uncompressed and response is gzip compressed" ,
308+ payload : nil ,
309+ resCompressor : "gzip" ,
310+ wantCompressInvokes : 0 ,
311+ },
303312 {
304313 name : "gzip_request_and_identity_response" ,
305314 desc : "request is gzip compressed and response is uncompressed with identity" ,
315+ payload : & testpb.Payload {Body : []byte ("payload" )},
306316 resCompressor : "identity" ,
307317 dialOpts : []grpc.DialOption {
308318 // Use WithCompressor instead of UseCompressor to avoid counting
@@ -314,24 +324,26 @@ func (s) TestSetSendCompressorSuccess(t *testing.T) {
314324 } {
315325 t .Run (tt .name , func (t * testing.T ) {
316326 t .Run ("unary" , func (t * testing.T ) {
317- testUnarySetSendCompressorSuccess (t , tt .resCompressor , tt .wantCompressInvokes , tt .dialOpts )
327+ testUnarySetSendCompressorSuccess (t , tt .payload , tt . resCompressor , tt .wantCompressInvokes , tt .dialOpts )
318328 })
319329
320330 t .Run ("stream" , func (t * testing.T ) {
321- testStreamSetSendCompressorSuccess (t , tt .resCompressor , tt .wantCompressInvokes , tt .dialOpts )
331+ testStreamSetSendCompressorSuccess (t , tt .payload , tt . resCompressor , tt .wantCompressInvokes , tt .dialOpts )
322332 })
323333 })
324334 }
325335}
326336
327- func testUnarySetSendCompressorSuccess (t * testing.T , resCompressor string , wantCompressInvokes int32 , dialOpts []grpc.DialOption ) {
337+ func testUnarySetSendCompressorSuccess (t * testing.T , payload * testpb. Payload , resCompressor string , wantCompressInvokes int32 , dialOpts []grpc.DialOption ) {
328338 wc := setupGzipWrapCompressor (t )
329339 ss := & stubserver.StubServer {
330- EmptyCallF : func (ctx context.Context , in * testpb.Empty ) (* testpb.Empty , error ) {
340+ UnaryCallF : func (ctx context.Context , in * testpb.SimpleRequest ) (* testpb.SimpleResponse , error ) {
331341 if err := grpc .SetSendCompressor (ctx , resCompressor ); err != nil {
332342 return nil , err
333343 }
334- return & testpb.Empty {}, nil
344+ return & testpb.SimpleResponse {
345+ Payload : payload ,
346+ }, nil
335347 },
336348 }
337349 if err := ss .Start (nil , dialOpts ... ); err != nil {
@@ -342,7 +354,7 @@ func testUnarySetSendCompressorSuccess(t *testing.T, resCompressor string, wantC
342354 ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
343355 defer cancel ()
344356
345- if _ , err := ss .Client .EmptyCall (ctx , & testpb.Empty {}); err != nil {
357+ if _ , err := ss .Client .UnaryCall (ctx , & testpb.SimpleRequest {}); err != nil {
346358 t .Fatalf ("Unexpected unary call error, got: %v, want: nil" , err )
347359 }
348360
@@ -352,7 +364,7 @@ func testUnarySetSendCompressorSuccess(t *testing.T, resCompressor string, wantC
352364 }
353365}
354366
355- func testStreamSetSendCompressorSuccess (t * testing.T , resCompressor string , wantCompressInvokes int32 , dialOpts []grpc.DialOption ) {
367+ func testStreamSetSendCompressorSuccess (t * testing.T , payload * testpb. Payload , resCompressor string , wantCompressInvokes int32 , dialOpts []grpc.DialOption ) {
356368 wc := setupGzipWrapCompressor (t )
357369 ss := & stubserver.StubServer {
358370 FullDuplexCallF : func (stream testgrpc.TestService_FullDuplexCallServer ) error {
@@ -364,7 +376,9 @@ func testStreamSetSendCompressorSuccess(t *testing.T, resCompressor string, want
364376 return err
365377 }
366378
367- return stream .Send (& testpb.StreamingOutputCallResponse {})
379+ return stream .Send (& testpb.StreamingOutputCallResponse {
380+ Payload : payload ,
381+ })
368382 },
369383 }
370384 if err := ss .Start (nil , dialOpts ... ); err != nil {
0 commit comments