mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
9933f66555
commit
715d4e2e01
2 changed files with 22 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue