@@ -31,6 +31,7 @@ import (
3131 "github.com/containerd/ttrpc"
3232 "github.com/containerd/ttrpc/integration/streaming"
3333 "github.com/golang/protobuf/ptypes/empty"
34+ "google.golang.org/protobuf/types/known/emptypb"
3435)
3536
3637func runService (ctx context.Context , t testing.TB , service streaming.TTRPCStreamingService ) (streaming.TTRPCStreamingClient , func ()) {
@@ -190,6 +191,14 @@ func (tss *testStreamingService) EchoNullStream(_ context.Context, es streaming.
190191 return sendErr
191192}
192193
194+ func (tss * testStreamingService ) EmptyPayloadStream (_ context.Context , _ * emptypb.Empty , streamer streaming.TTRPCStreaming_EmptyPayloadStreamServer ) error {
195+ if err := streamer .Send (& streaming.EchoPayload {Seq : 1 }); err != nil {
196+ return err
197+ }
198+
199+ return streamer .Send (& streaming.EchoPayload {Seq : 2 })
200+ }
201+
193202func TestStreamingService (t * testing.T ) {
194203 ctx , cancel := context .WithCancel (context .Background ())
195204 defer cancel ()
@@ -203,6 +212,7 @@ func TestStreamingService(t *testing.T) {
203212 t .Run ("DivideStream" , divideStreamTest (ctx , client ))
204213 t .Run ("EchoNull" , echoNullTest (ctx , client ))
205214 t .Run ("EchoNullStream" , echoNullStreamTest (ctx , client ))
215+ t .Run ("EmptyPayloadStream" , emptyPayloadStream (ctx , client ))
206216}
207217
208218func echoTest (ctx context.Context , client streaming.TTRPCStreamingClient ) func (t * testing.T ) {
@@ -385,6 +395,33 @@ func echoNullStreamTest(ctx context.Context, client streaming.TTRPCStreamingClie
385395 }
386396}
387397
398+ func emptyPayloadStream (ctx context.Context , client streaming.TTRPCStreamingClient ) func (t * testing.T ) {
399+ return func (t * testing.T ) {
400+ ctx , cancel := context .WithTimeout (ctx , 5 * time .Second )
401+ defer cancel ()
402+
403+ stream , err := client .EmptyPayloadStream (ctx , nil )
404+ if err != nil {
405+ t .Fatal (err )
406+ }
407+
408+ for i := uint32 (1 ); i < 3 ; i ++ {
409+ first , err := stream .Recv ()
410+ if err != nil {
411+ t .Fatal (err )
412+ }
413+
414+ if first .Seq != i {
415+ t .Fatalf ("unexpected seq: %d != %d" , first .Seq , i )
416+ }
417+ }
418+
419+ if _ , err := stream .Recv (); err != io .EOF {
420+ t .Fatalf ("Expected io.EOF, got %v" , err )
421+ }
422+ }
423+ }
424+
388425func assertNextEcho (t testing.TB , a , b * streaming.EchoPayload ) {
389426 t .Helper ()
390427 if a .Msg != b .Msg {
0 commit comments