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

Function testFailedServerStreaming

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

Source from the content-addressed store, hash-verified

3412}
3413
3414func testFailedServerStreaming(t *testing.T, e env) {
3415 te := newTest(t, e)
3416 te.userAgent = failAppUA
3417 te.startServer(&testServer{security: e.security})
3418 defer te.tearDown()
3419 tc := testgrpc.NewTestServiceClient(te.clientConn())
3420
3421 respParam := make([]*testpb.ResponseParameters, len(respSizes))
3422 for i, s := range respSizes {
3423 respParam[i] = &testpb.ResponseParameters{
3424 Size: int32(s),
3425 }
3426 }
3427 req := &testpb.StreamingOutputCallRequest{
3428 ResponseType: testpb.PayloadType_COMPRESSABLE,
3429 ResponseParameters: respParam,
3430 }
3431 ctx := metadata.NewOutgoingContext(te.ctx, testMetadata)
3432 stream, err := tc.StreamingOutputCall(ctx, req)
3433 if err != nil {
3434 t.Fatalf("%v.StreamingOutputCall(_) = _, %v, want <nil>", tc, err)
3435 }
3436 wantErr := status.Error(codes.DataLoss, "error for testing: "+failAppUA)
3437 if _, err := stream.Recv(); !equalError(err, wantErr) {
3438 t.Fatalf("%v.Recv() = _, %v, want _, %v", stream, err, wantErr)
3439 }
3440}
3441
3442func equalError(x, y error) bool {
3443 return x == y || (x != nil && y != nil && x.Error() == y.Error())

Callers 1

Calls 10

StreamingOutputCallMethod · 0.95
NewOutgoingContextFunction · 0.92
equalErrorFunction · 0.85
newTestFunction · 0.70
FatalfMethod · 0.65
ErrorMethod · 0.65
RecvMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected