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

Method TestUnarySetSendCompressorAfterHeaderSendFailure

test/compressor_test.go:415–440  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

413}
414
415func (s) TestUnarySetSendCompressorAfterHeaderSendFailure(t *testing.T) {
416 ss := &stubserver.StubServer{
417 EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
418 // Send headers early and then set send compressor.
419 grpc.SendHeader(ctx, metadata.MD{})
420 err := grpc.SetSendCompressor(ctx, "gzip")
421 if err == nil {
422 t.Error("Wanted set send compressor error")
423 return &testpb.Empty{}, nil
424 }
425 return nil, err
426 },
427 }
428 if err := ss.Start(nil); err != nil {
429 t.Fatalf("Error starting endpoint server: %v", err)
430 }
431 defer ss.Stop()
432
433 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
434 defer cancel()
435
436 wantErr := status.Error(codes.Unknown, "transport: set send compressor called after headers sent or stream done")
437 if _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}); !equalError(err, wantErr) {
438 t.Fatalf("Unexpected unary call error, got: %v, want: %v", err, wantErr)
439 }
440}
441
442func (s) TestStreamSetSendCompressorAfterHeaderSendFailure(t *testing.T) {
443 ss := &stubserver.StubServer{

Callers

nothing calls this directly

Calls 9

StartMethod · 0.95
StopMethod · 0.95
SendHeaderFunction · 0.92
SetSendCompressorFunction · 0.92
ErrorFunction · 0.92
equalErrorFunction · 0.85
ErrorMethod · 0.65
FatalfMethod · 0.65
EmptyCallMethod · 0.65

Tested by

no test coverage detected