startIgnoringPostgresQueryCancel starts the Invocation, but excludes PostgreSQL query canceled and context cancellation errors. This prevents flakes in tests that only assert things that happen before PostgreSQL is fully initialized in the server.
(t *testing.T, inv *serpent.Invocation)
| 2671 | // cancellation errors. This prevents flakes in tests that only assert things that happen before PostgreSQL is fully |
| 2672 | // initialized in the server. |
| 2673 | func startIgnoringPostgresQueryCancel(t *testing.T, inv *serpent.Invocation) { |
| 2674 | t.Helper() |
| 2675 | clitest.StartWithAssert(t, inv, func(t *testing.T, err error) { |
| 2676 | if database.IsQueryCanceledError(err) { |
| 2677 | return |
| 2678 | } |
| 2679 | // specifically when making our initial connection to PostgreSQL, we ping the database. |
| 2680 | // Database driver.Conn instances can return driver.ErrBadConn on ping to remove the connection from the pool. |
| 2681 | // lib/pq does this no matter what the error is, including context.Canceled. |
| 2682 | // c.f. https://pkg.go.dev/database/sql/driver#Pinger |
| 2683 | if xerrors.Is(err, driver.ErrBadConn) { |
| 2684 | return |
| 2685 | } |
| 2686 | assert.NoError(t, err) |
| 2687 | }) |
| 2688 | } |
no test coverage detected