test & testutils: prevent goroutine leaks in test functions (#3133)

This commit is contained in:
lzhfromustc
2019-11-01 17:51:58 -04:00
committed by Doug Fawley
parent 0f32486dd3
commit da2bec01b9
3 changed files with 4 additions and 4 deletions

View File

@ -27,7 +27,7 @@ import (
func TestPipeListener(t *testing.T) {
pl := testutils.NewPipeListener()
recvdBytes := make(chan []byte)
recvdBytes := make(chan []byte, 1)
const want = "hello world"
go func() {

View File

@ -96,7 +96,7 @@ func TestConn(t *testing.T) {
func TestConnCloseWithData(t *testing.T) {
lis := Listen(7)
errChan := make(chan error)
errChan := make(chan error, 1)
var lisConn net.Conn
go func() {
var err error
@ -199,7 +199,7 @@ func TestCloseWhileAccepting(t *testing.T) {
}
func TestDeadline(t *testing.T) {
sig := make(chan error)
sig := make(chan error, 2)
blockingWrite := func(conn net.Conn) {
_, err := conn.Write([]byte("0123456789"))
sig <- err

View File

@ -4694,7 +4694,7 @@ func testClientResourceExhaustedCancelFullDuplex(t *testing.T, e env) {
resp := &testpb.StreamingOutputCallResponse{
Payload: payload,
}
ce := make(chan error)
ce := make(chan error, 1)
go func() {
var err error
for {