Tests the behavior for client-streaming RPC when client calls RecvMsg() twice. Second call to RecvMsg should fail with io.EOF.
(t *testing.T)
| 3909 | // Tests the behavior for client-streaming RPC when client calls RecvMsg() twice. |
| 3910 | // Second call to RecvMsg should fail with io.EOF. |
| 3911 | func (s) TestClientStreaming_ClientCallRecvMsgTwice(t *testing.T) { |
| 3912 | ss := stubserver.StubServer{ |
| 3913 | StreamingInputCallF: func(stream testgrpc.TestService_StreamingInputCallServer) error { |
| 3914 | if err := stream.RecvMsg(&testpb.StreamingInputCallRequest{}); err != nil { |
| 3915 | t.Errorf("stream.RecvMsg() = %v, want <nil>", err) |
| 3916 | } |
| 3917 | if err := stream.SendAndClose(&testpb.StreamingInputCallResponse{}); err != nil { |
| 3918 | t.Errorf("stream.SendAndClose(_) = %v, want <nil>", err) |
| 3919 | } |
| 3920 | return nil |
| 3921 | }, |
| 3922 | } |
| 3923 | if err := ss.Start(nil); err != nil { |
| 3924 | t.Fatal("Error starting server:", err) |
| 3925 | } |
| 3926 | defer ss.Stop() |
| 3927 | |
| 3928 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 3929 | defer cancel() |
| 3930 | stream, err := ss.Client.StreamingInputCall(ctx) |
| 3931 | if err != nil { |
| 3932 | t.Fatalf(".StreamingInputCall(_) = _, %v, want <nil>", err) |
| 3933 | } |
| 3934 | if err := stream.Send(&testpb.StreamingInputCallRequest{}); err != nil { |
| 3935 | t.Fatalf("stream.Send(_) = %v, want <nil>", err) |
| 3936 | } |
| 3937 | if err := stream.CloseSend(); err != nil { |
| 3938 | t.Fatalf("stream.CloseSend() = %v, want <nil>", err) |
| 3939 | } |
| 3940 | resp := new(testpb.StreamingInputCallResponse) |
| 3941 | if err := stream.RecvMsg(resp); err != nil { |
| 3942 | t.Fatalf("stream.RecvMsg() = %v , want <nil>", err) |
| 3943 | } |
| 3944 | if err = stream.RecvMsg(resp); err != io.EOF { |
| 3945 | t.Errorf("stream.RecvMsg() = %v, want error %v", err, io.EOF) |
| 3946 | } |
| 3947 | } |
| 3948 | |
| 3949 | // Tests the behavior for server-side streaming when client calls SendMsg twice. |
| 3950 | // Second call to SendMsg should fail with Internal error and result in closing |
nothing calls this directly
no test coverage detected