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

Method TestClientStreaming_ServerHandlerSendMsgAfterSendMsg

test/end2end_test.go:4200–4229  ·  view source on GitHub ↗

Tests that a client receives a cardinality violation error for client-streaming RPCs if the server calls SendMsg() multiple times.

(t *testing.T)

Source from the content-addressed store, hash-verified

4198// Tests that a client receives a cardinality violation error for client-streaming
4199// RPCs if the server calls SendMsg() multiple times.
4200func (s) TestClientStreaming_ServerHandlerSendMsgAfterSendMsg(t *testing.T) {
4201 ss := stubserver.StubServer{
4202 StreamingInputCallF: func(stream testgrpc.TestService_StreamingInputCallServer) error {
4203 if err := stream.SendMsg(&testpb.StreamingInputCallResponse{}); err != nil {
4204 t.Errorf("stream.SendMsg(_) = %v, want <nil>", err)
4205 }
4206 if err := stream.SendMsg(&testpb.StreamingInputCallResponse{}); err != nil {
4207 t.Errorf("stream.SendMsg(_) = %v, want <nil>", err)
4208 }
4209 return nil
4210 },
4211 }
4212 if err := ss.Start(nil); err != nil {
4213 t.Fatal("Error starting server:", err)
4214 }
4215 defer ss.Stop()
4216
4217 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
4218 defer cancel()
4219 stream, err := ss.Client.StreamingInputCall(ctx)
4220 if err != nil {
4221 t.Fatalf(".StreamingInputCall(_) = _, %v, want <nil>", err)
4222 }
4223 if err := stream.Send(&testpb.StreamingInputCallRequest{}); err != nil {
4224 t.Fatalf("stream.Send(_) = %v, want <nil>", err)
4225 }
4226 if _, err := stream.CloseAndRecv(); status.Code(err) != codes.Internal {
4227 t.Fatalf("stream.CloseAndRecv() = %v, want error with status code %s", err, codes.Internal)
4228 }
4229}
4230
4231func (s) TestExceedMaxStreamsLimit(t *testing.T) {
4232 for _, e := range listTestEnv() {

Callers

nothing calls this directly

Calls 10

StartMethod · 0.95
StopMethod · 0.95
CodeMethod · 0.80
SendMsgMethod · 0.65
ErrorfMethod · 0.65
FatalMethod · 0.65
StreamingInputCallMethod · 0.65
FatalfMethod · 0.65
SendMethod · 0.65
CloseAndRecvMethod · 0.65

Tested by

no test coverage detected