MCPcopy Index your code
hub / github.com/coder/coder / startIgnoringPostgresQueryCancel

Function startIgnoringPostgresQueryCancel

cli/server_test.go:2673–2688  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2671// cancellation errors. This prevents flakes in tests that only assert things that happen before PostgreSQL is fully
2672// initialized in the server.
2673func 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}

Callers 2

TestServerFunction · 0.85

Calls 4

StartWithAssertFunction · 0.92
IsQueryCanceledErrorFunction · 0.92
HelperMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected