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

Function testStreamServerInterceptor

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

Source from the content-addressed store, hash-verified

4455}
4456
4457func testStreamServerInterceptor(t *testing.T, e env) {
4458 te := newTest(t, e)
4459 te.streamServerInt = fullDuplexOnly
4460 te.startServer(&testServer{security: e.security})
4461 defer te.tearDown()
4462
4463 tc := testgrpc.NewTestServiceClient(te.clientConn())
4464 respParam := []*testpb.ResponseParameters{
4465 {
4466 Size: int32(1),
4467 },
4468 }
4469 payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, int32(1))
4470 if err != nil {
4471 t.Fatal(err)
4472 }
4473 req := &testpb.StreamingOutputCallRequest{
4474 ResponseType: testpb.PayloadType_COMPRESSABLE,
4475 ResponseParameters: respParam,
4476 Payload: payload,
4477 }
4478 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
4479 defer cancel()
4480 s1, err := tc.StreamingOutputCall(ctx, req)
4481 if err != nil {
4482 t.Fatalf("%v.StreamingOutputCall(_) = _, %v, want _, <nil>", tc, err)
4483 }
4484 if _, err := s1.Recv(); status.Code(err) != codes.PermissionDenied {
4485 t.Fatalf("%v.StreamingInputCall(_) = _, %v, want _, error code %s", tc, err, codes.PermissionDenied)
4486 }
4487 s2, err := tc.FullDuplexCall(ctx)
4488 if err != nil {
4489 t.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err)
4490 }
4491 if err := s2.Send(req); err != nil {
4492 t.Fatalf("%v.Send(_) = %v, want <nil>", s2, err)
4493 }
4494 if _, err := s2.Recv(); err != nil {
4495 t.Fatalf("%v.Recv() = _, %v, want _, <nil>", s2, err)
4496 }
4497}
4498
4499// funcServer implements methods of TestServiceServer using funcs,
4500// similar to an http.HandlerFunc.

Callers 1

Calls 12

StreamingOutputCallMethod · 0.95
FullDuplexCallMethod · 0.95
newPayloadFunction · 0.85
CodeMethod · 0.80
newTestFunction · 0.70
FatalMethod · 0.65
FatalfMethod · 0.65
RecvMethod · 0.65
SendMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected