Skip to content

Commit

Permalink
Update bufpipe_test.go
Browse files Browse the repository at this point in the history
Add test for close deadlock
  • Loading branch information
wnke authored May 10, 2021
1 parent 2cfa345 commit 55b70ec
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bufpipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,20 @@ func TestPipeReader_CloseWithError(t *testing.T) {
is.Equal(err, expect)
is.Equal(n, 0)
}

func TestPipeReader_WriterCloseNoDeadlock(t *testing.T) {
r, w := bufpipe.New(nil)

done := make(chan struct{})
go func(t *testing.T) {
buf := make([]byte, 800)
r.Read(buf)
done <- struct{}{}
}(t)

time.Sleep(300 * time.Millisecond)
w.Close()

<-done
}

0 comments on commit 55b70ec

Please sign in to comment.