database/sql, runtime: correct *.Fatal inside goroutines in tests

Found by go vet pass "testinggoroutines".

Change-Id: I6360af2079617b7aa62dcb9bd7254578ca5d1c1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/235527
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
Emmanuel T Odeke 2020-05-29 17:19:42 -07:00 committed by Emmanuel Odeke
parent 9933f66555
commit 715d4e2e01
2 changed files with 22 additions and 10 deletions

View file

@ -2888,20 +2888,26 @@ func TestConnExpiresFreshOutOfPool(t *testing.T) {
waitingForConn := make(chan struct{})
go func() {
defer close(afterPutConn)
conn, err := db.conn(ctx, alwaysNewConn)
if err != nil {
t.Fatal(err)
if err == nil {
db.putConn(conn, err, false)
} else {
t.Errorf("db.conn: %v", err)
}
db.putConn(conn, err, false)
close(afterPutConn)
}()
go func() {
defer close(waitingForConn)
for {
if t.Failed() {
return
}
db.mu.Lock()
ct := len(db.connRequests)
db.mu.Unlock()
if ct > 0 {
close(waitingForConn)
return
}
time.Sleep(10 * time.Millisecond)
@ -2910,6 +2916,10 @@ func TestConnExpiresFreshOutOfPool(t *testing.T) {
<-waitingForConn
if t.Failed() {
return
}
offsetMu.Lock()
if ec.expired {
offset = 11 * time.Second