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

Function testClientStreaming

test/end2end_test.go:3557–3592  ·  view source on GitHub ↗
(t *testing.T, e env, sizes []int)

Source from the content-addressed store, hash-verified

3555}
3556
3557func testClientStreaming(t *testing.T, e env, sizes []int) {
3558 te := newTest(t, e)
3559 te.startServer(&testServer{security: e.security})
3560 defer te.tearDown()
3561 tc := testgrpc.NewTestServiceClient(te.clientConn())
3562
3563 ctx, cancel := context.WithTimeout(te.ctx, defaultTestTimeout)
3564 defer cancel()
3565 stream, err := tc.StreamingInputCall(ctx)
3566 if err != nil {
3567 t.Fatalf("%v.StreamingInputCall(_) = _, %v, want <nil>", tc, err)
3568 }
3569
3570 var sum int
3571 for _, s := range sizes {
3572 payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, int32(s))
3573 if err != nil {
3574 t.Fatal(err)
3575 }
3576
3577 req := &testpb.StreamingInputCallRequest{
3578 Payload: payload,
3579 }
3580 if err := stream.Send(req); err != nil {
3581 t.Fatalf("%v.Send(_) = %v, want <nil>", stream, err)
3582 }
3583 sum += s
3584 }
3585 reply, err := stream.CloseAndRecv()
3586 if err != nil {
3587 t.Fatalf("%v.CloseAndRecv() got error %v, want %v", stream, err, nil)
3588 }
3589 if reply.GetAggregatedPayloadSize() != int32(sum) {
3590 t.Fatalf("%v.CloseAndRecv().GetAggregatePayloadSize() = %v; want %v", stream, reply.GetAggregatedPayloadSize(), sum)
3591 }
3592}
3593
3594func (s) TestClientStreamingError(t *testing.T) {
3595 for _, e := range listTestEnv() {

Callers 1

TestClientStreamingMethod · 0.85

Calls 11

StreamingInputCallMethod · 0.95
newPayloadFunction · 0.85
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