@@ -290,19 +290,29 @@ func (s) TestSetSendCompressorSuccess(t *testing.T) {
290
290
for _ , tt := range []struct {
291
291
name string
292
292
desc string
293
+ payload * testpb.Payload
293
294
dialOpts []grpc.DialOption
294
295
resCompressor string
295
296
wantCompressInvokes int32
296
297
}{
297
298
{
298
299
name : "identity_request_and_gzip_response" ,
299
300
desc : "request is uncompressed and response is gzip compressed" ,
301
+ payload : & testpb.Payload {Body : []byte ("payload" )},
300
302
resCompressor : "gzip" ,
301
303
wantCompressInvokes : 1 ,
302
304
},
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
+ },
303
312
{
304
313
name : "gzip_request_and_identity_response" ,
305
314
desc : "request is gzip compressed and response is uncompressed with identity" ,
315
+ payload : & testpb.Payload {Body : []byte ("payload" )},
306
316
resCompressor : "identity" ,
307
317
dialOpts : []grpc.DialOption {
308
318
// Use WithCompressor instead of UseCompressor to avoid counting
@@ -314,24 +324,26 @@ func (s) TestSetSendCompressorSuccess(t *testing.T) {
314
324
} {
315
325
t .Run (tt .name , func (t * testing.T ) {
316
326
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 )
318
328
})
319
329
320
330
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 )
322
332
})
323
333
})
324
334
}
325
335
}
326
336
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 ) {
328
338
wc := setupGzipWrapCompressor (t )
329
339
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 ) {
331
341
if err := grpc .SetSendCompressor (ctx , resCompressor ); err != nil {
332
342
return nil , err
333
343
}
334
- return & testpb.Empty {}, nil
344
+ return & testpb.SimpleResponse {
345
+ Payload : payload ,
346
+ }, nil
335
347
},
336
348
}
337
349
if err := ss .Start (nil , dialOpts ... ); err != nil {
@@ -342,7 +354,7 @@ func testUnarySetSendCompressorSuccess(t *testing.T, resCompressor string, wantC
342
354
ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
343
355
defer cancel ()
344
356
345
- if _ , err := ss .Client .EmptyCall (ctx , & testpb.Empty {}); err != nil {
357
+ if _ , err := ss .Client .UnaryCall (ctx , & testpb.SimpleRequest {}); err != nil {
346
358
t .Fatalf ("Unexpected unary call error, got: %v, want: nil" , err )
347
359
}
348
360
@@ -352,7 +364,7 @@ func testUnarySetSendCompressorSuccess(t *testing.T, resCompressor string, wantC
352
364
}
353
365
}
354
366
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 ) {
356
368
wc := setupGzipWrapCompressor (t )
357
369
ss := & stubserver.StubServer {
358
370
FullDuplexCallF : func (stream testgrpc.TestService_FullDuplexCallServer ) error {
@@ -364,7 +376,9 @@ func testStreamSetSendCompressorSuccess(t *testing.T, resCompressor string, want
364
376
return err
365
377
}
366
378
367
- return stream .Send (& testpb.StreamingOutputCallResponse {})
379
+ return stream .Send (& testpb.StreamingOutputCallResponse {
380
+ Payload : payload ,
381
+ })
368
382
},
369
383
}
370
384
if err := ss .Start (nil , dialOpts ... ); err != nil {
0 commit comments