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

Method TestStream_Header_TrailersOnly

stream_test.go:47–71  ·  stream_test.go::s.TestStream_Header_TrailersOnly
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func (s) TestStream_Header_TrailersOnly(t *testing.T) {
48 ss := stubserver.StubServer{
49 FullDuplexCallF: func(testgrpc.TestService_FullDuplexCallServer) error {
50 return status.Errorf(codes.NotFound, "a test error")
51 },
52 }
53 if err := ss.Start(nil); err != nil {
54 t.Fatal("Error starting server:", err)
55 }
56 defer ss.Stop()
57
58 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
59 defer cancel()
60
61 s, err := ss.Client.FullDuplexCall(ctx)
62 if err != nil {
63 t.Fatal("Error staring call", err)
64 }
65 if md, err := s.Header(); md != nil || err != nil {
66 t.Fatalf("s.Header() = %v, %v; want nil, nil", md, err)
67 }
68 if _, err := s.Recv(); status.Code(err) != codes.NotFound {
69 t.Fatalf("s.Recv() = _, %v; want _, err.Code()=codes.NotFound", err)
70 }
71}
72
73// TestUnaryClient_ServerStreamingMismatch ensures that the client's
74// non-streaming RecvMsg() logic correctly handles various error scenarios

Callers

nothing calls this directly

Calls 9

StartMethod · 0.95
StopMethod · 0.95
ErrorfFunction · 0.92
CodeFunction · 0.92
FatalMethod · 0.65
FullDuplexCallMethod · 0.65
HeaderMethod · 0.65
FatalfMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected