Skip to content

Commit

Permalink
added select statement for case
Browse files Browse the repository at this point in the history
  • Loading branch information
misvivek committed Dec 4, 2024
1 parent 0cf3584 commit dea8408
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/transport/handler_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ func (s) TestHandlerTransport_HandleStreams_Timeout(t *testing.T) {
t.Errorf("ctx.Err = %v; want %v", err, context.DeadlineExceeded)
return
}
s.WriteStatus(status.New(codes.DeadlineExceeded, "too slow"))
// rst flag setting to verify the noop function: signalDeadlineExceeded
ch := make(chan struct{}, 1)
origSignalDeadlineExceeded := signalDeadlineExceeded
Expand All @@ -403,9 +402,14 @@ func (s) TestHandlerTransport_HandleStreams_Timeout(t *testing.T) {
defer func() {
signalDeadlineExceeded = origSignalDeadlineExceeded
}()

s.WriteStatus(status.New(codes.DeadlineExceeded, "too slow"))
select {
case <-s.ctx.Done():
case <-time.After(5 * time.Second):
t.Errorf("timeout waiting for ctx.Done")
return
}
}

ht.HandleStreams(
context.Background(), func(s *ServerStream) { go runStream(s) },
)
Expand Down

0 comments on commit dea8408

Please sign in to comment.