@@ -3736,6 +3736,38 @@ func (s) TestClientStreaming_ReturnErrorAfterSendAndClose(t *testing.T) {
37363736 }
37373737}
37383738
3739+ // Tests for a successful RPC, client will continue to receive io.EOF for successive calls to CloseAndRecv().
3740+ func (s ) TestClientStreaming_ClientCallCloseAndRecvAfterCloseAndRecv (t * testing.T ) {
3741+ ss := stubserver.StubServer {
3742+ StreamingInputCallF : func (stream testgrpc.TestService_StreamingInputCallServer ) error {
3743+ if err := stream .SendAndClose (& testpb.StreamingInputCallResponse {}); err != nil {
3744+ t .Errorf ("stream.SendAndClose(_) = %v, want <nil>" , err )
3745+ }
3746+ return nil
3747+ },
3748+ }
3749+ if err := ss .Start (nil ); err != nil {
3750+ t .Fatal ("Error starting server:" , err )
3751+ }
3752+ defer ss .Stop ()
3753+
3754+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
3755+ defer cancel ()
3756+ stream , err := ss .Client .StreamingInputCall (ctx )
3757+ if err != nil {
3758+ t .Fatalf (".StreamingInputCall(_) = _, %v, want <nil>" , err )
3759+ }
3760+ if err := stream .Send (& testpb.StreamingInputCallRequest {}); err != nil {
3761+ t .Fatalf ("stream.Send(_) = %v, want <nil>" , err )
3762+ }
3763+ if _ , err := stream .CloseAndRecv (); err != nil {
3764+ t .Fatalf ("stream.CloseAndRecv() = %v , want <nil>" , err )
3765+ }
3766+ if _ , err := stream .CloseAndRecv (); err != io .EOF {
3767+ t .Fatalf ("stream.CloseAndRecv() = %v, want error %s" , err , io .EOF )
3768+ }
3769+ }
3770+
37393771// Tests that a client receives a cardinality violation error for unary
37403772// RPCs if the server doesn't send a message before returning status OK.
37413773func (s ) TestUnaryRPC_ServerSendsOnlyTrailersWithOK (t * testing.T ) {
0 commit comments