From 7fc908a5f2642471f78b3527cf999545e160445a Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 7 Oct 2023 10:37:18 -0500 Subject: [PATCH] Do not call t.Fatal in goroutine require.Equal internally calls t.Fatal, which is not safe to call in a goroutine. --- stdlib/sql_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/stdlib/sql_test.go b/stdlib/sql_test.go index 023c5355..eb732135 100644 --- a/stdlib/sql_test.go +++ b/stdlib/sql_test.go @@ -399,13 +399,22 @@ func TestConnConcurrency(t *testing.T) { errChan <- fmt.Errorf("select failed: %d %w", idx, err) return } - require.Equal(t, idx, id) - require.Equal(t, strconv.Itoa(idx), str) + if id != idx { + 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{ Microseconds: int64(idx) * time.Second.Microseconds(), Valid: true, } - require.Equal(t, expectedDuration, duration) + if duration != expectedDuration { + errChan <- fmt.Errorf("duration mismatch: %d %v", idx, duration) + return + } errChan <- nil }(i)