Skip to content

Commit 7fc908a

Browse files
committed
Do not call t.Fatal in goroutine
require.Equal internally calls t.Fatal, which is not safe to call in a goroutine.
1 parent 0f0d236 commit 7fc908a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

stdlib/sql_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,22 @@ func TestConnConcurrency(t *testing.T) {
399399
errChan <- fmt.Errorf("select failed: %d %w", idx, err)
400400
return
401401
}
402-
require.Equal(t, idx, id)
403-
require.Equal(t, strconv.Itoa(idx), str)
402+
if id != idx {
403+
errChan <- fmt.Errorf("id mismatch: %d %d", idx, id)
404+
return
405+
}
406+
if str != strconv.Itoa(idx) {
407+
errChan <- fmt.Errorf("str mismatch: %d %s", idx, str)
408+
return
409+
}
404410
expectedDuration := pgtype.Interval{
405411
Microseconds: int64(idx) * time.Second.Microseconds(),
406412
Valid: true,
407413
}
408-
require.Equal(t, expectedDuration, duration)
414+
if duration != expectedDuration {
415+
errChan <- fmt.Errorf("duration mismatch: %d %v", idx, duration)
416+
return
417+
}
409418

410419
errChan <- nil
411420
}(i)

0 commit comments

Comments
 (0)