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

Function testClientStreamingError

test/end2end_test.go:3603–3634  ·  view source on GitHub ↗
(t *testing.T, e env)

Source from the content-addressed store, hash-verified

3601}
3602
3603func testClientStreamingError(t *testing.T, e env) {
3604 te := newTest(t, e)
3605 te.startServer(&testServer{security: e.security, earlyFail: true})
3606 defer te.tearDown()
3607 tc := testgrpc.NewTestServiceClient(te.clientConn())
3608
3609 stream, err := tc.StreamingInputCall(te.ctx)
3610 if err != nil {
3611 t.Fatalf("%v.StreamingInputCall(_) = _, %v, want <nil>", tc, err)
3612 }
3613 payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, 1)
3614 if err != nil {
3615 t.Fatal(err)
3616 }
3617
3618 req := &testpb.StreamingInputCallRequest{
3619 Payload: payload,
3620 }
3621 // The 1st request should go through.
3622 if err := stream.Send(req); err != nil {
3623 t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, req, err)
3624 }
3625 for {
3626 if err := stream.Send(req); err != io.EOF {
3627 continue
3628 }
3629 if _, err := stream.CloseAndRecv(); status.Code(err) != codes.NotFound {
3630 t.Fatalf("%v.CloseAndRecv() = %v, want error %s", stream, err, codes.NotFound)
3631 }
3632 break
3633 }
3634}
3635
3636// Tests that a client receives a cardinality violation error for client-streaming
3637// RPCs if the server doesn't send a message before returning status OK.

Callers 1

Calls 11

StreamingInputCallMethod · 0.95
newPayloadFunction · 0.85
CodeMethod · 0.80
newTestFunction · 0.70
FatalfMethod · 0.65
FatalMethod · 0.65
SendMethod · 0.65
CloseAndRecvMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected