Do not call t.Fatal in goroutine
require.Equal internally calls t.Fatal, which is not safe to call in a goroutine.
This commit is contained in:
+12
-3
@@ -399,13 +399,22 @@ func TestConnConcurrency(t *testing.T) {
|
|||||||
errChan <- fmt.Errorf("select failed: %d %w", idx, err)
|
errChan <- fmt.Errorf("select failed: %d %w", idx, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
require.Equal(t, idx, id)
|
if id != idx {
|
||||||
require.Equal(t, strconv.Itoa(idx), str)
|
errChan <- fmt.Errorf("id mismatch: %d %d", idx, id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if str != strconv.Itoa(idx) {
|
||||||
|
errChan <- fmt.Errorf("str mismatch: %d %s", idx, str)
|
||||||
|
return
|
||||||
|
}
|
||||||
expectedDuration := pgtype.Interval{
|
expectedDuration := pgtype.Interval{
|
||||||
Microseconds: int64(idx) * time.Second.Microseconds(),
|
Microseconds: int64(idx) * time.Second.Microseconds(),
|
||||||
Valid: true,
|
Valid: true,
|
||||||
}
|
}
|
||||||
require.Equal(t, expectedDuration, duration)
|
if duration != expectedDuration {
|
||||||
|
errChan <- fmt.Errorf("duration mismatch: %d %v", idx, duration)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
errChan <- nil
|
errChan <- nil
|
||||||
}(i)
|
}(i)
|
||||||
|
|||||||
Reference in New Issue
Block a user