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

Function testUnarySetSendCompressorSuccess

encoding/compressor_test.go:109–137  ·  view source on GitHub ↗
(t *testing.T, payload *testpb.Payload, resCompressor string, wantCompressInvokes int32, dialOpts []grpc.DialOption)

Source from the content-addressed store, hash-verified

107}
108
109func testUnarySetSendCompressorSuccess(t *testing.T, payload *testpb.Payload, resCompressor string, wantCompressInvokes int32, dialOpts []grpc.DialOption) {
110 wc := setupGzipWrapCompressor(t)
111 ss := &stubserver.StubServer{
112 UnaryCallF: func(ctx context.Context, _ *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
113 if err := grpc.SetSendCompressor(ctx, resCompressor); err != nil {
114 return nil, err
115 }
116 return &testpb.SimpleResponse{
117 Payload: payload,
118 }, nil
119 },
120 }
121 if err := ss.Start(nil, dialOpts...); err != nil {
122 t.Fatalf("Error starting endpoint server: %v", err)
123 }
124 defer ss.Stop()
125
126 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
127 defer cancel()
128
129 if _, err := ss.Client.UnaryCall(ctx, &testpb.SimpleRequest{}); err != nil {
130 t.Fatalf("Unexpected unary call error, got: %v, want: nil", err)
131 }
132
133 compressInvokes := atomic.LoadInt32(&wc.compressInvokes)
134 if compressInvokes != wantCompressInvokes {
135 t.Fatalf("Unexpected compress invokes, got:%d, want: %d", compressInvokes, wantCompressInvokes)
136 }
137}
138
139func testStreamSetSendCompressorSuccess(t *testing.T, payload *testpb.Payload, resCompressor string, wantCompressInvokes int32, dialOpts []grpc.DialOption) {
140 wc := setupGzipWrapCompressor(t)

Callers 1

Calls 6

StartMethod · 0.95
StopMethod · 0.95
SetSendCompressorFunction · 0.92
setupGzipWrapCompressorFunction · 0.85
FatalfMethod · 0.65
UnaryCallMethod · 0.65

Tested by

no test coverage detected