MCPcopy
hub / github.com/grpc/grpc-go / TestStreamSetSendCompressorAfterHeaderSendFailure

Method TestStreamSetSendCompressorAfterHeaderSendFailure

test/compressor_test.go:442–471  ·  test/compressor_test.go::s.TestStreamSetSendCompressorAfterHeaderSendFailure
(t *testing.T)

Source from the content-addressed store, hash-verified

440}
441
442func (s) TestStreamSetSendCompressorAfterHeaderSendFailure(t *testing.T) {
443 ss := &stubserver.StubServer{
444 FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
445 // Send headers early and then set send compressor.
446 grpc.SendHeader(stream.Context(), metadata.MD{})
447 err := grpc.SetSendCompressor(stream.Context(), "gzip")
448 if err == nil {
449 t.Error("Wanted set send compressor error")
450 }
451 return err
452 },
453 }
454 if err := ss.Start(nil); err != nil {
455 t.Fatalf("Error starting endpoint server: %v", err)
456 }
457 defer ss.Stop()
458
459 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
460 defer cancel()
461
462 wantErr := status.Error(codes.Unknown, "transport: set send compressor called after headers sent or stream done")
463 s, err := ss.Client.FullDuplexCall(ctx)
464 if err != nil {
465 t.Fatalf("Unexpected full duplex call error, got: %v, want: nil", err)
466 }
467
468 if _, err := s.Recv(); !equalError(err, wantErr) {
469 t.Fatalf("Unexpected full duplex recv error, got: %v, want: %v", err, wantErr)
470 }
471}
472
473func (s) TestClientSupportedCompressors(t *testing.T) {
474 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)

Callers

nothing calls this directly

Calls 11

StartMethod · 0.95
StopMethod · 0.95
SendHeaderFunction · 0.92
SetSendCompressorFunction · 0.92
ErrorFunction · 0.92
equalErrorFunction · 0.85
ContextMethod · 0.65
ErrorMethod · 0.65
FatalfMethod · 0.65
FullDuplexCallMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected